Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Move category view urls to separate file
dominik-zeglen5cfed7bec6d1
diff --git a/saleor/static/dashboard-next/AppRoot.tsx b/saleor/static/dashboard-next/AppRoot.tsxindex f13123a161..8e0884bb78 100644--- a/saleor/static/dashboard-next/AppRoot.tsx+++ b/saleor/static/dashboard-next/AppRoot.tsx@@ -23,7 +23,7 @@ import { appMountPoint } from ".";import * as saleorLogo from "../images/logo.svg";import { UserContext } from "./auth";import { User } from "./auth/types/User";-import { categoryListUrl } from "./categories";+import { categoryListUrl } from "./categories/urls";import { collectionListUrl } from "./collections/urls";import MenuToggle from "./components/MenuToggle";import Navigator from "./components/Navigator";diff --git a/saleor/static/dashboard-next/categories/index.tsx b/saleor/static/dashboard-next/categories/index.tsxindex b0c0b60513..f74cdc0db1 100644--- a/saleor/static/dashboard-next/categories/index.tsx+++ b/saleor/static/dashboard-next/categories/index.tsx@@ -3,6 +3,7 @@ import * as React from "react";import { Route, RouteComponentProps, Switch } from "react-router-dom";import { WindowTitle } from "../components/WindowTitle";import i18n from "../i18n";+import { categoryAddUrl, categoryListUrl, categoryUrl } from "./urls";import { CategoryCreateView } from "./views/CategoryCreate";import CategoryDetailsView, {CategoryDetailsQueryParams@@ -43,29 +44,16 @@ const CategoryCreate: React.StatelessComponent<);};-const Component = ({ match }) => (+const Component = () => (<><WindowTitle title={i18n.t("Categories")} /><Switch>- <Route exact path={match.url} component={CategoryList} />- <Route exact path={`${match.url}/add/`} component={CategoryCreate} />- <Route exact path={`${match.url}/:id/add/`} component={CategoryCreate} />- <Route path={`${match.url}/:id/`} component={CategoryDetails} />+ <Route exact path={categoryListUrl} component={CategoryList} />+ <Route exact path={categoryAddUrl()} component={CategoryCreate} />+ <Route exact path={categoryAddUrl(":id")} component={CategoryCreate} />+ <Route path={categoryUrl(":id")} component={CategoryDetails} /></Switch></>);-export const categoryListUrl = "/categories/";-export const categoryAddUrl = (parentId?: string) => {- if (parentId) {- return `/categories/${parentId}/add/`;- }- return `/categories/add/`;-};-export const categoryUrl = (id?: string) => {- if (id) {- return `/categories/${id}/`;- }- return "/categories/";-};export default Component;diff --git a/saleor/static/dashboard-next/categories/urls.ts b/saleor/static/dashboard-next/categories/urls.tsnew file mode 100644index 0000000000..80d0f5384c--- /dev/null+++ b/saleor/static/dashboard-next/categories/urls.ts@@ -0,0 +1,11 @@+import * as urlJoin from "url-join";++const categorySectionUrl = "/categories/";+export const categoryListUrl = categorySectionUrl;+export const categoryUrl = (id: string) => urlJoin(categorySectionUrl, id);+export const categoryAddUrl = (parentId?: string) => {+ if (parentId) {+ return urlJoin(categoryUrl(parentId), "add");+ }+ return urlJoin(categorySectionUrl, "add");+};diff --git a/saleor/static/dashboard-next/categories/views/CategoryCreate.tsx b/saleor/static/dashboard-next/categories/views/CategoryCreate.tsxindex 011018cdbd..df5bc5f828 100644--- a/saleor/static/dashboard-next/categories/views/CategoryCreate.tsx+++ b/saleor/static/dashboard-next/categories/views/CategoryCreate.tsx@@ -1,6 +1,5 @@import * as React from "react";-import { categoryUrl } from "../";import Messages from "../../components/messages";import Navigator from "../../components/Navigator";import { WindowTitle } from "../../components/WindowTitle";@@ -9,6 +8,7 @@ import { maybe } from "../../misc";import CategoryCreatePage from "../components/CategoryCreatePage";import { TypedCategoryCreateMutation } from "../mutations";import { CategoryCreate } from "../types/CategoryCreate";+import { categoryUrl } from "../urls";interface CategoryCreateViewProps {parentId: string;diff --git a/saleor/static/dashboard-next/categories/views/CategoryDetails/index.tsx b/saleor/static/dashboard-next/categories/views/CategoryDetails/index.tsxindex 48a35a7d19..aea04b292b 100644--- a/saleor/static/dashboard-next/categories/views/CategoryDetails/index.tsx+++ b/saleor/static/dashboard-next/categories/views/CategoryDetails/index.tsx@@ -2,7 +2,6 @@ import DialogContentText from "@material-ui/core/DialogContentText";import * as React from "react";import { Route } from "react-router-dom";-import { categoryAddUrl, categoryListUrl, categoryUrl } from "../..";import ActionDialog from "../../../components/ActionDialog";import Messages from "../../../components/messages";import Navigator from "../../../components/Navigator";@@ -22,6 +21,7 @@ import {import { TypedCategoryDetailsQuery } from "../../queries";import { CategoryDelete } from "../../types/CategoryDelete";import { CategoryUpdate } from "../../types/CategoryUpdate";+import { categoryAddUrl, categoryListUrl, categoryUrl } from "../../urls";import { categoryDeleteUrl } from "./urls";export type CategoryDetailsQueryParams = Partial<{diff --git a/saleor/static/dashboard-next/categories/views/CategoryDetails/urls.ts b/saleor/static/dashboard-next/categories/views/CategoryDetails/urls.tsindex f3ea8d8f09..e6afc274d5 100644--- a/saleor/static/dashboard-next/categories/views/CategoryDetails/urls.ts+++ b/saleor/static/dashboard-next/categories/views/CategoryDetails/urls.ts@@ -1,3 +1,5 @@-import { categoryUrl } from "../..";+import * as urlJoin from "url-join";+import { categoryUrl } from "../../urls";-export const categoryDeleteUrl = (id: string) => categoryUrl(id) + "delete";+export const categoryDeleteUrl = (id: string) =>+ urlJoin(categoryUrl(id), "delete");diff --git a/saleor/static/dashboard-next/categories/views/CategoryList.tsx b/saleor/static/dashboard-next/categories/views/CategoryList.tsxindex b5680ca7d6..43052de96c 100644--- a/saleor/static/dashboard-next/categories/views/CategoryList.tsx+++ b/saleor/static/dashboard-next/categories/views/CategoryList.tsx@@ -1,10 +1,10 @@import * as React from "react";-import { categoryAddUrl, categoryUrl } from "..";import Navigator from "../../components/Navigator";import { maybe } from "../../misc";import { CategoryListPage } from "../components/CategoryListPage/CategoryListPage";import { TypedRootCategoriesQuery } from "../queries";+import { categoryAddUrl, categoryUrl } from "../urls";export const CategoryList: React.StatelessComponent = () => (<Navigator>