Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Move page views urls to separate file

dominik-zeglen7e26d8f53dee
diff --git a/saleor/static/dashboard-next/pages/index.tsx b/saleor/static/dashboard-next/pages/index.tsx
index b743fbc3d8..fb44cb14c6 100644
--- a/saleor/static/dashboard-next/pages/index.tsx
+++ b/saleor/static/dashboard-next/pages/index.tsx
@@ -35,15 +35,4 @@ const Component = ({ match }) => (
</>
);
-export function pageEditUrl(id: string) {
- return `/pages/${id}/`;
-}
-
-export function pageStorefrontUrl(slug: string) {
- return `/page/${slug}/`;
-}
-
-export const pageListUrl = "/pages/";
-export const pageAddUrl = "/pages/add/";
-
export default Component;
diff --git a/saleor/static/dashboard-next/pages/urls.ts b/saleor/static/dashboard-next/pages/urls.ts
new file mode 100644
index 0000000000..652b49681a
--- /dev/null
+++ b/saleor/static/dashboard-next/pages/urls.ts
@@ -0,0 +1,6 @@
+import * as urlJoin from "url-join";
+
+const pageSectionUrl = "/pages/";
+export const pageListUrl = pageSectionUrl;
+export const pageUrl = (id: string) => urlJoin(pageSectionUrl, id);
+export const pageAddUrl = urlJoin(pageSectionUrl, "add");
diff --git a/saleor/static/dashboard-next/pages/views/PageCreate.tsx b/saleor/static/dashboard-next/pages/views/PageCreate.tsx
index 1a6f6dde17..7c02e8a741 100644
--- a/saleor/static/dashboard-next/pages/views/PageCreate.tsx
+++ b/saleor/static/dashboard-next/pages/views/PageCreate.tsx
@@ -1,12 +1,12 @@
import * as React from "react";
import { Redirect } from "react-router";
-import { pageListUrl } from "..";
import { NavigatorLink } from "../../components/Navigator";
import { WindowTitle } from "../../components/WindowTitle";
import i18n from "../../i18n";
import PageDetailsPage from "../../pages/components/PageDetailsPage";
import { TypedPageCreateMutation } from "../mutations";
+import { pageListUrl } from "../urls";
export const PageCreateForm: React.StatelessComponent = () => (
<TypedPageCreateMutation>
diff --git a/saleor/static/dashboard-next/pages/views/PageDetails.tsx b/saleor/static/dashboard-next/pages/views/PageDetails.tsx
index 2caeda57fb..4d0de0df2c 100644
--- a/saleor/static/dashboard-next/pages/views/PageDetails.tsx
+++ b/saleor/static/dashboard-next/pages/views/PageDetails.tsx
@@ -1,7 +1,6 @@
import * as React from "react";
import { Redirect } from "react-router";
-import { pageListUrl } from "..";
import ErrorMessageCard from "../../components/ErrorMessageCard";
import { NavigatorLink } from "../../components/Navigator";
import { WindowTitle } from "../../components/WindowTitle";
@@ -10,6 +9,7 @@ import { maybe } from "../../misc";
import PageDetailsPage from "../components/PageDetailsPage";
import { TypedPageDeleteMutation, TypedPageUpdateMutation } from "../mutations";
import { pageDetailsQuery, TypedPageDetailsQuery } from "../queries";
+import { pageListUrl } from "../urls";
interface PageUpdateFormProps {
id: string;
diff --git a/saleor/static/dashboard-next/pages/views/PageList.tsx b/saleor/static/dashboard-next/pages/views/PageList.tsx
index 70aea3b507..3dbf53146e 100644
--- a/saleor/static/dashboard-next/pages/views/PageList.tsx
+++ b/saleor/static/dashboard-next/pages/views/PageList.tsx
@@ -6,8 +6,8 @@ import { createPaginationState, Paginator } from "../../components/Paginator";
import i18n from "../../i18n";
import { maybe } from "../../misc";
import PageListPage from "../components/PageListPage/PageListPage";
-import { pageAddUrl, pageEditUrl } from "../index";
import { pageListQuery, TypedPageListQuery } from "../queries";
+import { pageAddUrl, pageUrl } from "../urls";
export type PageListQueryParams = Partial<{ after: string; before: string }>;
@@ -23,7 +23,7 @@ export const PageList: React.StatelessComponent<PageListProps> = ({
<Navigator>
{navigate => {
const paginationState = createPaginationState(PAGINATE_BY, params);
- const handleEditClick = (id: string) => () => navigate(pageEditUrl(id));
+ const handleEditClick = (id: string) => () => navigate(pageUrl(id));
return (
<TypedPageListQuery
query={pageListQuery}