diff --git a/static/js/publisher/components/BrandStoreRoute/BrandStoreRoute.tsx b/static/js/publisher/components/BrandStoreRoute/BrandStoreRoute.tsx index b7d220a0ea..a8cb9c7391 100644 --- a/static/js/publisher/components/BrandStoreRoute/BrandStoreRoute.tsx +++ b/static/js/publisher/components/BrandStoreRoute/BrandStoreRoute.tsx @@ -1,4 +1,3 @@ -import { Spinner } from "@canonical/react-components"; import { useSetAtom } from "jotai"; import { useEffect } from "react"; import { Outlet, useLocation, useNavigate, useParams } from "react-router-dom"; @@ -7,6 +6,7 @@ import { useBrandStores } from "../../hooks"; import StoreNotFound from "../../pages/StoreNotFound"; import { brandStoresState } from "../../state/brandStoreState"; import { Store } from "../../types/shared"; +import Loader from "../Loader"; function BrandStoreRoute() { const location = useLocation(); @@ -47,7 +47,7 @@ function BrandStoreRoute() { ) ) : ( - + ); } diff --git a/static/js/publisher/hooks/usePolicies.ts b/static/js/publisher/hooks/usePolicies.ts index b86761fbae..1ada7e0c58 100644 --- a/static/js/publisher/hooks/usePolicies.ts +++ b/static/js/publisher/hooks/usePolicies.ts @@ -7,7 +7,7 @@ function usePolicies( modelId: string | undefined, ): UsePoliciesResponse { return useQuery({ - queryKey: ["policies", storeId], + queryKey: ["policies", storeId, modelId], queryFn: async () => { const response = await fetch( `/api/store/${storeId}/models/${modelId}/policies`, diff --git a/static/js/publisher/index.tsx b/static/js/publisher/index.tsx index 5ea247c971..0168085064 100644 --- a/static/js/publisher/index.tsx +++ b/static/js/publisher/index.tsx @@ -8,12 +8,10 @@ import { importComponent } from "./utils/importComponent"; import BrandStoreRoute from "./components/BrandStoreRoute/BrandStoreRoute"; import PublisherLayout from "./layouts/PublisherLayout"; import SnapsManagementLayout from "./layouts/SnapsManagementLayout"; +import ModelDetailsPageLayout from "./layouts/ModelDetailsPageLayout/ModelPageLayout"; import BrandStoreSettings from "./pages/BrandStoreSettings"; import Members from "./pages/Members"; -import Model from "./pages/Model"; -import Policies from "./pages/Model/Policies"; -import Models from "./pages/Models"; import SigningKeys from "./pages/SigningKeys"; import Snaps from "./pages/Snaps"; import ValidationSet from "./pages/ValidationSet"; @@ -38,6 +36,9 @@ const RegisterSnap = importComponent(() => import("./pages/RegisterSnap")); const RequestReservedName = importComponent( () => import("./pages/RequestReservedName"), ); +const Models = importComponent(() => import("./pages/Models")); +const Model = importComponent(() => import("./pages/Model")); +const Policies = importComponent(() => import("./pages/Model/Policies")); Sentry.init({ dsn: window.SENTRY_DSN, @@ -117,7 +118,7 @@ root.render( } /> } /> - + }> } /> } /> } /> diff --git a/static/js/publisher/pages/Model/ModelBreadcrumb.tsx b/static/js/publisher/layouts/ModelDetailsPageLayout/ModelBreadcrumb.tsx similarity index 100% rename from static/js/publisher/pages/Model/ModelBreadcrumb.tsx rename to static/js/publisher/layouts/ModelDetailsPageLayout/ModelBreadcrumb.tsx diff --git a/static/js/publisher/pages/Model/ModelNav.tsx b/static/js/publisher/layouts/ModelDetailsPageLayout/ModelNav.tsx similarity index 100% rename from static/js/publisher/pages/Model/ModelNav.tsx rename to static/js/publisher/layouts/ModelDetailsPageLayout/ModelNav.tsx diff --git a/static/js/publisher/layouts/ModelDetailsPageLayout/ModelPageLayout.tsx b/static/js/publisher/layouts/ModelDetailsPageLayout/ModelPageLayout.tsx new file mode 100644 index 0000000000..d3f58f536b --- /dev/null +++ b/static/js/publisher/layouts/ModelDetailsPageLayout/ModelPageLayout.tsx @@ -0,0 +1,18 @@ +import { Outlet, useLocation } from "react-router-dom"; +import ModelBreadcrumb from "./ModelBreadcrumb"; +import ModelNav from "./ModelNav"; + +function ModelDetailsPageLayout() { + const { pathname } = useLocation(); + const isPolicies = pathname.endsWith("policies"); + + return ( + <> + + + + + ); +} + +export default ModelDetailsPageLayout; diff --git a/static/js/publisher/pages/Model/__tests__/ModelNav.test.tsx b/static/js/publisher/layouts/ModelDetailsPageLayout/__tests__/ModelNav.test.tsx similarity index 100% rename from static/js/publisher/pages/Model/__tests__/ModelNav.test.tsx rename to static/js/publisher/layouts/ModelDetailsPageLayout/__tests__/ModelNav.test.tsx diff --git a/static/js/publisher/pages/Model/Model.tsx b/static/js/publisher/pages/Model/Model.tsx index c8ec35d663..de2d95fb2c 100644 --- a/static/js/publisher/pages/Model/Model.tsx +++ b/static/js/publisher/pages/Model/Model.tsx @@ -14,8 +14,6 @@ import { import { modelsListState, currentModelState } from "../../state/modelsState"; import { brandIdState, brandStoreState } from "../../state/brandStoreState"; -import ModelNav from "./ModelNav"; -import ModelBreadcrumb from "./ModelBreadcrumb"; import { useModels } from "../../hooks"; import { setPageTitle } from "../../utils"; import type { Model as ModelType } from "../../types/shared"; @@ -96,12 +94,6 @@ function Model() { return ( <> -
- -
-
- -