From 744a4e966185c7f4041cec5daa087554015a63a3 Mon Sep 17 00:00:00 2001 From: typescreep Date: Fri, 21 Nov 2025 10:49:59 +0300 Subject: [PATCH] sync naming --- src/App.tsx | 30 +++--- .../RedirectProjectInfo.tsx | 8 +- .../RedirectProjectList.tsx | 12 +-- .../molecules/BlackholeForm/BlackholeForm.tsx | 10 +- .../ManageableBreadcrumbs.tsx | 16 ++-- .../ManageableSidebar/ManageableSidebar.tsx | 10 +- .../TableApiBuiltin/TableApiBuiltin.tsx | 92 ++++--------------- .../molecules/TableCrdInfo/TableCrdInfo.tsx | 34 +++---- .../molecules/ResourceInfo/ResourceInfo.tsx | 29 ++---- src/components/organisms/Factory/Factory.tsx | 11 +-- .../Forms/ApisForms/CreateApisForm.tsx | 8 +- .../Forms/ApisForms/UpdateApisForm.tsx | 21 ++--- .../Forms/BuiltinForms/CreateBuiltinForm.tsx | 8 +- .../Forms/BuiltinForms/UpdateBuiltinForm.tsx | 19 ++-- .../Forms/CrdsForms/CreateCrdsForm.tsx | 8 +- .../Forms/CrdsForms/UpdateCrdsForm.tsx | 40 +++----- .../organisms/Header/organisms/User/User.tsx | 4 - .../organisms/HeaderSecond/HeaderSecond.tsx | 11 +-- .../organisms/Selector/Selector.tsx | 61 +++++------- .../SelectorCluster/SelectorCluster.tsx | 16 ++-- .../SelectorClusterInside.tsx | 17 ++-- .../SelectorInside/SelectorInside.tsx | 26 ++---- .../SelectorNamespace/SelectorNamespace.tsx | 51 ++++------ .../ListInsideAllResources.tsx | 6 +- .../ListInsideApisByApiGroup.tsx | 4 +- .../ListInsideClusterAndNs.tsx | 42 ++------- .../ListInsideCrdsByApiGroup.tsx | 4 +- src/components/organisms/Search/Search.tsx | 2 +- .../molecules/SearchEntry/SearchEntry.tsx | 6 +- src/components/organisms/Sidebar/styled.ts | 10 -- src/constants/blocksSizes.ts | 2 - .../customizationApiGroupAndVersion.ts | 48 +++++----- src/hooks/useIsSearchPage/useIsSearchPage.ts | 2 +- src/hooks/useNavSelector/useNavSelector.ts | 79 +++++----------- src/hooks/useNavSelectorInside.ts | 54 ++++------- src/pages/Forms/FormApiPage/FormApiPage.tsx | 26 +++--- .../Forms/FormBuiltinPage/FormBuiltinPage.tsx | 22 ++--- src/pages/Forms/FormCrdPage/FormCrdPage.tsx | 26 +++--- src/pages/Forms/index.ts | 1 - .../Tables/TableApiPage/TableApiPage.tsx | 24 ++--- .../TableBuiltinPage/TableBuiltinPage.tsx | 16 ++-- .../Tables/TableCrdPage/TableCrdPage.tsx | 4 +- src/pages/Tables/index.ts | 1 - src/store/theme/theme/theme.ts | 2 - src/templates/AppShell/AppShell.tsx | 1 - src/templates/BaseTemplate/BaseTemplate.tsx | 1 - src/templates/MainLayout/MainLayout.tsx | 14 +-- src/utils/getBacklink.ts | 26 +++--- 48 files changed, 350 insertions(+), 615 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 3911dcd..aff33c1 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -59,29 +59,29 @@ export const App: FC = ({ isFederation, forcedTheme }) => { } /> } /> - }> + }> {/* } /> */} - } /> - } /> - {/* } /> */} - } /> - } /> + } /> + } /> + {/* } /> */} + } /> + } /> } /> } /> - }> + }> {/* } /> */} - } /> - } /> - {/* } /> */} - } /> - } /> + } /> + } /> + {/* } /> */} + } /> + } /> } /> } /> - }> + }> } /> = ({ isFederation, forcedTheme }) => { } /> - } /> - } /> + } /> + } /> ) diff --git a/src/components/atoms/RedirectProjectInfo/RedirectProjectInfo.tsx b/src/components/atoms/RedirectProjectInfo/RedirectProjectInfo.tsx index 584263b..cde4448 100644 --- a/src/components/atoms/RedirectProjectInfo/RedirectProjectInfo.tsx +++ b/src/components/atoms/RedirectProjectInfo/RedirectProjectInfo.tsx @@ -4,15 +4,15 @@ import { useSelector } from 'react-redux' import { RootState } from 'store/store' export const RedirectProjectInfo: FC = () => { - const { clusterName, namespace } = useParams() + const { cluster, namespace } = useParams() const navigate = useNavigate() const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) - navigate(`${baseprefix}/${clusterName}/${namespace}/factory/project/${namespace}`) + navigate(`${baseprefix}/${cluster}/${namespace}/factory/project/${namespace}`) useEffect(() => { - navigate(`${baseprefix}/${clusterName}/${namespace}/factory/project/${namespace}`) - }, [clusterName, namespace, baseprefix, navigate]) + navigate(`${baseprefix}/${cluster}/${namespace}/factory/project/${namespace}`) + }, [cluster, namespace, baseprefix, navigate]) return null } diff --git a/src/components/atoms/RedirectProjectList/RedirectProjectList.tsx b/src/components/atoms/RedirectProjectList/RedirectProjectList.tsx index 40e8c38..cf08411 100644 --- a/src/components/atoms/RedirectProjectList/RedirectProjectList.tsx +++ b/src/components/atoms/RedirectProjectList/RedirectProjectList.tsx @@ -4,24 +4,24 @@ import { useSelector } from 'react-redux' import { RootState } from 'store/store' import { BASE_PROJECTS_API_GROUP, - BASE_PROJECTS_VERSION, - BASE_PROJECTS_RESOURCE_NAME, + BASE_PROJECTS_API_VERSION, + BASE_PROJECTS_PLURAL, } from 'constants/customizationApiGroupAndVersion' export const RedirectProjectList: FC = () => { - const { clusterName } = useParams() + const { cluster } = useParams() const navigate = useNavigate() const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) navigate( - `${baseprefix}/${clusterName}/api-table/${BASE_PROJECTS_API_GROUP}/${BASE_PROJECTS_VERSION}/${BASE_PROJECTS_RESOURCE_NAME}`, + `${baseprefix}/${cluster}/api-table/${BASE_PROJECTS_API_GROUP}/${BASE_PROJECTS_API_VERSION}/${BASE_PROJECTS_PLURAL}`, ) useEffect(() => { navigate( - `${baseprefix}/${clusterName}/api-table/${BASE_PROJECTS_API_GROUP}/${BASE_PROJECTS_VERSION}/${BASE_PROJECTS_RESOURCE_NAME}`, + `${baseprefix}/${cluster}/api-table/${BASE_PROJECTS_API_GROUP}/${BASE_PROJECTS_API_VERSION}/${BASE_PROJECTS_PLURAL}`, ) - }, [clusterName, baseprefix, navigate]) + }, [cluster, baseprefix, navigate]) return null } diff --git a/src/components/molecules/BlackholeForm/BlackholeForm.tsx b/src/components/molecules/BlackholeForm/BlackholeForm.tsx index 28ff258..1f58752 100644 --- a/src/components/molecules/BlackholeForm/BlackholeForm.tsx +++ b/src/components/molecules/BlackholeForm/BlackholeForm.tsx @@ -17,7 +17,7 @@ type TBlackholeFormProps = { data: | { type: 'builtin' - typeName: string + plural: string prefillValuesSchema?: TJSON prefillValueNamespaceOnly?: string } @@ -25,7 +25,7 @@ type TBlackholeFormProps = { type: 'apis' apiGroup: string apiVersion: string - typeName: string + plural: string prefillValuesSchema?: TJSON prefillValueNamespaceOnly?: string } @@ -71,15 +71,15 @@ export const BlackholeForm: FC = ({ data, customizationId, }, []) const urlParams = { - clusterName: params.clusterName, + cluster: params.cluster, namespace: params.namespace, syntheticProject: params.syntheticProject, - entryName: params.entryName, + name: params.name, } const urlParamsForPermissions = { apiGroup: params.apiGroup, - typeName: params.typeName, + plural: params.plural, } return ( diff --git a/src/components/molecules/ManageableBreadcrumbs/ManageableBreadcrumbs.tsx b/src/components/molecules/ManageableBreadcrumbs/ManageableBreadcrumbs.tsx index b9c4102..02efdc1 100644 --- a/src/components/molecules/ManageableBreadcrumbs/ManageableBreadcrumbs.tsx +++ b/src/components/molecules/ManageableBreadcrumbs/ManageableBreadcrumbs.tsx @@ -12,13 +12,13 @@ export const ManageableBreadcrumbs: FC = ({ idToCom const location = useLocation() const { pathname } = useLocation() const params = useParams() - const clusterName = params?.clusterName || '' + const cluster = params?.cluster || '' const namespace = params?.namespace || '' const syntheticProject = params?.syntheticProject || '' const apiGroup = params?.apiGroup || '' const apiVersion = params?.apiVersion || '' - const typeName = params?.typeName || '' - const entryName = params?.entryName || '' + const plural = params?.plural || '' + const name = params?.name || '' const apiExtensionVersion = params?.apiExtensionVersion || '' const crdName = params?.crdName || '' @@ -32,13 +32,13 @@ export const ManageableBreadcrumbs: FC = ({ idToCom return ( = ({ idToCom entryType: '', apiGroup, apiVersion, - typeName, - entryName, + plural, + name, apiExtensionVersion, crdName, ...replaceValuesPartsOfUrls, diff --git a/src/components/molecules/ManageableSidebar/ManageableSidebar.tsx b/src/components/molecules/ManageableSidebar/ManageableSidebar.tsx index e3d478c..f5e3246 100644 --- a/src/components/molecules/ManageableSidebar/ManageableSidebar.tsx +++ b/src/components/molecules/ManageableSidebar/ManageableSidebar.tsx @@ -4,7 +4,6 @@ import { useLocation, useParams } from 'react-router-dom' import { ManageableSidebarProvider } from '@prorobotech/openapi-k8s-toolkit' import { useSelector } from 'react-redux' import type { RootState } from 'store/store' -// import { HEAD_FIRST_ROW, SIDEBAR_CLUSTER_HEIGHT } from 'constants/blocksSizes' import { HEAD_FIRST_ROW } from 'constants/blocksSizes' import { BASE_API_GROUP, @@ -29,7 +28,7 @@ export const ManageableSidebar: FC = ({ const location = useLocation() const { pathname } = useLocation() const params = useParams() - const clusterName = params?.clusterName || '' + const cluster = params?.cluster || '' const namespace = params?.namespace || '' const syntheticProject = params?.syntheticProject || '' const theme = useSelector((state: RootState) => state.openapiTheme.theme) @@ -38,7 +37,6 @@ export const ManageableSidebar: FC = ({ const [height, setHeight] = useState(0) useEffect(() => { - // const height = window.innerHeight - HEAD_FIRST_ROW - SIDEBAR_CLUSTER_HEIGHT - 2 const height = window.innerHeight - HEAD_FIRST_ROW - 2 setHeight(height) @@ -71,13 +69,13 @@ export const ManageableSidebar: FC = ({ $maxHeight={height} > = ({ resourceType, apiGroup, apiVersion, - typeName, + plural, labels, fields, limit, @@ -72,8 +69,6 @@ export const TableApiBuiltin: FC = ({ ) const [selectedRowKeys, setSelectedRowKeys] = useState([]) const [selectedRowsData, setSelectedRowsData] = useState<{ name: string; endpoint: string }[]>([]) - // const [isNamespaced, setIsNamespaced] = useState() - // const [isNamespacedLoading, setIsNamespacedLoading] = useState() const [height, setHeight] = useState(0) @@ -99,45 +94,11 @@ export const TableApiBuiltin: FC = ({ } }, []) - // useEffect(() => { - // setIsNamespacedLoading(true) - // if (resourceType === 'builtin') { - // checkIfBuiltInInstanceNamespaceScoped({ - // typeName, - // clusterName: cluster, - // }) - // .then(({ isNamespaceScoped }) => { - // if (isNamespaceScoped) { - // setIsNamespaced(isNamespaceScoped) - // } else { - // setIsNamespaced(false) - // } - // }) - // .finally(() => setIsNamespacedLoading(false)) - // } - // if (resourceType === 'api' && apiGroup && apiVersion) { - // checkIfApiInstanceNamespaceScoped({ - // apiGroup, - // apiVersion, - // typeName, - // clusterName: cluster, - // }) - // .then(({ isNamespaceScoped }) => { - // if (isNamespaceScoped) { - // setIsNamespaced(true) - // } else { - // setIsNamespaced(false) - // } - // }) - // .finally(() => setIsNamespacedLoading(false)) - // } - // }, [resourceType, cluster, typeName, apiGroup, apiVersion]) - const createPermission = usePermissions({ - group: apiGroup || undefined, - resource: typeName, + apiGroup: apiGroup || undefined, + plural, namespace: params.namespace, - clusterName: cluster, + cluster, verb: 'create', refetchInterval: false, }) @@ -149,9 +110,9 @@ export const TableApiBuiltin: FC = ({ } = useK8sSmartResource<{ items: TSingleResource[] }>({ cluster, namespace, - group: apiGroup || undefined, - version: apiVersion || '', - plural: typeName, + apiGroup, + apiVersion: apiVersion || '', + plural, labelSelector: labels ? encodeURIComponent(labels.join(',')) : undefined, fieldSelector: fields ? encodeURIComponent(fields.join(',')) : undefined, limit, @@ -182,14 +143,14 @@ export const TableApiBuiltin: FC = ({ {!error && dataItems && ( = ({ entryType: params.entryType, apiGroup: params.apiGroup, apiVersion: params.apiVersion, - typeName: params.typeName, - entryName: params.entryName, + plural: params.plural, + name: params.name, apiExtensionVersion: params.apiExtensionVersion, crdName: params.crdName, ...replaceValuesPartsOfUrls, @@ -209,16 +170,14 @@ export const TableApiBuiltin: FC = ({ baseprefix={inside ? `${baseprefix}/inside` : baseprefix} dataItems={dataItems.items} k8sResource={{ - resource: typeName, + plural, apiGroup, apiVersion, }} - // isNamespaced={isNamespaced} - // isNamespacedLoading={isNamespacedLoading} dataForControls={{ cluster, syntheticProject: params.syntheticProject, - resource: typeName, + plural, apiGroup, apiVersion, }} @@ -233,23 +192,8 @@ export const TableApiBuiltin: FC = ({ }, }} tableProps={{ ...TABLE_PROPS, disablePagination: !searchMount }} - // maxHeight={height - 65} /> )} - {/* {selectedRowKeys.length > 0 && ( - - - - - - - )} */} {searchMount ? : } @@ -264,15 +208,13 @@ export const TableApiBuiltin: FC = ({ syntheticProject: params.syntheticProject, apiGroup, apiVersion, - typeName, + plural, inside, fullPath, searchMount, }) navigate(url) }} - // loading={isNamespaced ? false : createPermission.isPending} - // disabled={isNamespaced ? false : !createPermission.data?.status.allowed} loading={createPermission.isPending} disabled={!createPermission.data?.status.allowed} > diff --git a/src/components/molecules/TableCrdInfo/TableCrdInfo.tsx b/src/components/molecules/TableCrdInfo/TableCrdInfo.tsx index 72cc1bc..2bb728d 100644 --- a/src/components/molecules/TableCrdInfo/TableCrdInfo.tsx +++ b/src/components/molecules/TableCrdInfo/TableCrdInfo.tsx @@ -34,12 +34,6 @@ export const TableCrdInfo: FC = ({ const [isNamespaced, setIsNamespaced] = useState() - // const { isPending, error, data } = useCrdData({ - // clusterName: cluster, - // crdName, - // apiExtensionVersion, - // }) - const { data: dataArr, isLoading: isPending, @@ -48,8 +42,8 @@ export const TableCrdInfo: FC = ({ items: TCRD[] }>({ cluster, - group: 'apiextensions.k8s.io', - version: apiExtensionVersion, + apiGroup: 'apiextensions.k8s.io', + apiVersion: apiExtensionVersion, plural: 'customresourcedefinitions', fieldSelector: `metadata.name=${crdName}`, }) @@ -61,8 +55,8 @@ export const TableCrdInfo: FC = ({ checkIfApiInstanceNamespaceScoped({ apiGroup, apiVersion, - typeName: data.spec.names.plural, - clusterName: cluster, + plural: data.spec.names.plural, + cluster, }).then(({ isNamespaceScoped }) => { if (isNamespaceScoped) { setIsNamespaced(true) @@ -72,28 +66,28 @@ export const TableCrdInfo: FC = ({ }, [cluster, data, isPending, error, apiGroup, apiVersion]) const createPermission = usePermissions({ - group: apiGroup, - resource: data ? data.spec.names.singular : '', + apiGroup, + plural: data ? data.spec.names.singular : '', namespace: '', - clusterName: cluster, + cluster, verb: 'create', refetchInterval: false, }) const updatePermission = usePermissions({ - group: apiGroup, - resource: data ? data.spec.names.singular : '', + apiGroup, + plural: data ? data.spec.names.singular : '', namespace: '', - clusterName: cluster, + cluster, verb: 'update', refetchInterval: false, }) const deletePermission = usePermissions({ - group: apiGroup, - resource: data ? data.spec.names.singular : '', + apiGroup, + plural: data ? data.spec.names.singular : '', namespace: '', - clusterName: cluster, + cluster, verb: 'delete', refetchInterval: false, }) @@ -106,7 +100,7 @@ export const TableCrdInfo: FC = ({ )} {!error && data && data.spec && ( = ({ - clusterName, + cluster, namespace, crdName, crdPluralName, @@ -59,7 +59,6 @@ export const ResourceInfo: FC = ({ const location = useLocation() const navigate = useNavigate() const params = useParams() - const cluster = useSelector((state: RootState) => state.cluster.cluster) const theme = useSelector((state: RootState) => state.openapiTheme.theme) const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) @@ -94,14 +93,6 @@ export const ResourceInfo: FC = ({ } }, []) - // const { isPending, error, data } = useCrdResources({ - // clusterName, - // namespace, - // apiGroup, - // apiVersion, - // crdName: crdPluralName, - // }) - const { data, isLoading: isPending, @@ -109,9 +100,9 @@ export const ResourceInfo: FC = ({ } = useK8sSmartResource<{ items: TJSON[] }>({ - cluster: clusterName, - group: apiGroup, - version: apiVersion, + cluster, + apiGroup, + apiVersion, plural: crdPluralName, }) @@ -158,7 +149,7 @@ export const ResourceInfo: FC = ({ // key={`/${apiGroup}/${apiVersion}/${crdPluralName}`} // customizationId={`${customizationIdPrefix}/${apiGroup}/${apiVersion}/${crdPluralName}`} // tableMappingsReplaceValues={{ - // clusterName: params.clusterName, + // cluster: params.cluster, // projectName: params.projectName, // instanceName: params.instanceName, // namespace: params.namespace, @@ -166,8 +157,8 @@ export const ResourceInfo: FC = ({ // entryType: params.entryType, // apiGroup: params.apiGroup, // apiVersion: params.apiVersion, - // typeName: params.typeName, - // entryName: params.entryName, + // plural: params.plural, + // name: params.name, // apiExtensionVersion: params.apiExtensionVersion, // crdName: params.crdName, // ...replaceValuesPartsOfUrls, @@ -182,12 +173,12 @@ export const ResourceInfo: FC = ({ // cluster, // syntheticProject: params.syntheticProject, // pathPrefix: 'forms/crds', - // typeName: crdPluralName, + // plural: crdPluralName, // apiVersion: `${apiGroup}/${apiVersion}`, // backlink: `${baseprefix}${inside ? '/inside' : ''}/${cluster}${namespace ? `/${namespace}` : ''}${ // params.syntheticProject ? `/${params.syntheticProject}` : '' // }/crd-table/${apiGroup}/${apiVersion}/${apiExtensionVersion}/${crdName}`, - // deletePathPrefix: `/api/clusters/${clusterName}/k8s/apis`, + // deletePathPrefix: `/api/clusters/${cluster}/k8s/apis`, // onDeleteHandle, // permissions: { // canUpdate: permissions.canUpdate, diff --git a/src/components/organisms/Factory/Factory.tsx b/src/components/organisms/Factory/Factory.tsx index 6ed21ae..972c0d0 100644 --- a/src/components/organisms/Factory/Factory.tsx +++ b/src/components/organisms/Factory/Factory.tsx @@ -4,7 +4,6 @@ import { DynamicComponents, DynamicRendererWithProviders, TDynamicComponentsAppTypeMap, - // useDirectUnknownResource, useK8sSmartResource, TFactoryResponse, ContentCard, @@ -45,16 +44,10 @@ export const Factory: FC = ({ setSidebarTags }) => { } }, []) - // const { data: factoryData } = useDirectUnknownResource>({ - // uri: `/api/clusters/${cluster}/k8s/apis/${BASE_API_GROUP}/${BASE_API_VERSION}/factories/`, - // refetchInterval: false, - // queryKey: ['factories', cluster || 'no-cluster'], - // isEnabled: cluster !== undefined, - // }) const { data: factoryData } = useK8sSmartResource>({ cluster, - group: BASE_API_GROUP, - version: BASE_API_VERSION, + apiGroup: BASE_API_GROUP, + apiVersion: BASE_API_VERSION, plural: 'factories', }) diff --git a/src/components/organisms/Forms/ApisForms/CreateApisForm.tsx b/src/components/organisms/Forms/ApisForms/CreateApisForm.tsx index 1d9408f..c337e57 100644 --- a/src/components/organisms/Forms/ApisForms/CreateApisForm.tsx +++ b/src/components/organisms/Forms/ApisForms/CreateApisForm.tsx @@ -7,11 +7,11 @@ type TCreateApisFormProps = { namespace?: string apiGroup: string apiVersion: string - typeName: string + plural: string backLink?: string | null } -export const CreateApisForm: FC = ({ namespace, apiGroup, apiVersion, typeName, backLink }) => { +export const CreateApisForm: FC = ({ namespace, apiGroup, apiVersion, plural, backLink }) => { const [currentMode, setCurrentMode] = useState('OpenAPI') const [currentModeDisabled, setCurrentModeDisabled] = useState(false) @@ -45,10 +45,10 @@ export const CreateApisForm: FC = ({ namespace, apiGroup, type: 'apis', apiGroup, apiVersion, - typeName, + plural, prefillValueNamespaceOnly: namespace, }} - customizationId={`default-/${apiGroup}/${apiVersion}/${typeName}`} + customizationId={`default-/${apiGroup}/${apiVersion}/${plural}`} isCreate backlink={backLink} modeData={modeData} diff --git a/src/components/organisms/Forms/ApisForms/UpdateApisForm.tsx b/src/components/organisms/Forms/ApisForms/UpdateApisForm.tsx index f831b7c..05e0b1f 100644 --- a/src/components/organisms/Forms/ApisForms/UpdateApisForm.tsx +++ b/src/components/organisms/Forms/ApisForms/UpdateApisForm.tsx @@ -8,8 +8,8 @@ import { BlackholeForm } from 'components' type TUpdateApisFormProps = { apiGroup: string apiVersion: string - typeName: string - entryName: string + plural: string + name: string namespace?: string backLink?: string | null } @@ -17,8 +17,8 @@ type TUpdateApisFormProps = { export const UpdateApisForm: FC = ({ apiGroup, apiVersion, - typeName, - entryName, + plural, + name, namespace, backLink, }) => { @@ -42,12 +42,12 @@ export const UpdateApisForm: FC = ({ } const { data, isPending, error } = useApiResourceSingle({ - clusterName: cluster, + cluster, namespace, apiGroup, apiVersion, - typeName, - entryName, + plural, + name, refetchInterval: false, }) @@ -59,8 +59,6 @@ export const UpdateApisForm: FC = ({ return } - /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ - // const { status: _, ...noStatusData } = data /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ const { managedFields: __, ...metadata } = data.metadata @@ -80,11 +78,10 @@ export const UpdateApisForm: FC = ({ type: 'apis', apiGroup, apiVersion, - typeName, - // prefillValuesSchema: { ...noStatusData, metadata }, + plural, prefillValuesSchema: { ...data, metadata }, }} - customizationId={`default-/${apiGroup}/${apiVersion}/${typeName}`} + customizationId={`default-/${apiGroup}/${apiVersion}/${plural}`} backlink={backLink} modeData={modeData} /> diff --git a/src/components/organisms/Forms/BuiltinForms/CreateBuiltinForm.tsx b/src/components/organisms/Forms/BuiltinForms/CreateBuiltinForm.tsx index 1faadd8..74ba5b6 100644 --- a/src/components/organisms/Forms/BuiltinForms/CreateBuiltinForm.tsx +++ b/src/components/organisms/Forms/BuiltinForms/CreateBuiltinForm.tsx @@ -5,11 +5,11 @@ import { BlackholeForm } from 'components' type TCreateBuiltinFormProps = { namespace?: string - typeName: string + plural: string backLink?: string | null } -export const CreateBuiltinForm: FC = ({ namespace, typeName, backLink }) => { +export const CreateBuiltinForm: FC = ({ namespace, plural, backLink }) => { const [currentMode, setCurrentMode] = useState('OpenAPI') const [currentModeDisabled, setCurrentModeDisabled] = useState(false) @@ -41,10 +41,10 @@ export const CreateBuiltinForm: FC = ({ namespace, type = ({ typeName, entryName, namespace, backLink }) => { +export const UpdateBuiltinForm: FC = ({ plural, name, namespace, backLink }) => { const cluster = useSelector((state: RootState) => state.cluster.cluster) const [currentMode, setCurrentMode] = useState('OpenAPI') @@ -33,10 +33,10 @@ export const UpdateBuiltinForm: FC = ({ typeName, entry } const { data, isPending, error } = useBuiltinResourceSingle({ - clusterName: cluster, + cluster, namespace, - typeName, - entryName, + plural, + name, refetchInterval: false, }) @@ -48,8 +48,6 @@ export const UpdateBuiltinForm: FC = ({ typeName, entry return } - /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ - // const { status: _, ...noStatusData } = data /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ const { managedFields: __, ...metadata } = data.metadata @@ -67,11 +65,10 @@ export const UpdateBuiltinForm: FC = ({ typeName, entry diff --git a/src/components/organisms/Forms/CrdsForms/CreateCrdsForm.tsx b/src/components/organisms/Forms/CrdsForms/CreateCrdsForm.tsx index 237b0f6..79dd95a 100644 --- a/src/components/organisms/Forms/CrdsForms/CreateCrdsForm.tsx +++ b/src/components/organisms/Forms/CrdsForms/CreateCrdsForm.tsx @@ -7,11 +7,11 @@ type TCreateCrdsFormProps = { namespace?: string apiGroup: string apiVersion: string - typeName: string + plural: string backLink?: string | null } -export const CreateCrdsForm: FC = ({ namespace, apiGroup, apiVersion, typeName, backLink }) => { +export const CreateCrdsForm: FC = ({ namespace, apiGroup, apiVersion, plural, backLink }) => { const [currentMode, setCurrentMode] = useState('OpenAPI') const [currentModeDisabled, setCurrentModeDisabled] = useState(false) @@ -45,10 +45,10 @@ export const CreateCrdsForm: FC = ({ namespace, apiGroup, type: 'apis', apiGroup, apiVersion, - typeName, + plural, prefillValueNamespaceOnly: namespace, }} - customizationId={`default-/${apiGroup}/${apiVersion}/${typeName}`} + customizationId={`default-/${apiGroup}/${apiVersion}/${plural}`} isCreate backlink={backLink} modeData={modeData} diff --git a/src/components/organisms/Forms/CrdsForms/UpdateCrdsForm.tsx b/src/components/organisms/Forms/CrdsForms/UpdateCrdsForm.tsx index 7f4cb5d..ce37e22 100644 --- a/src/components/organisms/Forms/CrdsForms/UpdateCrdsForm.tsx +++ b/src/components/organisms/Forms/CrdsForms/UpdateCrdsForm.tsx @@ -1,11 +1,6 @@ import React, { FC, useState } from 'react' import { Spin, Alert, Segmented } from 'antd' -import { - // useCrdResourceSingle, - useK8sSmartResource, - TSingleResource, - Spacer, -} from '@prorobotech/openapi-k8s-toolkit' +import { useK8sSmartResource, TSingleResource, Spacer } from '@prorobotech/openapi-k8s-toolkit' import { useSelector } from 'react-redux' import { RootState } from 'store/store' import { BlackholeForm } from 'components' @@ -13,8 +8,8 @@ import { BlackholeForm } from 'components' type TUpdateCrdsFormProps = { apiGroup: string apiVersion: string - typeName: string - entryName: string + plural: string + name: string namespace?: string backLink?: string | null } @@ -22,8 +17,8 @@ type TUpdateCrdsFormProps = { export const UpdateCrdsForm: FC = ({ apiGroup, apiVersion, - typeName, - entryName, + plural, + name, namespace, backLink, }) => { @@ -46,16 +41,6 @@ export const UpdateCrdsForm: FC = ({ onDisabled: onCurrentModeDisabled, } - // const { data, isPending, error } = useCrdResourceSingle({ - // clusterName: cluster, - // namespace, - // apiGroup, - // apiVersion, - // crdName: typeName, - // entryName, - // refetchInterval: false, - // }) - const { data: dataArr, isLoading: isPending, @@ -65,10 +50,10 @@ export const UpdateCrdsForm: FC = ({ }>({ cluster, namespace, - group: apiGroup, - version: apiVersion, - plural: typeName, - fieldSelector: `metadata.name=${entryName}`, + apiGroup, + apiVersion, + plural, + fieldSelector: `metadata.name=${name}`, }) const data = dataArr?.items && dataArr.items.length > 0 ? dataArr.items[0] : undefined @@ -87,8 +72,6 @@ export const UpdateCrdsForm: FC = ({ return } - /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ - // const { status: _, ...noStatusData } = data /* eslint-disable-next-line @typescript-eslint/no-unused-vars */ const { managedFields: __, ...metadata } = data.metadata @@ -108,11 +91,10 @@ export const UpdateCrdsForm: FC = ({ type: 'apis', apiGroup, apiVersion, - typeName, - // prefillValuesSchema: { ...noStatusData, metadata }, + plural, prefillValuesSchema: { ...data, metadata }, }} - customizationId={`default-/${apiGroup}/${apiVersion}/${typeName}`} + customizationId={`default-/${apiGroup}/${apiVersion}/${plural}`} backlink={backLink} modeData={modeData} /> diff --git a/src/components/organisms/Header/organisms/User/User.tsx b/src/components/organisms/Header/organisms/User/User.tsx index 69f89ce..71fff86 100644 --- a/src/components/organisms/Header/organisms/User/User.tsx +++ b/src/components/organisms/Header/organisms/User/User.tsx @@ -20,10 +20,6 @@ export const User: FC = () => { placement="top" menu={{ items: [ - // { - // key: '1', - // label: , - // }, ...(BASE_HIDE_INSIDE === 'true' ? [] : [ diff --git a/src/components/organisms/HeaderSecond/HeaderSecond.tsx b/src/components/organisms/HeaderSecond/HeaderSecond.tsx index 10b588f..1faa445 100644 --- a/src/components/organisms/HeaderSecond/HeaderSecond.tsx +++ b/src/components/organisms/HeaderSecond/HeaderSecond.tsx @@ -12,8 +12,7 @@ type THeaderProps = { } export const HeaderSecond: FC = ({ inside, isSearch }) => { - // const { projectName, instanceName, clusterName, entryType, namespace, syntheticProject } = useParams() - const { projectName, instanceName, clusterName, namespace, syntheticProject } = useParams() + const { projectName, instanceName, cluster, namespace, syntheticProject } = useParams() const { token } = theme.useToken() const possibleProject = syntheticProject && namespace ? syntheticProject : namespace @@ -23,17 +22,17 @@ export const HeaderSecond: FC = ({ inside, isSearch }) => { - {inside ? : } - {inside && } + {inside ? : } + {inside && } {!inside && !isSearch && BASE_USE_NAMESPACE_NAV !== 'true' && ( )} {!inside && (isSearch || BASE_USE_NAMESPACE_NAV === 'true') && ( - + )} diff --git a/src/components/organisms/HeaderSecond/organisms/Selector/Selector.tsx b/src/components/organisms/HeaderSecond/organisms/Selector/Selector.tsx index 782f2d2..f1913e8 100644 --- a/src/components/organisms/HeaderSecond/organisms/Selector/Selector.tsx +++ b/src/components/organisms/HeaderSecond/organisms/Selector/Selector.tsx @@ -1,79 +1,60 @@ import React, { FC, useState } from 'react' import { Flex, Typography } from 'antd' import { useNavigate } from 'react-router-dom' -import { - // useDirectUnknownResource, - useK8sSmartResource, - TNavigationResource, -} from '@prorobotech/openapi-k8s-toolkit' +import { useK8sSmartResource, TNavigationResource } from '@prorobotech/openapi-k8s-toolkit' import { useNavSelector } from 'hooks/useNavSelector' import { useMountEffect } from 'hooks/useMountEffect' import { EntrySelect } from 'components/atoms' import { BASE_API_GROUP, BASE_API_VERSION, + BASE_CUSTOMIZATION_NAVIGATION_RESOURCE_PLURAL, BASE_CUSTOMIZATION_NAVIGATION_RESOURCE_NAME, - BASE_CUSTOMIZATION_NAVIGATION_RESOURCE, } from 'constants/customizationApiGroupAndVersion' type TSelectorProps = { - clusterName?: string + cluster?: string projectName?: string instanceName?: string } -export const Selector: FC = ({ clusterName, projectName, instanceName }) => { +export const Selector: FC = ({ cluster, projectName, instanceName }) => { const navigate = useNavigate() - const [selectedClusterName, setSelectedClusterName] = useState(clusterName) + const [selectedCluster, setSelectedCluster] = useState(cluster) const [selectedProjectName, setSelectedProjectName] = useState(projectName) const [selectedInstanceName, setSelectedInstanceName] = useState(instanceName) - // const { projectsInSidebar, instancesInSidebar, allInstancesLoadingSuccess, clustersInSidebar } = useNavSelector( const { projectsInSidebar, instancesInSidebar, allInstancesLoadingSuccess } = useNavSelector( - selectedClusterName, + selectedCluster, projectName, ) - // const { data: navigationData } = useDirectUnknownResource<{ - // spec: { projects: { clear: string; change: string }; instances: { clear: string; change: string } } - // }>({ - // uri: `/api/clusters/${clusterName}/k8s/apis/${BASE_API_GROUP}/${BASE_API_VERSION}/${BASE_CUSTOMIZATION_NAVIGATION_RESOURCE_NAME}/${BASE_CUSTOMIZATION_NAVIGATION_RESOURCE}`, - // refetchInterval: false, - // queryKey: ['navigation', clusterName || 'no-cluster'], - // isEnabled: clusterName !== undefined, - // }) - const { data: navigationDataArr } = useK8sSmartResource<{ items: TNavigationResource[] }>({ - cluster: clusterName || '', - group: BASE_API_GROUP, - version: BASE_API_VERSION, - plural: BASE_CUSTOMIZATION_NAVIGATION_RESOURCE_NAME, - fieldSelector: `metadata.name=${BASE_CUSTOMIZATION_NAVIGATION_RESOURCE}`, - isEnabled: clusterName !== undefined, + cluster: cluster || '', + apiGroup: BASE_API_GROUP, + apiVersion: BASE_API_VERSION, + plural: BASE_CUSTOMIZATION_NAVIGATION_RESOURCE_PLURAL, + fieldSelector: `metadata.name=${BASE_CUSTOMIZATION_NAVIGATION_RESOURCE_NAME}`, + isEnabled: cluster !== undefined, }) const navigationData = navigationDataArr?.items && navigationDataArr.items.length > 0 ? navigationDataArr.items[0] : undefined - // const handleClusterChange = (value: string) => { - // setSelectedClusterName(value) - // navigate(`${baseprefix}/clusters/${value}`) - // } - const handleProjectChange = (value?: string) => { if (value && value !== 'all') { setSelectedProjectName(value) const changeUrl = navigationData?.spec?.projects?.change - .replace('{selectedCluster}', selectedClusterName || 'no-cluster') + .replace('{selectedCluster}', selectedCluster || 'no-cluster') .replace('{value}', value) || 'no navigation data' navigate(changeUrl) } else { const clearUrl = - navigationData?.spec?.projects?.clear.replace('{selectedCluster}', selectedClusterName || 'no-cluster') || + navigationData?.spec?.projects?.clear.replace('{selectedCluster}', selectedCluster || 'no-cluster') || 'no navigation data' navigate(clearUrl) } @@ -84,31 +65,31 @@ export const Selector: FC = ({ clusterName, projectName, instanc setSelectedInstanceName(value) const changeUrl = navigationData?.spec?.instances?.change - .replace('{selectedCluster}', selectedClusterName || 'no-cluster') + .replace('{selectedCluster}', selectedCluster || 'no-cluster') .replace('{selectedProject}', selectedProjectName || 'no-project') .replace('{value}', value) || 'no navigation data' navigate(changeUrl) } else { const clearUrl = navigationData?.spec?.instances?.clear - .replace('{selectedCluster}', selectedClusterName || 'no-cluster') + .replace('{selectedCluster}', selectedCluster || 'no-cluster') .replace('{selectedProject}', selectedProjectName || 'no-project') || 'no navigation data' navigate(clearUrl) } } useMountEffect(() => { - setSelectedClusterName(clusterName) + setSelectedCluster(cluster) setSelectedProjectName(projectName) setSelectedInstanceName(instanceName) - }, [projectName, instanceName, clusterName]) + }, [projectName, instanceName, cluster]) return ( {/* */} Project: @@ -117,7 +98,7 @@ export const Selector: FC = ({ clusterName, projectName, instanc options={[{ value: 'all', label: 'All Namespaces' }, ...projectsInSidebar]} value={selectedProjectName || 'all'} onChange={handleProjectChange} - disabled={selectedClusterName === undefined || projectsInSidebar.length === 0} + disabled={selectedCluster === undefined || projectsInSidebar.length === 0} /> Instance: = ({ clusterName, projectName, instanc value={selectedInstanceName || 'all'} onChange={handleInstanceChange} disabled={ - selectedClusterName === undefined || + selectedCluster === undefined || selectedProjectName === undefined || (allInstancesLoadingSuccess && instancesInSidebar.length === 0) } diff --git a/src/components/organisms/HeaderSecond/organisms/SelectorCluster/SelectorCluster.tsx b/src/components/organisms/HeaderSecond/organisms/SelectorCluster/SelectorCluster.tsx index 00c75d7..f647f32 100644 --- a/src/components/organisms/HeaderSecond/organisms/SelectorCluster/SelectorCluster.tsx +++ b/src/components/organisms/HeaderSecond/organisms/SelectorCluster/SelectorCluster.tsx @@ -9,21 +9,20 @@ import { EntrySelect } from 'components/atoms' import { BASE_NAVIGATE_FROM_CLUSTERLIST } from 'constants/customizationApiGroupAndVersion' type TSelectorClusterProps = { - clusterName?: string + cluster?: string } -export const SelectorCluster: FC = ({ clusterName }) => { +export const SelectorCluster: FC = ({ cluster }) => { const navigate = useNavigate() const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) - const [selectedClusterName, setSelectedClusterName] = useState(clusterName) + const [selectedCluster, setSelectedCluster] = useState(cluster) const { clustersInSidebar } = useNavSelectorClusters() const handleClusterChange = (value?: string) => { if (value) { - setSelectedClusterName(value) - // navigate(`${baseprefix}/clusters/${value}`) + setSelectedCluster(value) navigate(BASE_NAVIGATE_FROM_CLUSTERLIST.replace('~recordValue~', value)) } else { navigate(`${baseprefix}/clusters/`) @@ -31,8 +30,8 @@ export const SelectorCluster: FC = ({ clusterName }) => { } useMountEffect(() => { - setSelectedClusterName(clusterName) - }, [clusterName]) + setSelectedCluster(cluster) + }, [cluster]) return ( @@ -40,9 +39,8 @@ export const SelectorCluster: FC = ({ clusterName }) => { ) diff --git a/src/components/organisms/HeaderSecond/organisms/SelectorClusterInside/SelectorClusterInside.tsx b/src/components/organisms/HeaderSecond/organisms/SelectorClusterInside/SelectorClusterInside.tsx index d71663f..697891a 100644 --- a/src/components/organisms/HeaderSecond/organisms/SelectorClusterInside/SelectorClusterInside.tsx +++ b/src/components/organisms/HeaderSecond/organisms/SelectorClusterInside/SelectorClusterInside.tsx @@ -8,20 +8,20 @@ import { useMountEffect } from 'hooks/useMountEffect' import { EntrySelect } from 'components/atoms' type TSelectorClusterInsideProps = { - clusterName?: string + cluster?: string } -export const SelectorClusterInside: FC = ({ clusterName }) => { +export const SelectorClusterInside: FC = ({ cluster }) => { const navigate = useNavigate() const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) - const [selectedClusterName, setSelectedClusterName] = useState(clusterName) + const [selectedCluster, setSelectedCluster] = useState(cluster) - const { clustersInSidebar } = useNavSelectorInside(selectedClusterName) + const { clustersInSidebar } = useNavSelectorInside(selectedCluster) const handleClusterChange = (value?: string) => { if (value) { - setSelectedClusterName(value) + setSelectedCluster(value) navigate(`${baseprefix}/inside/${value}/apis`) } else { navigate(`${baseprefix}/inside/`) @@ -29,8 +29,8 @@ export const SelectorClusterInside: FC = ({ cluster } useMountEffect(() => { - setSelectedClusterName(clusterName) - }, [clusterName]) + setSelectedCluster(cluster) + }, [cluster]) return ( @@ -38,9 +38,8 @@ export const SelectorClusterInside: FC = ({ cluster ) diff --git a/src/components/organisms/HeaderSecond/organisms/SelectorInside/SelectorInside.tsx b/src/components/organisms/HeaderSecond/organisms/SelectorInside/SelectorInside.tsx index bd62b44..31a0ee2 100644 --- a/src/components/organisms/HeaderSecond/organisms/SelectorInside/SelectorInside.tsx +++ b/src/components/organisms/HeaderSecond/organisms/SelectorInside/SelectorInside.tsx @@ -6,24 +6,18 @@ import { useMountEffect } from 'hooks/useMountEffect' import { EntrySelect } from 'components/atoms' type TSelectorInsideProps = { - clusterName?: string + cluster?: string namespace?: string } -export const SelectorInside: FC = ({ clusterName, namespace }) => { +export const SelectorInside: FC = ({ cluster, namespace }) => { const navigate = useNavigate() const params = useParams() - const [selectedClusterName, setSelectedClusterName] = useState(clusterName) + const [selectedCluster, setSelectedCluster] = useState(cluster) const [selectedNamespace, setSelectedNamespace] = useState(namespace) - // const { namespacesInSidebar, clustersInSidebar } = useNavSelectorInside(selectedClusterName) - const { namespacesInSidebar } = useNavSelectorInside(selectedClusterName) - - // const handleClusterChange = (value: string) => { - // setSelectedClusterName(value) - // navigate(`${baseprefix}/inside/${value}/apis`) - // } + const { namespacesInSidebar } = useNavSelectorInside(selectedCluster) const handleNamepsaceChange = (value?: string) => { if (value && value !== 'all' && params.namespace) { @@ -44,25 +38,19 @@ export const SelectorInside: FC = ({ clusterName, namespac } useMountEffect(() => { - setSelectedClusterName(clusterName) + setSelectedCluster(cluster) setSelectedNamespace(namespace) - }, [namespace, clusterName]) + }, [namespace, cluster]) return ( - {/* */} Namespace: ) diff --git a/src/components/organisms/HeaderSecond/organisms/SelectorNamespace/SelectorNamespace.tsx b/src/components/organisms/HeaderSecond/organisms/SelectorNamespace/SelectorNamespace.tsx index a3c2db5..004a87a 100644 --- a/src/components/organisms/HeaderSecond/organisms/SelectorNamespace/SelectorNamespace.tsx +++ b/src/components/organisms/HeaderSecond/organisms/SelectorNamespace/SelectorNamespace.tsx @@ -1,11 +1,7 @@ import React, { FC, useState } from 'react' import { Flex, Typography } from 'antd' import { useLocation, useNavigate } from 'react-router-dom' -import { - // useDirectUnknownResource, - useK8sSmartResource, - TNavigationResource, -} from '@prorobotech/openapi-k8s-toolkit' +import { useK8sSmartResource, TNavigationResource } from '@prorobotech/openapi-k8s-toolkit' import { useSelector } from 'react-redux' import type { RootState } from 'store/store' import { useNavSelectorInside } from 'hooks/useNavSelectorInside' @@ -15,44 +11,35 @@ import { EntrySelect } from 'components/atoms' import { BASE_API_GROUP, BASE_API_VERSION, + BASE_CUSTOMIZATION_NAVIGATION_RESOURCE_PLURAL, BASE_CUSTOMIZATION_NAVIGATION_RESOURCE_NAME, - BASE_CUSTOMIZATION_NAVIGATION_RESOURCE, } from 'constants/customizationApiGroupAndVersion' type TSelectorNamespaceProps = { - clusterName?: string + cluster?: string namespace?: string } -export const SelectorNamespace: FC = ({ clusterName, namespace }) => { +export const SelectorNamespace: FC = ({ cluster, namespace }) => { const navigate = useNavigate() const location = useLocation() const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) - const [selectedClusterName, setSelectedClusterName] = useState(clusterName) + const [selectedCluster, setSelectedCluster] = useState(cluster) const [selectedNamespace, setSelectedNamespace] = useState(namespace) - const { namespacesInSidebar } = useNavSelectorInside(selectedClusterName) - - // const { data: navigationData } = useDirectUnknownResource<{ - // spec: { namespaces: { clear: string; change: string } } - // }>({ - // uri: `/api/clusters/${clusterName}/k8s/apis/${BASE_API_GROUP}/${BASE_API_VERSION}/${BASE_CUSTOMIZATION_NAVIGATION_RESOURCE_NAME}/${BASE_CUSTOMIZATION_NAVIGATION_RESOURCE}`, - // refetchInterval: false, - // queryKey: ['navigation', clusterName || 'no-cluster'], - // isEnabled: clusterName !== undefined, - // }) + const { namespacesInSidebar } = useNavSelectorInside(selectedCluster) const { data: navigationDataArr } = useK8sSmartResource<{ items: TNavigationResource[] }>({ - cluster: clusterName || '', - group: BASE_API_GROUP, - version: BASE_API_VERSION, - plural: BASE_CUSTOMIZATION_NAVIGATION_RESOURCE_NAME, - fieldSelector: `metadata.name=${BASE_CUSTOMIZATION_NAVIGATION_RESOURCE}`, - isEnabled: clusterName !== undefined, + cluster: cluster || '', + apiGroup: BASE_API_GROUP, + apiVersion: BASE_API_VERSION, + plural: BASE_CUSTOMIZATION_NAVIGATION_RESOURCE_PLURAL, + fieldSelector: `metadata.name=${BASE_CUSTOMIZATION_NAVIGATION_RESOURCE_NAME}`, + isEnabled: cluster !== undefined, }) const navigationData = @@ -65,10 +52,10 @@ export const SelectorNamespace: FC = ({ clusterName, na const { pathname, search, hash } = location const segs = pathname.split('/') - // Assume pattern: /prefix/:clusterName/:namespace?/:syntheticProject?/search/* + // Assume pattern: /prefix/:cluster/:namespace?/:syntheticProject?/search/* // Find the "search" segment index const searchIdx = segs.indexOf('search') - const clusterIdx = segs.indexOf(selectedClusterName || '') + const clusterIdx = segs.indexOf(selectedCluster || '') if (clusterIdx === -1) { return } // bail if we can't find the cluster @@ -101,21 +88,21 @@ export const SelectorNamespace: FC = ({ clusterName, na setSelectedNamespace(value) const changeUrl = navigationData?.spec?.namespaces?.change - .replace('{selectedCluster}', selectedClusterName || 'no-cluster') + .replace('{selectedCluster}', selectedCluster || 'no-cluster') .replace('{value}', value) || 'no navigation data' navigate(changeUrl) } else { const clearUrl = - navigationData?.spec?.namespaces?.clear.replace('{selectedCluster}', selectedClusterName || 'no-cluster') || + navigationData?.spec?.namespaces?.clear.replace('{selectedCluster}', selectedCluster || 'no-cluster') || 'no navigation data' navigate(clearUrl) } } useMountEffect(() => { - setSelectedClusterName(clusterName) + setSelectedCluster(cluster) setSelectedNamespace(namespace) - }, [namespace, clusterName]) + }, [namespace, cluster]) return ( @@ -125,7 +112,7 @@ export const SelectorNamespace: FC = ({ clusterName, na options={[{ value: 'all', label: 'All Namespaces' }, ...namespacesInSidebar]} value={selectedNamespace || 'all'} onChange={handleNamepsaceChange} - disabled={selectedClusterName === undefined || namespacesInSidebar.length === 0} + disabled={selectedCluster === undefined || namespacesInSidebar.length === 0} /> ) diff --git a/src/components/organisms/ListInsideAllResources/ListInsideAllResources.tsx b/src/components/organisms/ListInsideAllResources/ListInsideAllResources.tsx index fc0bf15..9c7a467 100644 --- a/src/components/organisms/ListInsideAllResources/ListInsideAllResources.tsx +++ b/src/components/organisms/ListInsideAllResources/ListInsideAllResources.tsx @@ -33,16 +33,16 @@ export const ListInsideAllResources: FC = ({ names }>() const apiGroupList = useApisResourceTypes({ - clusterName: cluster, + cluster, }) const builtInData = useBuiltinResourceTypes({ - clusterName: cluster, + cluster, }) useEffect(() => { getGroupsByCategory({ - clusterName: cluster, + cluster, namespace, apiGroupListData: apiGroupList.data, builtinResourceTypesData: builtInData.data, diff --git a/src/components/organisms/ListInsideApisByApiGroup/ListInsideApisByApiGroup.tsx b/src/components/organisms/ListInsideApisByApiGroup/ListInsideApisByApiGroup.tsx index 86588bf..f1f0045 100644 --- a/src/components/organisms/ListInsideApisByApiGroup/ListInsideApisByApiGroup.tsx +++ b/src/components/organisms/ListInsideApisByApiGroup/ListInsideApisByApiGroup.tsx @@ -27,13 +27,13 @@ export const ListInsideApisByApiGroup: FC = ({ n const navigate = useNavigate() const { isPending, error, data } = useApiResourceTypesByGroup({ - clusterName: cluster, + cluster, apiGroup, apiVersion, }) useEffect(() => { - filterIfApiInstanceNamespaceScoped({ namespace, data, apiGroup, apiVersion, clusterName: cluster }).then(data => + filterIfApiInstanceNamespaceScoped({ namespace, data, apiGroup, apiVersion, cluster }).then(data => setFilteredResources(data), ) }, [namespace, data, apiGroup, apiVersion, cluster]) diff --git a/src/components/organisms/ListInsideClusterAndNs/ListInsideClusterAndNs.tsx b/src/components/organisms/ListInsideClusterAndNs/ListInsideClusterAndNs.tsx index b3e752c..6508a08 100644 --- a/src/components/organisms/ListInsideClusterAndNs/ListInsideClusterAndNs.tsx +++ b/src/components/organisms/ListInsideClusterAndNs/ListInsideClusterAndNs.tsx @@ -1,14 +1,7 @@ /* eslint-disable no-nested-ternary */ import React, { FC, useState } from 'react' import { Button, Alert, Spin, Typography } from 'antd' -import { - filterSelectOptions, - Spacer, - TSingleResource, - // useBuiltinResources, - // useApiResources, - useK8sSmartResource, -} from '@prorobotech/openapi-k8s-toolkit' +import { filterSelectOptions, Spacer, TSingleResource, useK8sSmartResource } from '@prorobotech/openapi-k8s-toolkit' import { useNavigate } from 'react-router-dom' import { useSelector, useDispatch } from 'react-redux' import { RootState } from 'store/store' @@ -16,7 +9,7 @@ import { setCluster } from 'store/cluster/cluster/cluster' import { CUSTOM_NAMESPACE_API_RESOURCE_API_GROUP, CUSTOM_NAMESPACE_API_RESOURCE_API_VERSION, - CUSTOM_NAMESPACE_API_RESOURCE_RESOURCE_NAME, + CUSTOM_NAMESPACE_API_RESOURCE_PLURAL, } from 'constants/customizationApiGroupAndVersion' import { Styled } from './styled' @@ -37,42 +30,26 @@ export const ListInsideClusterAndNs: FC = () => { CUSTOM_NAMESPACE_API_RESOURCE_API_VERSION && typeof CUSTOM_NAMESPACE_API_RESOURCE_API_VERSION === 'string' && CUSTOM_NAMESPACE_API_RESOURCE_API_VERSION.length > 0 && - CUSTOM_NAMESPACE_API_RESOURCE_RESOURCE_NAME && - typeof CUSTOM_NAMESPACE_API_RESOURCE_RESOURCE_NAME === 'string' && - CUSTOM_NAMESPACE_API_RESOURCE_RESOURCE_NAME.length > 0 - - // const namespacesData = useBuiltinResources({ - // clusterName: selectedCluster || '', - // typeName: 'namespaces', - // limit: null, - // isEnabled: Boolean(selectedCluster !== undefined && !isCustomNamespaceResource), - // }) + CUSTOM_NAMESPACE_API_RESOURCE_PLURAL && + typeof CUSTOM_NAMESPACE_API_RESOURCE_PLURAL === 'string' && + CUSTOM_NAMESPACE_API_RESOURCE_PLURAL.length > 0 const namespacesData = useK8sSmartResource<{ items: TSingleResource[] }>({ cluster: selectedCluster || '', - version: 'v1', + apiVersion: 'v1', plural: 'namespaces', isEnabled: Boolean(selectedCluster !== undefined && !isCustomNamespaceResource), }) - // const namespacesDataCustom = useApiResources({ - // clusterName: selectedCluster || '', - // apiGroup: CUSTOM_NAMESPACE_API_RESOURCE_API_GROUP, - // apiVersion: CUSTOM_NAMESPACE_API_RESOURCE_API_VERSION, - // typeName: CUSTOM_NAMESPACE_API_RESOURCE_RESOURCE_NAME, - // limit: null, - // isEnabled: Boolean(selectedCluster !== undefined && isCustomNamespaceResource), - // }) - const namespacesDataCustom = useK8sSmartResource<{ items: TSingleResource[] }>({ cluster: selectedCluster || '', - group: CUSTOM_NAMESPACE_API_RESOURCE_API_GROUP, - version: CUSTOM_NAMESPACE_API_RESOURCE_API_VERSION, - plural: CUSTOM_NAMESPACE_API_RESOURCE_RESOURCE_NAME, + apiGroup: CUSTOM_NAMESPACE_API_RESOURCE_API_GROUP, + apiVersion: CUSTOM_NAMESPACE_API_RESOURCE_API_VERSION, + plural: CUSTOM_NAMESPACE_API_RESOURCE_PLURAL, isEnabled: Boolean(selectedCluster !== undefined && isCustomNamespaceResource), }) @@ -97,7 +74,6 @@ export const ListInsideClusterAndNs: FC = () => { if (typeof value === 'string') { dispatch(setCluster(value)) setSelectedCluster(value) - // navigate(`/${value}/apis`) } }} onClear={() => { diff --git a/src/components/organisms/ListInsideCrdsByApiGroup/ListInsideCrdsByApiGroup.tsx b/src/components/organisms/ListInsideCrdsByApiGroup/ListInsideCrdsByApiGroup.tsx index ed850b2..f55210c 100644 --- a/src/components/organisms/ListInsideCrdsByApiGroup/ListInsideCrdsByApiGroup.tsx +++ b/src/components/organisms/ListInsideCrdsByApiGroup/ListInsideCrdsByApiGroup.tsx @@ -30,13 +30,13 @@ export const ListInsideCrdsByApiGroup: FC = ({ const [filteredResources, setFilteredResources] = useState() const { isPending, error, data } = useApiResourceTypesByGroup({ - clusterName: cluster, + cluster, apiGroup, apiVersion, }) useEffect(() => { - filterIfApiInstanceNamespaceScoped({ namespace, data, apiGroup, apiVersion, clusterName: cluster }).then(data => + filterIfApiInstanceNamespaceScoped({ namespace, data, apiGroup, apiVersion, cluster }).then(data => setFilteredResources(data), ) }, [namespace, data, apiGroup, apiVersion, cluster]) diff --git a/src/components/organisms/Search/Search.tsx b/src/components/organisms/Search/Search.tsx index 3d531b5..b296aff 100644 --- a/src/components/organisms/Search/Search.tsx +++ b/src/components/organisms/Search/Search.tsx @@ -100,7 +100,7 @@ export const Search: FC = () => { useEffect(() => { setIsLoading(true) setError(undefined) - getKinds({ clusterName: cluster }) + getKinds({ cluster }) .then(data => { setKindIndex(data) setKindWithVersion(getSortedKindsAll(data)) diff --git a/src/components/organisms/Search/molecules/SearchEntry/SearchEntry.tsx b/src/components/organisms/Search/molecules/SearchEntry/SearchEntry.tsx index 28e6ab0..a6be1ee 100644 --- a/src/components/organisms/Search/molecules/SearchEntry/SearchEntry.tsx +++ b/src/components/organisms/Search/molecules/SearchEntry/SearchEntry.tsx @@ -40,7 +40,7 @@ export const SearchEntry: FC = ({ resource, labels, fields, f const { FIELD_NAME } = constants - const [apiGroup, apiVersion, typeName] = resource.split('~') + const [apiGroup, apiVersion, plural] = resource.split('~') const kindName = kindByGvr(kindsWithVersion)(resource) const abbr = getUppercase(kindName && kindName.length ? kindName : 'Loading') @@ -91,13 +91,13 @@ export const SearchEntry: FC = ({ resource, labels, fields, f {isOpen && ( <> - {typeName && ( + {plural && ( 0 ? 'api' : 'builtin'} namespace={isNamespaceResource ? namespace : undefined} apiGroup={apiGroup.length > 0 ? apiGroup : undefined} apiVersion={apiVersion} - typeName={typeName} + plural={plural} labels={labels?.length ? labels : undefined} fields={fields?.length ? fields : undefined} limit={limitSp && limitSp.length > 0 ? Number(limitSp) : undefined} diff --git a/src/components/organisms/Sidebar/styled.ts b/src/components/organisms/Sidebar/styled.ts index ff1f047..216bc6f 100644 --- a/src/components/organisms/Sidebar/styled.ts +++ b/src/components/organisms/Sidebar/styled.ts @@ -1,5 +1,4 @@ import styled from 'styled-components' -// import { HEAD_FIRST_ROW, SIDEBAR_CLUSTER_HEIGHT } from 'constants/blocksSizes' import { HEAD_FIRST_ROW } from 'constants/blocksSizes' type TBackgroundContainerProps = { @@ -16,15 +15,6 @@ const BackgroundContainer = styled.div` height: calc(100vh - ${HEAD_FIRST_ROW}px); ` -// const ClusterSelectorContainer = styled.div` -// height: ${SIDEBAR_CLUSTER_HEIGHT}px; -// display: flex; -// justify-content: center; -// align-items: center; -// padding: 12px; -// ` - export const Styled = { BackgroundContainer, - // ClusterSelectorContainer, } diff --git a/src/constants/blocksSizes.ts b/src/constants/blocksSizes.ts index 545c3d3..a89fc15 100644 --- a/src/constants/blocksSizes.ts +++ b/src/constants/blocksSizes.ts @@ -4,8 +4,6 @@ export const NAV_HEIGHT = 50 export const FOOTER_HEIGHT = 38 export const MAIN_CONTENT_HORIZONTAL_PADDING = 24 export const BACKLINK_HEIGHT = 26 -/* sidebar */ -// export const SIDEBAR_CLUSTER_HEIGHT = 56 /* computed only */ export const BREADCRUMBS_HEIGHT = 26 export const CONTENT_CARD_PADDING = 25 diff --git a/src/constants/customizationApiGroupAndVersion.ts b/src/constants/customizationApiGroupAndVersion.ts index dc40f62..c35578a 100644 --- a/src/constants/customizationApiGroupAndVersion.ts +++ b/src/constants/customizationApiGroupAndVersion.ts @@ -27,12 +27,13 @@ export const BASE_API_VERSION = import.meta.env.DEV ? window._env_.CUSTOMIZATION_API_VERSION || import.meta.env.VITE_CUSTOMIZATION_API_VERSION : window._env_.CUSTOMIZATION_API_VERSION +export const BASE_CUSTOMIZATION_NAVIGATION_RESOURCE_PLURAL = import.meta.env.DEV + ? window._env_.CUSTOMIZATION_NAVIGATION_RESOURCE_PLURAL || + import.meta.env.VITE_CUSTOMIZATION_NAVIGATION_RESOURCE_PLURAL + : window._env_.CUSTOMIZATION_NAVIGATION_RESOURCE_PLURAL export const BASE_CUSTOMIZATION_NAVIGATION_RESOURCE_NAME = import.meta.env.DEV ? window._env_.CUSTOMIZATION_NAVIGATION_RESOURCE_NAME || import.meta.env.VITE_CUSTOMIZATION_NAVIGATION_RESOURCE_NAME : window._env_.CUSTOMIZATION_NAVIGATION_RESOURCE_NAME -export const BASE_CUSTOMIZATION_NAVIGATION_RESOURCE = import.meta.env.DEV - ? window._env_.CUSTOMIZATION_NAVIGATION_RESOURCE || import.meta.env.VITE_CUSTOMIZATION_NAVIGATION_RESOURCE - : window._env_.CUSTOMIZATION_NAVIGATION_RESOURCE export const CUSTOMIZATION_SIDEBAR_FALLBACK_ID = import.meta.env.DEV ? window._env_.CUSTOMIZATION_SIDEBAR_FALLBACK_ID || import.meta.env.VITE_CUSTOMIZATION_SIDEBAR_FALLBACK_ID @@ -53,29 +54,29 @@ export const BASE_NAVIGATE_FROM_CLUSTERLIST = import.meta.env.DEV export const BASE_PROJECTS_API_GROUP = import.meta.env.DEV ? window._env_.PROJECTS_API_GROUP || import.meta.env.VITE_PROJECTS_API_GROUP : window._env_.PROJECTS_API_GROUP -export const BASE_PROJECTS_VERSION = import.meta.env.DEV - ? window._env_.PROJECTS_VERSION || import.meta.env.VITE_PROJECTS_VERSION - : window._env_.PROJECTS_VERSION -export const BASE_PROJECTS_RESOURCE_NAME = import.meta.env.DEV - ? window._env_.PROJECTS_RESOURCE_NAME || import.meta.env.VITE_PROJECTS_RESOURCE_NAME - : window._env_.PROJECTS_RESOURCE_NAME +export const BASE_PROJECTS_API_VERSION = import.meta.env.DEV + ? window._env_.PROJECTS_API_VERSION || import.meta.env.VITE_PROJECTS_API_VERSION + : window._env_.PROJECTS_API_VERSION +export const BASE_PROJECTS_PLURAL = import.meta.env.DEV + ? window._env_.PROJECTS_PLURAL || import.meta.env.VITE_PROJECTS_PLURAL + : window._env_.PROJECTS_PLURAL -export const BASE_MARKETPLACE_RESOURCE_NAME = import.meta.env.DEV - ? window._env_.MARKETPLACE_RESOURCE_NAME || import.meta.env.VITE_MARKETPLACE_RESOURCE_NAME - : window._env_.MARKETPLACE_RESOURCE_NAME +export const BASE_MARKETPLACE_PLURAL = import.meta.env.DEV + ? window._env_.MARKETPLACE_PLURAL || import.meta.env.VITE_MARKETPLACE_PLURAL + : window._env_.MARKETPLACE_PLURAL export const BASE_MARKETPLACE_KIND = import.meta.env.DEV ? import.meta.env.VITE_MARKETPLACE_KIND : window._env_.MARKETPLACE_KIND -export const BASE_INSTANCES_API_GROUP = import.meta.env.DEV +export const BASE_INSTANCES_API_GROUP: string | undefined = import.meta.env.DEV ? window._env_.INSTANCES_API_GROUP || import.meta.env.VITE_INSTANCES_API_GROUP : window._env_.INSTANCES_API_GROUP -export const BASE_INSTANCES_VERSION = import.meta.env.DEV - ? window._env_.INSTANCES_VERSION || import.meta.env.VITE_INSTANCES_VERSION - : window._env_.INSTANCES_VERSION -export const BASE_INSTANCES_RESOURCE_NAME = import.meta.env.DEV - ? window._env_.INSTANCES_RESOURCE_NAME || import.meta.env.VITE_INSTANCES_RESOURCE_NAME - : window._env_.INSTANCES_RESOURCE_NAME +export const BASE_INSTANCES_API_VERSION = import.meta.env.DEV + ? window._env_.INSTANCES_API_VERSION || import.meta.env.VITE_INSTANCES_API_VERSION + : window._env_.INSTANCES_API_VERSION +export const BASE_INSTANCES_PLURAL = import.meta.env.DEV + ? window._env_.INSTANCES_PLURAL || import.meta.env.VITE_INSTANCES_PLURAL + : window._env_.INSTANCES_PLURAL export const NODE_TERMINAL_DEFAULT_PROFILE = import.meta.env.DEV ? window._env_.NODE_TERMINAL_DEFAULT_PROFILE || import.meta.env.VITE_NODE_TERMINAL_DEFAULT_PROFILE @@ -123,14 +124,13 @@ export const BASE_NAMESPACE_FACTORY_KEY = import.meta.env.DEV ? window._env_.BASE_NAMESPACE_FACTORY_KEY || import.meta.env.VITE_BASE_NAMESPACE_FACTORY_KEY : window._env_.BASE_NAMESPACE_FACTORY_KEY -export const CUSTOM_NAMESPACE_API_RESOURCE_API_GROUP = import.meta.env.DEV +export const CUSTOM_NAMESPACE_API_RESOURCE_API_GROUP: string | undefined = import.meta.env.DEV ? window._env_.CUSTOM_NAMESPACE_API_RESOURCE_API_GROUP || import.meta.env.VITE_CUSTOM_NAMESPACE_API_RESOURCE_API_GROUP : window._env_.CUSTOM_NAMESPACE_API_RESOURCE_API_GROUP export const CUSTOM_NAMESPACE_API_RESOURCE_API_VERSION = import.meta.env.DEV ? window._env_.CUSTOM_NAMESPACE_API_RESOURCE_API_VERSION || import.meta.env.VITE_CUSTOM_NAMESPACE_API_RESOURCE_API_VERSION : window._env_.CUSTOM_NAMESPACE_API_RESOURCE_API_VERSION -export const CUSTOM_NAMESPACE_API_RESOURCE_RESOURCE_NAME = import.meta.env.DEV - ? window._env_.CUSTOM_NAMESPACE_API_RESOURCE_RESOURCE_NAME || - import.meta.env.VITE_CUSTOM_NAMESPACE_API_RESOURCE_RESOURCE_NAME - : window._env_.CUSTOM_NAMESPACE_API_RESOURCE_RESOURCE_NAME +export const CUSTOM_NAMESPACE_API_RESOURCE_PLURAL = import.meta.env.DEV + ? window._env_.CUSTOM_NAMESPACE_API_RESOURCE_PLURAL || import.meta.env.VITE_CUSTOM_NAMESPACE_API_RESOURCE_PLURAL + : window._env_.CUSTOM_NAMESPACE_API_RESOURCE_PLURAL diff --git a/src/hooks/useIsSearchPage/useIsSearchPage.ts b/src/hooks/useIsSearchPage/useIsSearchPage.ts index a7c3ad9..5eadd49 100644 --- a/src/hooks/useIsSearchPage/useIsSearchPage.ts +++ b/src/hooks/useIsSearchPage/useIsSearchPage.ts @@ -3,7 +3,7 @@ import { useLocation, matchPath } from 'react-router-dom' export const useIsSearchPage = (prefix: string) => { const { pathname } = useLocation() const base = `/${prefix}`.replace(/\/{2,}/g, '/').replace(/\/$/, '') - const pattern = `${base}/:clusterName/:namespace?/:syntheticProject?/search/*` + const pattern = `${base}/:cluster/:namespace?/:syntheticProject?/search/*` return Boolean(matchPath({ path: pattern }, pathname)) } diff --git a/src/hooks/useNavSelector/useNavSelector.ts b/src/hooks/useNavSelector/useNavSelector.ts index a54da43..155b23e 100644 --- a/src/hooks/useNavSelector/useNavSelector.ts +++ b/src/hooks/useNavSelector/useNavSelector.ts @@ -1,8 +1,6 @@ import { - // useApiResources, TClusterList, TSingleResource, - // useDirectUnknownResource, useK8sSmartResource, TNavigationResource, } from '@prorobotech/openapi-k8s-toolkit' @@ -11,14 +9,14 @@ import { RootState } from 'store/store' import { BASE_API_GROUP, BASE_API_VERSION, + BASE_CUSTOMIZATION_NAVIGATION_RESOURCE_PLURAL, BASE_CUSTOMIZATION_NAVIGATION_RESOURCE_NAME, - BASE_CUSTOMIZATION_NAVIGATION_RESOURCE, BASE_PROJECTS_API_GROUP, - BASE_PROJECTS_VERSION, - BASE_PROJECTS_RESOURCE_NAME, + BASE_PROJECTS_API_VERSION, + BASE_PROJECTS_PLURAL, BASE_INSTANCES_API_GROUP, - BASE_INSTANCES_VERSION, - BASE_INSTANCES_RESOURCE_NAME, + BASE_INSTANCES_API_VERSION, + BASE_INSTANCES_PLURAL, } from 'constants/customizationApiGroupAndVersion' import { parseAll } from './utils' @@ -49,62 +47,33 @@ const mappedInstanceToOptionInSidebar = ({ label: instance.metadata.name, }) -export const useNavSelector = (clusterName?: string, projectName?: string) => { +export const useNavSelector = (cluster?: string, projectName?: string) => { const clusterList = useSelector((state: RootState) => state.clusterList.clusterList) - // const { data: navigationData } = useDirectUnknownResource<{ - // spec: { instances: { mapOptionsPattern: string } } - // }>({ - // uri: `/api/clusters/${clusterName}/k8s/apis/${BASE_API_GROUP}/${BASE_API_VERSION}/${BASE_CUSTOMIZATION_NAVIGATION_RESOURCE_NAME}/${BASE_CUSTOMIZATION_NAVIGATION_RESOURCE}`, - // refetchInterval: false, - // queryKey: ['navigation', clusterName || 'no-cluster'], - // isEnabled: clusterName !== undefined, - // }) - const { data: navigationDataArr } = useK8sSmartResource<{ items: TNavigationResource[] }>({ - cluster: clusterName || '', - group: BASE_API_GROUP, - version: BASE_API_VERSION, - plural: BASE_CUSTOMIZATION_NAVIGATION_RESOURCE_NAME, - fieldSelector: `metadata.name=${BASE_CUSTOMIZATION_NAVIGATION_RESOURCE}`, - isEnabled: clusterName !== undefined, + cluster: cluster || '', + apiGroup: BASE_API_GROUP, + apiVersion: BASE_API_VERSION, + plural: BASE_CUSTOMIZATION_NAVIGATION_RESOURCE_PLURAL, + fieldSelector: `metadata.name=${BASE_CUSTOMIZATION_NAVIGATION_RESOURCE_NAME}`, + isEnabled: cluster !== undefined, }) const navigationData = navigationDataArr?.items && navigationDataArr.items.length > 0 ? navigationDataArr.items[0] : undefined - // const { data: projects } = useApiResources({ - // clusterName: clusterName || '', - // namespace: '', - // apiGroup: BASE_PROJECTS_API_GROUP, - // apiVersion: BASE_PROJECTS_VERSION, - // typeName: BASE_PROJECTS_RESOURCE_NAME, - // limit: null, - // isEnabled: clusterName !== undefined, - // }) - const { data: projects } = useK8sSmartResource<{ items: TSingleResource[] }>({ - cluster: clusterName || '', - group: BASE_PROJECTS_API_GROUP, - version: BASE_PROJECTS_VERSION, - plural: BASE_PROJECTS_RESOURCE_NAME, - isEnabled: clusterName !== undefined, + cluster: cluster || '', + apiGroup: BASE_PROJECTS_API_GROUP, + apiVersion: BASE_PROJECTS_API_VERSION, + plural: BASE_PROJECTS_PLURAL, + isEnabled: cluster !== undefined, }) - // const { data: instances, isSuccess: allInstancesLoadingSuccess } = useApiResources({ - // clusterName: clusterName || '', - // namespace: '', - // apiGroup: BASE_INSTANCES_API_GROUP, - // apiVersion: BASE_INSTANCES_VERSION, - // typeName: BASE_INSTANCES_RESOURCE_NAME, - // limit: null, - // isEnabled: clusterName !== undefined, - // }) - const { data: instances, isLoading: isInstancesLoading, @@ -112,11 +81,11 @@ export const useNavSelector = (clusterName?: string, projectName?: string) => { } = useK8sSmartResource<{ items: TSingleResource[] }>({ - cluster: clusterName || '', - group: BASE_INSTANCES_API_GROUP, - version: BASE_INSTANCES_VERSION, - plural: BASE_INSTANCES_RESOURCE_NAME, - isEnabled: clusterName !== undefined, + cluster: cluster || '', + apiGroup: BASE_INSTANCES_API_GROUP, + apiVersion: BASE_INSTANCES_API_VERSION, + plural: BASE_INSTANCES_PLURAL, + isEnabled: cluster !== undefined, }) const allInstancesLoadingSuccess: boolean = Boolean( @@ -124,9 +93,9 @@ export const useNavSelector = (clusterName?: string, projectName?: string) => { ) const clustersInSidebar = clusterList ? clusterList.map(mappedClusterToOptionInSidebar) : [] - const projectsInSidebar = clusterName && projects ? projects.items.map(mappedProjectToOptionInSidebar) : [] + const projectsInSidebar = cluster && projects ? projects.items.map(mappedProjectToOptionInSidebar) : [] const instancesInSidebar = - clusterName && instances + cluster && instances ? instances.items .filter(item => item.metadata.namespace === projectName) .map(item => diff --git a/src/hooks/useNavSelectorInside.ts b/src/hooks/useNavSelectorInside.ts index 58c4b06..c7e5ec5 100644 --- a/src/hooks/useNavSelectorInside.ts +++ b/src/hooks/useNavSelectorInside.ts @@ -1,16 +1,10 @@ -import { - TClusterList, - TSingleResource, - // useBuiltinResources, - // useApiResources, - useK8sSmartResource, -} from '@prorobotech/openapi-k8s-toolkit' +import { TClusterList, TSingleResource, useK8sSmartResource } from '@prorobotech/openapi-k8s-toolkit' import { useSelector } from 'react-redux' import { RootState } from 'store/store' import { CUSTOM_NAMESPACE_API_RESOURCE_API_GROUP, CUSTOM_NAMESPACE_API_RESOURCE_API_VERSION, - CUSTOM_NAMESPACE_API_RESOURCE_RESOURCE_NAME, + CUSTOM_NAMESPACE_API_RESOURCE_PLURAL, } from 'constants/customizationApiGroupAndVersion' const mappedClusterToOptionInSidebar = ({ name }: TClusterList[number]): { value: string; label: string } => ({ @@ -23,7 +17,7 @@ const mappedNamespaceToOptionInSidebar = ({ metadata }: TSingleResource): { valu label: metadata.name, }) -export const useNavSelectorInside = (clusterName?: string) => { +export const useNavSelectorInside = (cluster?: string) => { const clusterList = useSelector((state: RootState) => state.clusterList.clusterList) const isCustomNamespaceResource = @@ -33,49 +27,33 @@ export const useNavSelectorInside = (clusterName?: string) => { CUSTOM_NAMESPACE_API_RESOURCE_API_VERSION && typeof CUSTOM_NAMESPACE_API_RESOURCE_API_VERSION === 'string' && CUSTOM_NAMESPACE_API_RESOURCE_API_VERSION.length > 0 && - CUSTOM_NAMESPACE_API_RESOURCE_RESOURCE_NAME && - typeof CUSTOM_NAMESPACE_API_RESOURCE_RESOURCE_NAME === 'string' && - CUSTOM_NAMESPACE_API_RESOURCE_RESOURCE_NAME.length > 0 - - // const { data: namespaces } = useBuiltinResources({ - // clusterName: clusterName || '', - // typeName: 'namespaces', - // limit: null, - // isEnabled: Boolean(clusterName !== undefined && !isCustomNamespaceResource), - // }) + CUSTOM_NAMESPACE_API_RESOURCE_PLURAL && + typeof CUSTOM_NAMESPACE_API_RESOURCE_PLURAL === 'string' && + CUSTOM_NAMESPACE_API_RESOURCE_PLURAL.length > 0 const { data: namespaces } = useK8sSmartResource<{ items: TSingleResource[] }>({ - cluster: clusterName || '', - version: 'v1', + cluster: cluster || '', + apiVersion: 'v1', plural: 'namespaces', - isEnabled: Boolean(clusterName !== undefined && !isCustomNamespaceResource), + isEnabled: Boolean(cluster !== undefined && !isCustomNamespaceResource), }) - // const { data: namespacesCustom } = useApiResources({ - // clusterName: clusterName || '', - // apiGroup: CUSTOM_NAMESPACE_API_RESOURCE_API_GROUP, - // apiVersion: CUSTOM_NAMESPACE_API_RESOURCE_API_VERSION, - // typeName: CUSTOM_NAMESPACE_API_RESOURCE_RESOURCE_NAME, - // limit: null, - // isEnabled: Boolean(clusterName !== undefined && isCustomNamespaceResource), - // }) - const { data: namespacesCustom } = useK8sSmartResource<{ items: TSingleResource[] }>({ - cluster: clusterName || '', - group: CUSTOM_NAMESPACE_API_RESOURCE_API_GROUP, - version: CUSTOM_NAMESPACE_API_RESOURCE_API_VERSION, - plural: CUSTOM_NAMESPACE_API_RESOURCE_RESOURCE_NAME, - isEnabled: Boolean(clusterName !== undefined && !isCustomNamespaceResource), + cluster: cluster || '', + apiGroup: CUSTOM_NAMESPACE_API_RESOURCE_API_GROUP, + apiVersion: CUSTOM_NAMESPACE_API_RESOURCE_API_VERSION, + plural: CUSTOM_NAMESPACE_API_RESOURCE_PLURAL, + isEnabled: Boolean(cluster !== undefined && !isCustomNamespaceResource), }) const clustersInSidebar = clusterList ? clusterList.map(mappedClusterToOptionInSidebar) : [] - const namespacesInSidebar = clusterName && namespaces ? namespaces.items.map(mappedNamespaceToOptionInSidebar) : [] + const namespacesInSidebar = cluster && namespaces ? namespaces.items.map(mappedNamespaceToOptionInSidebar) : [] const namespacesInSidebarCustom = - clusterName && namespacesCustom ? namespacesCustom.items.map(mappedNamespaceToOptionInSidebar) : [] + cluster && namespacesCustom ? namespacesCustom.items.map(mappedNamespaceToOptionInSidebar) : [] return { clustersInSidebar, diff --git a/src/pages/Forms/FormApiPage/FormApiPage.tsx b/src/pages/Forms/FormApiPage/FormApiPage.tsx index 858a392..5287fbd 100644 --- a/src/pages/Forms/FormApiPage/FormApiPage.tsx +++ b/src/pages/Forms/FormApiPage/FormApiPage.tsx @@ -9,7 +9,7 @@ import { BASE_USE_NAMESPACE_NAV } from 'constants/customizationApiGroupAndVersio import { TChromeCtx } from 'templates' export const FormApiPage: FC = () => { - const { clusterName, syntheticProject, namespace, apiGroup, apiVersion, typeName, entryName } = useParams() + const { cluster, syntheticProject, namespace, apiGroup, apiVersion, plural, name } = useParams() const [searchParams] = useSearchParams() const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) @@ -20,7 +20,7 @@ export const FormApiPage: FC = () => { const preparedBacklink = getFormsBackLink({ backLink, - clusterName, + cluster, possibleProject, possibleInstance, baseprefix, @@ -32,12 +32,10 @@ export const FormApiPage: FC = () => { useEffect(() => { setSidebarSuffix('api-form') - setBreadcrumbsSuffix(`api-form${entryName ? '-edit' : ''}`) - setCurrentTags([`${apiGroup}/${apiVersion}/${typeName}`]) + setBreadcrumbsSuffix(`api-form${name ? '-edit' : ''}`) + setCurrentTags([`${apiGroup}/${apiVersion}/${plural}`]) setBacklinkTo(preparedBacklink) - setBacklinkTitle( - `${entryName ? 'Update' : 'Create'} ${apiGroup}/${apiVersion}/${typeName}${entryName ? `/${entryName}` : ''}`, - ) + setBacklinkTitle(`${name ? 'Update' : 'Create'} ${apiGroup}/${apiVersion}/${plural}${name ? `/${name}` : ''}`) return () => { setCurrentTags(undefined) @@ -49,8 +47,8 @@ export const FormApiPage: FC = () => { }, [ apiGroup, apiVersion, - typeName, - entryName, + plural, + name, preparedBacklink, setSidebarSuffix, setBreadcrumbsSuffix, @@ -58,19 +56,19 @@ export const FormApiPage: FC = () => { setBacklinkTo, setBacklinkTitle, ]) - if (!typeName || !apiGroup || !apiVersion) { + if (!plural || !apiGroup || !apiVersion) { return null } return ( - {entryName ? ( + {name ? ( ) : ( @@ -78,7 +76,7 @@ export const FormApiPage: FC = () => { namespace={namespace} apiGroup={apiGroup} apiVersion={apiVersion} - typeName={typeName} + plural={plural} backLink={backLink} /> )} diff --git a/src/pages/Forms/FormBuiltinPage/FormBuiltinPage.tsx b/src/pages/Forms/FormBuiltinPage/FormBuiltinPage.tsx index c9472f8..7aeb5a6 100644 --- a/src/pages/Forms/FormBuiltinPage/FormBuiltinPage.tsx +++ b/src/pages/Forms/FormBuiltinPage/FormBuiltinPage.tsx @@ -9,7 +9,7 @@ import { BASE_USE_NAMESPACE_NAV } from 'constants/customizationApiGroupAndVersio import { TChromeCtx } from 'templates' export const FormBuiltinPage: FC = () => { - const { clusterName, syntheticProject, namespace, typeName, entryName } = useParams() + const { cluster, syntheticProject, namespace, plural, name } = useParams() const [searchParams] = useSearchParams() const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) @@ -20,7 +20,7 @@ export const FormBuiltinPage: FC = () => { const preparedBacklink = getFormsBackLink({ backLink, - clusterName, + cluster, possibleProject, possibleInstance, baseprefix, @@ -32,10 +32,10 @@ export const FormBuiltinPage: FC = () => { useEffect(() => { setSidebarSuffix('builtin-form') - setBreadcrumbsSuffix(`builtin-form${entryName ? '-edit' : ''}`) - setCurrentTags([`${typeName}`]) + setBreadcrumbsSuffix(`builtin-form${name ? '-edit' : ''}`) + setCurrentTags([`${plural}`]) setBacklinkTo(preparedBacklink) - setBacklinkTitle(`${entryName ? 'Update' : 'Create'} ${typeName}${entryName ? `/${entryName}` : ''}`) + setBacklinkTitle(`${name ? 'Update' : 'Create'} ${plural}${name ? `/${name}` : ''}`) return () => { setCurrentTags(undefined) @@ -45,8 +45,8 @@ export const FormBuiltinPage: FC = () => { setBacklinkTitle(undefined) } }, [ - typeName, - entryName, + plural, + name, preparedBacklink, setSidebarSuffix, setBreadcrumbsSuffix, @@ -55,16 +55,16 @@ export const FormBuiltinPage: FC = () => { setBacklinkTitle, ]) - if (!typeName) { + if (!plural) { return null } return ( - {entryName ? ( - + {name ? ( + ) : ( - + )} ) diff --git a/src/pages/Forms/FormCrdPage/FormCrdPage.tsx b/src/pages/Forms/FormCrdPage/FormCrdPage.tsx index a3202a9..2a18980 100644 --- a/src/pages/Forms/FormCrdPage/FormCrdPage.tsx +++ b/src/pages/Forms/FormCrdPage/FormCrdPage.tsx @@ -9,7 +9,7 @@ import { BASE_USE_NAMESPACE_NAV } from 'constants/customizationApiGroupAndVersio import { TChromeCtx } from 'templates' export const FormCrdPage: FC = () => { - const { clusterName, syntheticProject, apiGroup, apiVersion, namespace, typeName, entryName } = useParams() + const { cluster, syntheticProject, apiGroup, apiVersion, namespace, plural, name } = useParams() const [searchParams] = useSearchParams() const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) @@ -20,7 +20,7 @@ export const FormCrdPage: FC = () => { const preparedBacklink = getFormsBackLink({ backLink, - clusterName, + cluster, possibleProject, possibleInstance, baseprefix, @@ -32,12 +32,10 @@ export const FormCrdPage: FC = () => { useEffect(() => { setSidebarSuffix('crd-form') - setBreadcrumbsSuffix(`crd-form${entryName ? '-edit' : ''}`) - setCurrentTags([`${apiGroup}/${apiVersion}/${typeName}`]) + setBreadcrumbsSuffix(`crd-form${name ? '-edit' : ''}`) + setCurrentTags([`${apiGroup}/${apiVersion}/${plural}`]) setBacklinkTo(preparedBacklink) - setBacklinkTitle( - `${entryName ? 'Update' : 'Create'} ${apiGroup}/${apiVersion}/${typeName}${entryName ? `/${entryName}` : ''}`, - ) + setBacklinkTitle(`${plural ? 'Update' : 'Create'} ${apiGroup}/${apiVersion}/${plural}${name ? `/${name}` : ''}`) return () => { setCurrentTags(undefined) @@ -49,8 +47,8 @@ export const FormCrdPage: FC = () => { }, [ apiGroup, apiVersion, - typeName, - entryName, + plural, + name, preparedBacklink, setSidebarSuffix, setBreadcrumbsSuffix, @@ -59,18 +57,18 @@ export const FormCrdPage: FC = () => { setBacklinkTitle, ]) - if (!typeName || !apiGroup || !apiVersion) { + if (!plural || !apiGroup || !apiVersion) { return null } return ( - {entryName ? ( + {name ? ( ) : ( @@ -78,7 +76,7 @@ export const FormCrdPage: FC = () => { namespace={namespace} apiGroup={apiGroup} apiVersion={apiVersion} - typeName={typeName} + plural={plural} backLink={backLink} /> )} diff --git a/src/pages/Forms/index.ts b/src/pages/Forms/index.ts index 2a27924..7476473 100644 --- a/src/pages/Forms/index.ts +++ b/src/pages/Forms/index.ts @@ -1,3 +1,2 @@ -// export { FormCrdPage } from './FormCrdPage' export { FormApiPage } from './FormApiPage' export { FormBuiltinPage } from './FormBuiltinPage' diff --git a/src/pages/Tables/TableApiPage/TableApiPage.tsx b/src/pages/Tables/TableApiPage/TableApiPage.tsx index 98fcda1..ec7b16f 100644 --- a/src/pages/Tables/TableApiPage/TableApiPage.tsx +++ b/src/pages/Tables/TableApiPage/TableApiPage.tsx @@ -10,8 +10,8 @@ import { TChromeCtx } from 'templates' import { BASE_USE_NAMESPACE_NAV, BASE_PROJECTS_API_GROUP, - BASE_PROJECTS_VERSION, - BASE_PROJECTS_RESOURCE_NAME, + BASE_PROJECTS_API_VERSION, + BASE_PROJECTS_PLURAL, } from 'constants/customizationApiGroupAndVersion' type TTableApiPageProps = { @@ -19,22 +19,22 @@ type TTableApiPageProps = { } export const TableApiPage: FC = ({ inside }) => { - const { clusterName, namespace, syntheticProject, apiGroup, apiVersion, typeName } = useParams() + const { cluster, namespace, syntheticProject, apiGroup, apiVersion, plural } = useParams() const [searchParams] = useSearchParams() const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) const isProjectList = !namespace && apiGroup === BASE_PROJECTS_API_GROUP && - apiVersion === BASE_PROJECTS_VERSION && - typeName === BASE_PROJECTS_RESOURCE_NAME + apiVersion === BASE_PROJECTS_API_VERSION && + plural === BASE_PROJECTS_PLURAL const breadcrumbsIdProjectList = 'projects-list' const possibleProject = syntheticProject && namespace ? syntheticProject : namespace const possibleInstance = syntheticProject && namespace ? namespace : undefined const preparedBacklink = getTablesBackLink({ - clusterName, + cluster, possibleProject, possibleInstance, namespace, @@ -49,7 +49,7 @@ export const TableApiPage: FC = ({ inside }) => { useEffect(() => { setSidebarSuffix('builtin-table') setBreadcrumbsSuffix(isProjectList ? breadcrumbsIdProjectList : 'api-table') - setCurrentTags([`${typeName}`]) + setCurrentTags([`${plural}`]) setBacklinkTo(preparedBacklink) setBacklinkTitle(undefined) @@ -58,10 +58,10 @@ export const TableApiPage: FC = ({ inside }) => { setSidebarSuffix(undefined) setBreadcrumbsSuffix(undefined) setBacklinkTo(undefined) - setBacklinkTitle(`${apiGroup}/${apiVersion}/${typeName}`) + setBacklinkTitle(`${apiGroup}/${apiVersion}/${plural}`) } }, [ - typeName, + plural, isProjectList, breadcrumbsIdProjectList, preparedBacklink, @@ -85,14 +85,14 @@ export const TableApiPage: FC = ({ inside }) => { return ( - {typeName && apiGroup && apiVersion && ( + {plural && apiGroup && apiVersion && ( 0 ? Number(limitSp) : undefined} inside={inside} customizationIdPrefix={tableCustomizationIdPrefix} diff --git a/src/pages/Tables/TableBuiltinPage/TableBuiltinPage.tsx b/src/pages/Tables/TableBuiltinPage/TableBuiltinPage.tsx index c3e402c..b70d9cc 100644 --- a/src/pages/Tables/TableBuiltinPage/TableBuiltinPage.tsx +++ b/src/pages/Tables/TableBuiltinPage/TableBuiltinPage.tsx @@ -14,7 +14,7 @@ type TTableBuiltinPageProps = { } export const TableBuiltinPage: FC = ({ inside }) => { - const { clusterName, namespace, syntheticProject, typeName } = useParams() + const { cluster, namespace, syntheticProject, plural } = useParams() const [searchParams] = useSearchParams() const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) @@ -22,7 +22,7 @@ export const TableBuiltinPage: FC = ({ inside }) => { const possibleInstance = syntheticProject && namespace ? namespace : undefined const preparedBacklink = getTablesBackLink({ - clusterName, + cluster, possibleProject, possibleInstance, namespace, @@ -37,9 +37,9 @@ export const TableBuiltinPage: FC = ({ inside }) => { useEffect(() => { setSidebarSuffix('builtin-table') setBreadcrumbsSuffix('builtin-table') - setCurrentTags([`${typeName}`]) + setCurrentTags([`${plural}`]) setBacklinkTo(preparedBacklink) - setBacklinkTitle(typeName) + setBacklinkTitle(plural) return () => { setCurrentTags(undefined) @@ -49,7 +49,7 @@ export const TableBuiltinPage: FC = ({ inside }) => { setBacklinkTitle(undefined) } }, [ - typeName, + plural, preparedBacklink, setSidebarSuffix, setBreadcrumbsSuffix, @@ -69,13 +69,13 @@ export const TableBuiltinPage: FC = ({ inside }) => { return ( - {typeName && ( + {plural && ( 0 ? Number(limitSp) : undefined} inside={inside} customizationIdPrefix={tableCustomizationIdPrefix} diff --git a/src/pages/Tables/TableCrdPage/TableCrdPage.tsx b/src/pages/Tables/TableCrdPage/TableCrdPage.tsx index 1eddc08..5bab36a 100644 --- a/src/pages/Tables/TableCrdPage/TableCrdPage.tsx +++ b/src/pages/Tables/TableCrdPage/TableCrdPage.tsx @@ -14,14 +14,14 @@ type TTableCrdPageProps = { } export const TableCrdPage: FC = ({ inside }) => { - const { clusterName, namespace, syntheticProject, apiGroup, apiVersion, apiExtensionVersion, crdName } = useParams() + const { cluster, namespace, syntheticProject, apiGroup, apiVersion, apiExtensionVersion, crdName } = useParams() const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) const possibleProject = syntheticProject && namespace ? syntheticProject : namespace const possibleInstance = syntheticProject && namespace ? namespace : undefined const preparedBacklink = getTablesBackLink({ - clusterName, + cluster, possibleProject, possibleInstance, namespace, diff --git a/src/pages/Tables/index.ts b/src/pages/Tables/index.ts index 842bb38..fa949a1 100644 --- a/src/pages/Tables/index.ts +++ b/src/pages/Tables/index.ts @@ -1,3 +1,2 @@ -// export { TableCrdPage } from './TableCrdPage' export { TableApiPage } from './TableApiPage' export { TableBuiltinPage } from './TableBuiltinPage' diff --git a/src/store/theme/theme/theme.ts b/src/store/theme/theme/theme.ts index f567799..2c4ee9c 100644 --- a/src/store/theme/theme/theme.ts +++ b/src/store/theme/theme/theme.ts @@ -21,5 +21,3 @@ export const themeSlice = createSlice({ }) export const { setTheme } = themeSlice.actions - -// export default themeSlice diff --git a/src/templates/AppShell/AppShell.tsx b/src/templates/AppShell/AppShell.tsx index c42f1a7..21d3cd0 100644 --- a/src/templates/AppShell/AppShell.tsx +++ b/src/templates/AppShell/AppShell.tsx @@ -1,4 +1,3 @@ -// AppShell.tsx import React, { FC, useState, useMemo } from 'react' import { Outlet, useParams } from 'react-router-dom' import { BaseTemplate } from 'templates' diff --git a/src/templates/BaseTemplate/BaseTemplate.tsx b/src/templates/BaseTemplate/BaseTemplate.tsx index aecf1cf..28ada8d 100644 --- a/src/templates/BaseTemplate/BaseTemplate.tsx +++ b/src/templates/BaseTemplate/BaseTemplate.tsx @@ -5,7 +5,6 @@ import type { RootState } from 'store/store' import { DefaultLayout, HeaderSecond, Footer, Sidebar, RowFlexGrow, FlexCol } from 'components' type TBaseTemplateProps = { - // withNoCluster?: boolean children?: ReactNode | undefined inside?: boolean isSearch?: boolean diff --git a/src/templates/MainLayout/MainLayout.tsx b/src/templates/MainLayout/MainLayout.tsx index e89ff53..12e3365 100644 --- a/src/templates/MainLayout/MainLayout.tsx +++ b/src/templates/MainLayout/MainLayout.tsx @@ -16,7 +16,7 @@ type TMainLayoutProps = { } export const MainLayout: FC = ({ children, forcedTheme }) => { - const { clusterName } = useParams() + const { cluster } = useParams() const { useToken } = antdtheme const { token } = useToken() const dispatch = useDispatch() @@ -66,17 +66,9 @@ export const MainLayout: FC = ({ children, forcedTheme }) => { } }, [clusterListQuery, dispatch]) - // if (clusterName) { - // dispatch(setCluster(clusterName)) - // } - - // if (clusterName === undefined) { - // dispatch(setCluster('')) - // } - useEffect(() => { - dispatch(setCluster(clusterName ?? '')) - }, [dispatch, clusterName]) + dispatch(setCluster(cluster ?? '')) + }, [dispatch, cluster]) return ( diff --git a/src/utils/getBacklink.ts b/src/utils/getBacklink.ts index a862354..7df34da 100644 --- a/src/utils/getBacklink.ts +++ b/src/utils/getBacklink.ts @@ -1,19 +1,19 @@ import { BASE_INSTANCES_API_GROUP, - BASE_INSTANCES_VERSION, - BASE_INSTANCES_RESOURCE_NAME, + BASE_INSTANCES_API_VERSION, + BASE_INSTANCES_PLURAL, } from 'constants/customizationApiGroupAndVersion' export const getFormsBackLink = ({ backLink, - clusterName, + cluster, possibleProject, possibleInstance, baseprefix, namespacesMode, }: { backLink?: string | null - clusterName?: string + cluster?: string possibleProject?: string possibleInstance?: string baseprefix?: string @@ -24,22 +24,22 @@ export const getFormsBackLink = ({ } if (possibleInstance) { - return `${baseprefix}/${clusterName}/${possibleInstance}/${possibleProject}/api-table/apps/v1/deployments` + return `${baseprefix}/${cluster}/${possibleInstance}/${possibleProject}/api-table/apps/v1/deployments` } if (namespacesMode) { - return `${baseprefix}/${clusterName}/builtin-table/namespaces` + return `${baseprefix}/${cluster}/builtin-table/namespaces` } if (possibleProject) { - return `${baseprefix}/clusters/${clusterName}/projects/${possibleProject}` + return `${baseprefix}/clusters/${cluster}/projects/${possibleProject}` } return `${baseprefix}/clusters` } export const getTablesBackLink = ({ - clusterName, + cluster, possibleProject, possibleInstance, namespace, @@ -47,7 +47,7 @@ export const getTablesBackLink = ({ inside, namespacesMode, }: { - clusterName?: string + cluster?: string possibleProject?: string possibleInstance?: string namespace?: string @@ -56,19 +56,19 @@ export const getTablesBackLink = ({ namespacesMode?: boolean }): string => { if (inside) { - return `${baseprefix}/inside/${clusterName}${namespace ? `/${namespace}` : ''}/apis` + return `${baseprefix}/inside/${cluster}${namespace ? `/${namespace}` : ''}/apis` } if (possibleInstance) { - return `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_INSTANCES_API_GROUP}/${BASE_INSTANCES_VERSION}/${BASE_INSTANCES_RESOURCE_NAME}` + return `${baseprefix}/${cluster}/${possibleProject}/api-table/${BASE_INSTANCES_API_GROUP}/${BASE_INSTANCES_API_VERSION}/${BASE_INSTANCES_PLURAL}` } if (namespacesMode) { - return `${baseprefix}/${clusterName}/builtin-table/namespaces` + return `${baseprefix}/${cluster}/builtin-table/namespaces` } if (possibleProject) { - return `${baseprefix}/clusters/${clusterName}/projects/${possibleProject}` + return `${baseprefix}/clusters/${cluster}/projects/${possibleProject}` } return `${baseprefix}/clusters`