From 7f3f6ef8b4b253b0941d649c246dccc85a5943ba Mon Sep 17 00:00:00 2001 From: typescreep Date: Mon, 16 Jun 2025 16:58:58 +0300 Subject: [PATCH] inside routing --- .../ManageableBreadcrumbs.tsx | 10 ++++-- src/pages/FormApiPage/FormApiPage.tsx | 2 +- src/pages/FormBuiltinPage/FormBuiltinPage.tsx | 2 +- src/pages/FormCrdPage/FormCrdPage.tsx | 2 +- .../ListInsideApiByApiGroupPage.tsx | 33 +++---------------- .../ListInsideApiPage/ListInsideApiPage.tsx | 21 ++---------- .../ListInsideCrdByApiGroupPage.tsx | 33 +++---------------- src/pages/TableApiPage/TableApiPage.tsx | 13 ++++++-- .../TableBuiltinPage/TableBuiltinPage.tsx | 10 ++++-- src/pages/TableCrdPage/TableCrdPage.tsx | 13 ++++++-- 10 files changed, 49 insertions(+), 90 deletions(-) diff --git a/src/components/molecules/ManageableBreadcrumbs/ManageableBreadcrumbs.tsx b/src/components/molecules/ManageableBreadcrumbs/ManageableBreadcrumbs.tsx index 17dcbd7..03fa6ec 100644 --- a/src/components/molecules/ManageableBreadcrumbs/ManageableBreadcrumbs.tsx +++ b/src/components/molecules/ManageableBreadcrumbs/ManageableBreadcrumbs.tsx @@ -3,7 +3,11 @@ import { useLocation, useParams } from 'react-router-dom' import { ManageableBreadcrumbsWithDataProvider } from '@prorobotech/openapi-k8s-toolkit' import { BASE_API_GROUP, BASE_API_VERSION } from 'constants/customizationApiGroupAndVersion' -export const ManageableBreadcrumbs: FC = () => { +type TManageableBreadCrumbsProps = { + inside?: boolean +} + +export const ManageableBreadcrumbs: FC = ({ inside }) => { const { pathname } = useLocation() const params = useParams() const clusterName = params?.clusterName || '' @@ -18,7 +22,9 @@ export const ManageableBreadcrumbs: FC = () => { return ( = ({ forcedTheme, inside }) => { return ( - + = ({ forcedTheme, inside return ( - + = ({ forcedTheme, inside }) => { return ( - + = ({ forcedTheme, inside }) => { - const { clusterName, namespace, apiGroup, apiVersion } = useParams() - const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) - - const breadcrumbItems = [ - { - title: In-Cloud: inside, - key: 'home', - }, - { - title: ( - API Resources - ), - key: 'list-api', - }, - { - title: 'Api Resources by Group', - key: 'api-resources-by-group', - }, - { - title: apiGroup, - key: 'api-group', - }, - ] + const { namespace, apiGroup, apiVersion } = useParams() return ( - + {apiGroup && apiVersion && ( diff --git a/src/pages/ListInsideApiPage/ListInsideApiPage.tsx b/src/pages/ListInsideApiPage/ListInsideApiPage.tsx index d02d5d5..fb12048 100644 --- a/src/pages/ListInsideApiPage/ListInsideApiPage.tsx +++ b/src/pages/ListInsideApiPage/ListInsideApiPage.tsx @@ -1,10 +1,7 @@ import React, { FC } from 'react' -import { Breadcrumb } from 'antd' import { Spacer } from '@prorobotech/openapi-k8s-toolkit' -import { useParams, Link } from 'react-router-dom' -import { useSelector } from 'react-redux' -import type { RootState } from 'store/store' -import { ListInsideAllResources } from 'components' +import { useParams } from 'react-router-dom' +import { ListInsideAllResources, ManageableBreadcrumbs } from 'components' import { BaseTemplate } from 'templates' type TListInsideApiPageProps = { @@ -14,22 +11,10 @@ type TListInsideApiPageProps = { export const ListInsideApiPage: FC = ({ forcedTheme, inside }) => { const { namespace } = useParams() - const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) - - const breadcrumbItems = [ - { - title: In-Cloud: inside, - key: 'home', - }, - { - title: 'API Resources', - key: 'list-api', - }, - ] return ( - + diff --git a/src/pages/ListInsideCrdByApiGroupPage/ListInsideCrdByApiGroupPage.tsx b/src/pages/ListInsideCrdByApiGroupPage/ListInsideCrdByApiGroupPage.tsx index dabf94b..5a2f9cb 100644 --- a/src/pages/ListInsideCrdByApiGroupPage/ListInsideCrdByApiGroupPage.tsx +++ b/src/pages/ListInsideCrdByApiGroupPage/ListInsideCrdByApiGroupPage.tsx @@ -1,10 +1,7 @@ import React, { FC } from 'react' -import { Breadcrumb } from 'antd' import { Spacer } from '@prorobotech/openapi-k8s-toolkit' -import { useParams, Link } from 'react-router-dom' -import { useSelector } from 'react-redux' -import type { RootState } from 'store/store' -import { ListInsideCrdsByApiGroup } from 'components' +import { useParams } from 'react-router-dom' +import { ListInsideCrdsByApiGroup, ManageableBreadcrumbs } from 'components' import { BaseTemplate } from 'templates' type TListInsideCrdByApiGroupPageProps = { @@ -13,33 +10,11 @@ type TListInsideCrdByApiGroupPageProps = { } export const ListInsideCrdByApiGroupPage: FC = ({ forcedTheme, inside }) => { - const { clusterName, namespace, apiGroup, apiVersion, apiExtensionVersion } = useParams() - const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) - - const breadcrumbItems = [ - { - title: In-Cloud: inside, - key: 'home', - }, - { - title: ( - API Resources - ), - key: 'list-api', - }, - { - title: 'CRD by Group', - key: 'crd-by-group', - }, - { - title: apiGroup, - key: 'api-group', - }, - ] + const { namespace, apiGroup, apiVersion, apiExtensionVersion } = useParams() return ( - + {apiGroup && apiVersion && apiExtensionVersion && ( = ({ forcedTheme, inside }) => `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_INSTANCES_API_GROUP}/${BASE_INSTANCES_VERSION}/${BASE_INSTANCES_RESOURCE_NAME}` : `${baseprefix}/clusters/${clusterName}/projects/${possibleProject}` - const clustererBacklink = `${baseprefix}/clusters` + const customBacklinkWithInside = inside + ? `${baseprefix}/inside/${clusterName}${namespace ? `/${namespace}` : ''}/apis` + : customBacklink + + const clustererBacklink = inside ? customBacklinkWithInside : `${baseprefix}/clusters` // const instancesBacklink = // apiGroup === 'apps' && apiVersion === 'v1' && typeName === 'deployments' @@ -41,8 +45,11 @@ export const TableApiPage: FC = ({ forcedTheme, inside }) => return ( - - + + diff --git a/src/pages/TableBuiltinPage/TableBuiltinPage.tsx b/src/pages/TableBuiltinPage/TableBuiltinPage.tsx index 86014a8..7459600 100644 --- a/src/pages/TableBuiltinPage/TableBuiltinPage.tsx +++ b/src/pages/TableBuiltinPage/TableBuiltinPage.tsx @@ -29,12 +29,16 @@ export const TableBuiltinPage: FC = ({ forcedTheme, insi ? `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_INSTANCES_API_GROUP}/${BASE_INSTANCES_VERSION}/${BASE_INSTANCES_RESOURCE_NAME}` : `${baseprefix}/clusters/${clusterName}/projects/${possibleProject}` - const clustererBacklink = `${baseprefix}/clusters` + const customBacklinkWithInside = inside + ? `${baseprefix}/inside/${clusterName}${namespace ? `/${namespace}` : ''}/apis` + : customBacklink + + const clustererBacklink = inside ? customBacklinkWithInside : `${baseprefix}/clusters` return ( - - + + diff --git a/src/pages/TableCrdPage/TableCrdPage.tsx b/src/pages/TableCrdPage/TableCrdPage.tsx index 6ad4ec2..d9d1b0f 100644 --- a/src/pages/TableCrdPage/TableCrdPage.tsx +++ b/src/pages/TableCrdPage/TableCrdPage.tsx @@ -28,12 +28,19 @@ export const TableCrdPage: FC = ({ forcedTheme, inside }) => ? `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_INSTANCES_API_GROUP}/${BASE_INSTANCES_VERSION}/${BASE_INSTANCES_RESOURCE_NAME}` : `${baseprefix}/clusters/${clusterName}/projects/${possibleProject}` - const clustererBacklink = `${baseprefix}/clusters` + const customBacklinkWithInside = inside + ? `${baseprefix}/inside/${clusterName}${namespace ? `/${namespace}` : ''}/apis` + : customBacklink + + const clustererBacklink = inside ? customBacklinkWithInside : `${baseprefix}/clusters` return ( - - + +