diff --git a/package-lock.json b/package-lock.json index 9869ff4..7bcdf8c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "@ant-design/icons": "5.6.0", "@monaco-editor/react": "4.6.0", "@originjs/vite-plugin-federation": "1.3.6", - "@prorobotech/openapi-k8s-toolkit": "^0.0.1-alpha.129", + "@prorobotech/openapi-k8s-toolkit": "^0.0.1-alpha.137", "@readme/openapi-parser": "4.0.0", "@reduxjs/toolkit": "2.2.5", "@tanstack/react-query": "5.62.2", @@ -2804,9 +2804,9 @@ } }, "node_modules/@prorobotech/openapi-k8s-toolkit": { - "version": "0.0.1-alpha.129", - "resolved": "https://registry.npmjs.org/@prorobotech/openapi-k8s-toolkit/-/openapi-k8s-toolkit-0.0.1-alpha.129.tgz", - "integrity": "sha512-V5hrvOfbx7ZXCHu3sDYfvVKJPEbiymMk7Zb/1cQNfkyzjqvBB2JVRVEGVR9c6uyuWOHchBAMkiw2S5c5pm+yfQ==", + "version": "0.0.1-alpha.137", + "resolved": "https://registry.npmjs.org/@prorobotech/openapi-k8s-toolkit/-/openapi-k8s-toolkit-0.0.1-alpha.137.tgz", + "integrity": "sha512-40wpiC8aRBmXZiNnkqYjqo15UEjF9mowoSGqe1/xzxFdjjeZtSBoDoGhLMFy/j6QBCvgaYnNH7mYqxZg5MS7rg==", "license": "MIT", "dependencies": { "@monaco-editor/react": "4.6.0", diff --git a/package.json b/package.json index 4d22087..bff473d 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "@ant-design/icons": "5.6.0", "@monaco-editor/react": "4.6.0", "@originjs/vite-plugin-federation": "1.3.6", - "@prorobotech/openapi-k8s-toolkit": "0.0.1-alpha.129", + "@prorobotech/openapi-k8s-toolkit": "0.0.1-alpha.137", "@readme/openapi-parser": "4.0.0", "@reduxjs/toolkit": "2.2.5", "@tanstack/react-query": "5.62.2", diff --git a/src/App.tsx b/src/App.tsx index 4ea0d50..6711b2b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -30,6 +30,7 @@ import { } from 'pages' import { getBasePrefix } from 'utils/getBaseprefix' import { colorsLight, colorsDark, sizes } from 'constants/colors' +import { MainLayout } from 'templates/MainLayout' type TAppProps = { isFederation?: boolean @@ -54,87 +55,77 @@ export const App: FC = ({ isFederation, forcedTheme }) => { const renderRoutes = (prefix = '') => ( - } /> - } /> - } /> - } /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } - /> - } /> + }> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } + /> + } /> + } /> + ) diff --git a/src/components/molecules/TableApiBuiltin/TableApiBuiltin.tsx b/src/components/molecules/TableApiBuiltin/TableApiBuiltin.tsx index 853dccf..4a27a36 100644 --- a/src/components/molecules/TableApiBuiltin/TableApiBuiltin.tsx +++ b/src/components/molecules/TableApiBuiltin/TableApiBuiltin.tsx @@ -10,11 +10,12 @@ import { usePermissions, DeleteModal, DeleteModalMany, - checkIfBuiltInInstanceNamespaceScoped, - checkIfApiInstanceNamespaceScoped, + // checkIfBuiltInInstanceNamespaceScoped, + // checkIfApiInstanceNamespaceScoped, useBuiltinResources, useApiResources, Spacer, + getLinkToForm, } from '@prorobotech/openapi-k8s-toolkit' import { FlexGrow, PaddingContainer } from 'components' import { TABLE_PROPS } from 'constants/tableProps' @@ -27,13 +28,13 @@ import { TABLE_ADD_BUTTON_HEIGHT, } from 'constants/blocksSizes' import { OverflowContainer } from './atoms' -import { getDataItems, getBackLinkToTable, getLinkToForm } from './utils' +import { getDataItems } from './utils' type TTableApiBuiltinProps = { namespace?: string resourceType: 'builtin' | 'api' apiGroup?: string // api - apiVersion?: string // api + apiVersion: string // api typeName: string labels?: string[] fields?: string[] @@ -71,7 +72,8 @@ export const TableApiBuiltin: FC = ({ ) const [selectedRowKeys, setSelectedRowKeys] = useState([]) const [selectedRowsData, setSelectedRowsData] = useState<{ name: string; endpoint: string }[]>([]) - const [isNamespaced, setIsNamespaced] = useState() + // const [isNamespaced, setIsNamespaced] = useState() + // const [isNamespacedLoading, setIsNamespacedLoading] = useState() const [height, setHeight] = useState(0) @@ -97,58 +99,49 @@ export const TableApiBuiltin: FC = ({ } }, []) - useEffect(() => { - if (resourceType === 'builtin') { - checkIfBuiltInInstanceNamespaceScoped({ - typeName, - clusterName: cluster, - }).then(({ isNamespaceScoped }) => { - if (isNamespaceScoped) { - setIsNamespaced(isNamespaceScoped) - } - }) - } - if (resourceType === 'api' && apiGroup && apiVersion) { - checkIfApiInstanceNamespaceScoped({ - apiGroup, - apiVersion, - typeName, - clusterName: cluster, - }).then(({ isNamespaceScoped }) => { - if (isNamespaceScoped) { - setIsNamespaced(true) - } - }) - } - }, [resourceType, cluster, typeName, apiGroup, apiVersion]) + // 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({ - apiGroup: apiGroup || '', - typeName, - namespace: '', + group: apiGroup || undefined, + resource: typeName, + namespace: params.namespace, clusterName: cluster, verb: 'create', refetchInterval: false, }) - const updatePermission = usePermissions({ - apiGroup: apiGroup || '', - typeName, - namespace: '', - clusterName: cluster, - verb: 'update', - refetchInterval: false, - }) - - const deletePermission = usePermissions({ - apiGroup: apiGroup || '', - typeName, - namespace: '', - clusterName: cluster, - verb: 'delete', - refetchInterval: false, - }) - const { isPending: isPendingBuiltin, error: errorBuiltin, @@ -233,35 +226,26 @@ export const TableApiBuiltin: FC = ({ ...replaceValuesPartsOfUrls, }} cluster={cluster} + namespace={namespace} theme={theme} baseprefix={inside ? `${baseprefix}/inside` : baseprefix} dataItems={getDataItems({ resourceType, dataBuiltin, dataApi })} + k8sResource={{ + resource: typeName, + apiGroup, + apiVersion, + }} + // isNamespaced={isNamespaced} + // isNamespacedLoading={isNamespacedLoading} dataForControls={{ cluster, syntheticProject: params.syntheticProject, - pathPrefix: resourceType === 'builtin' ? 'forms/builtin' : 'forms/apis', - typeName, - apiVersion: resourceType === 'builtin' ? 'v1' : `${apiGroup}/${apiVersion}`, - backlink: getBackLinkToTable({ - resourceType, - cluster, - baseprefix, - namespace, - syntheticProject: params.syntheticProject, - apiGroup, - apiVersion, - typeName, - inside, - fullPath, - searchMount, - }), - deletePathPrefix: - resourceType === 'builtin' ? `/api/clusters/${cluster}/k8s/api` : `/api/clusters/${cluster}/k8s/apis`, + resource: typeName, + apiGroup, + apiVersion, + }} + dataForControlsInternal={{ onDeleteHandle, - permissions: { - canUpdate: isNamespaced ? true : updatePermission.data?.status.allowed, - canDelete: isNamespaced ? true : deletePermission.data?.status.allowed, - }, }} selectData={{ selectedRowKeys, @@ -271,7 +255,6 @@ export const TableApiBuiltin: FC = ({ }, }} tableProps={{ ...TABLE_PROPS, disablePagination: !searchMount }} - namespaceScopedWithoutNamespace={isNamespaced && !namespace} // maxHeight={height - 65} /> )} @@ -297,7 +280,6 @@ export const TableApiBuiltin: FC = ({ type="primary" onClick={() => { const url = getLinkToForm({ - resourceType, cluster, baseprefix, namespace, @@ -311,8 +293,10 @@ export const TableApiBuiltin: FC = ({ }) navigate(url) }} - loading={isNamespaced ? false : createPermission.isPending} - disabled={isNamespaced ? false : !createPermission.data?.status.allowed} + // loading={isNamespaced ? false : createPermission.isPending} + // disabled={isNamespaced ? false : !createPermission.data?.status.allowed} + loading={createPermission.isPending} + disabled={!createPermission.data?.status.allowed} > Add {kindName} diff --git a/src/components/molecules/TableApiBuiltin/utils.ts b/src/components/molecules/TableApiBuiltin/utils.ts index c0973b2..dde900f 100644 --- a/src/components/molecules/TableApiBuiltin/utils.ts +++ b/src/components/molecules/TableApiBuiltin/utils.ts @@ -11,178 +11,3 @@ export const getDataItems = ({ }): TJSON[] => { return resourceType === 'builtin' ? dataBuiltin?.items || [] : dataApi?.items || [] } - -export const getBackLinkToBuiltinTable = ({ - cluster, - baseprefix, - namespace, - syntheticProject, - typeName, - inside, - fullPath, - searchMount, -}: { - cluster: string - baseprefix?: string - namespace?: string - syntheticProject?: string - typeName: string - inside?: boolean - fullPath: string - searchMount?: boolean -}): string => { - if (searchMount) { - return encodeURIComponent(fullPath) - } - const root = `${baseprefix}${inside ? '/inside' : ''}/${cluster}` - const mainRoute = `${root}${namespace ? `/${namespace}` : ''}${syntheticProject ? `/${syntheticProject}` : ''}` - - return `${mainRoute}/builtin-table/${typeName}` -} - -export const getBackLinkToApiTable = ({ - cluster, - baseprefix, - namespace, - syntheticProject, - apiGroup, - apiVersion, - typeName, - inside, - fullPath, - searchMount, -}: { - cluster: string - baseprefix?: string - namespace?: string - syntheticProject?: string - apiGroup?: string // api - apiVersion?: string // api - typeName: string - inside?: boolean - fullPath: string - searchMount?: boolean -}): string => { - if (searchMount) { - return encodeURIComponent(fullPath) - } - - const root = `${baseprefix}${inside ? '/inside' : ''}/${cluster}` - const mainRoute = `${root}${namespace ? `/${namespace}` : ''}${syntheticProject ? `/${syntheticProject}` : ''}` - - return `${mainRoute}/api-table/${apiGroup}/${apiVersion}/${typeName}` -} - -export const getBackLinkToTable = ({ - resourceType, - ...rest -}: { - resourceType: 'builtin' | 'api' - cluster: string - baseprefix?: string - namespace?: string - syntheticProject?: string - apiGroup?: string // api - apiVersion?: string // api - typeName: string - inside?: boolean - fullPath: string - searchMount?: boolean -}): string => { - return resourceType === 'builtin' ? getBackLinkToBuiltinTable({ ...rest }) : getBackLinkToApiTable({ ...rest }) -} - -export const getLinkToBuiltinForm = ({ - cluster, - baseprefix, - namespace, - syntheticProject, - typeName, - inside, - fullPath, - searchMount, -}: { - cluster: string - baseprefix?: string - namespace?: string - syntheticProject?: string - typeName: string - inside?: boolean - fullPath: string - searchMount?: boolean -}): string => { - const root = `${baseprefix}${inside ? '/inside' : ''}/${cluster}` - const mainRoute = `${root}${namespace ? `/${namespace}` : ''}${syntheticProject ? `/${syntheticProject}` : ''}` - const backlink = getBackLinkToBuiltinTable({ - cluster, - baseprefix, - namespace, - syntheticProject, - typeName, - inside, - fullPath, - searchMount, - }) - - return `${mainRoute}/forms/builtin/v1/${typeName}?backlink=${backlink}` -} - -export const getLinkToApiForm = ({ - cluster, - baseprefix, - namespace, - syntheticProject, - apiGroup, - apiVersion, - typeName, - inside, - fullPath, - searchMount, -}: { - cluster: string - baseprefix?: string - namespace?: string - syntheticProject?: string - apiGroup?: string // api - apiVersion?: string // api - typeName: string - inside?: boolean - fullPath: string - searchMount?: boolean -}): string => { - const root = `${baseprefix}${inside ? '/inside' : ''}/${cluster}` - const mainRoute = `${root}${namespace ? `/${namespace}` : ''}${syntheticProject ? `/${syntheticProject}` : ''}` - const backlink = getBackLinkToApiTable({ - cluster, - baseprefix, - namespace, - syntheticProject, - apiGroup, - apiVersion, - typeName, - inside, - fullPath, - searchMount, - }) - - return `${mainRoute}/forms/apis/${apiGroup}/${apiVersion}/${typeName}?backlink=${backlink}` -} - -export const getLinkToForm = ({ - resourceType, - ...rest -}: { - resourceType: 'builtin' | 'api' - cluster: string - baseprefix?: string - namespace?: string - syntheticProject?: string - apiGroup?: string // api - apiVersion?: string // api - typeName: string - inside?: boolean - fullPath: string - searchMount?: boolean -}): string => { - return resourceType === 'builtin' ? getLinkToBuiltinForm({ ...rest }) : getLinkToApiForm({ ...rest }) -} diff --git a/src/components/molecules/TableCrdInfo/TableCrdInfo.tsx b/src/components/molecules/TableCrdInfo/TableCrdInfo.tsx index 9c079ae..fbd8519 100644 --- a/src/components/molecules/TableCrdInfo/TableCrdInfo.tsx +++ b/src/components/molecules/TableCrdInfo/TableCrdInfo.tsx @@ -50,8 +50,8 @@ export const TableCrdInfo: FC = ({ }, [cluster, data, isPending, error, apiGroup, apiVersion]) const createPermission = usePermissions({ - apiGroup, - typeName: data ? data.spec.names.singular : '', + group: apiGroup, + resource: data ? data.spec.names.singular : '', namespace: '', clusterName: cluster, verb: 'create', @@ -59,8 +59,8 @@ export const TableCrdInfo: FC = ({ }) const updatePermission = usePermissions({ - apiGroup, - typeName: data ? data.spec.names.singular : '', + group: apiGroup, + resource: data ? data.spec.names.singular : '', namespace: '', clusterName: cluster, verb: 'update', @@ -68,8 +68,8 @@ export const TableCrdInfo: FC = ({ }) const deletePermission = usePermissions({ - apiGroup, - typeName: data ? data.spec.names.singular : '', + group: apiGroup, + resource: data ? data.spec.names.singular : '', namespace: '', clusterName: cluster, verb: 'delete', diff --git a/src/components/molecules/TableCrdInfo/molecules/ResourceInfo/ResourceInfo.tsx b/src/components/molecules/TableCrdInfo/molecules/ResourceInfo/ResourceInfo.tsx index 15c914d..9f0d04b 100644 --- a/src/components/molecules/TableCrdInfo/molecules/ResourceInfo/ResourceInfo.tsx +++ b/src/components/molecules/TableCrdInfo/molecules/ResourceInfo/ResourceInfo.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unused-vars */ import React, { FC, useState, useEffect } from 'react' import { useLocation, useNavigate, useParams } from 'react-router-dom' import { Spin, Alert, Button, Flex } from 'antd' @@ -130,133 +131,135 @@ export const ResourceInfo: FC = ({ return acc }, {}) - return ( - <> - {isPending && } - {error && } - - {!error && data && ( - { - setSelectedRowKeys(selectedRowKeys) - setSelectedRowsData(selectedRowsData) - }, - }} - tableProps={{ ...TABLE_PROPS, disablePagination: true }} - // maxHeight={height - 65} - /> - )} - {/* {selectedRowKeys.length > 0 && ( - - - - - - - )} */} - - - - - - {selectedRowKeys.length > 0 && ( - - - - - )} - - - {isDeleteModalOpen && ( - { - setIsDeleteModalOpen(false) - clearSelected() - }} - endpoint={isDeleteModalOpen.endpoint} - /> - )} - {isDeleteModalManyOpen !== false && ( - { - setIsDeleteModalManyOpen(false) - clearSelected() - }} - /> - )} - - ) + return
Most likely deprecated
+ + // return ( + // <> + // {isPending && } + // {error && } + // + // {!error && data && ( + // { + // setSelectedRowKeys(selectedRowKeys) + // setSelectedRowsData(selectedRowsData) + // }, + // }} + // tableProps={{ ...TABLE_PROPS, disablePagination: true }} + // // maxHeight={height - 65} + // /> + // )} + // {/* {selectedRowKeys.length > 0 && ( + // + // + // + // + // + // + // )} */} + // + // + // + // + // + // {selectedRowKeys.length > 0 && ( + // + // + // + // + // )} + // + // + // {isDeleteModalOpen && ( + // { + // setIsDeleteModalOpen(false) + // clearSelected() + // }} + // endpoint={isDeleteModalOpen.endpoint} + // /> + // )} + // {isDeleteModalManyOpen !== false && ( + // { + // setIsDeleteModalManyOpen(false) + // clearSelected() + // }} + // /> + // )} + // + // ) } diff --git a/src/components/organisms/Header/organisms/User/User.tsx b/src/components/organisms/Header/organisms/User/User.tsx index 5565425..efe7ac3 100644 --- a/src/components/organisms/Header/organisms/User/User.tsx +++ b/src/components/organisms/Header/organisms/User/User.tsx @@ -25,7 +25,7 @@ export const User: FC = () => { // }, { key: '2', - label:
navigate(`${baseprefix}/inside`)}>Inside
, + label:
navigate(`${baseprefix}/inside/clusters`)}>Inside
, }, { key: '3', diff --git a/src/components/organisms/HeaderSecond/organisms/SelectorCluster/SelectorCluster.tsx b/src/components/organisms/HeaderSecond/organisms/SelectorCluster/SelectorCluster.tsx index e090ebf..00c75d7 100644 --- a/src/components/organisms/HeaderSecond/organisms/SelectorCluster/SelectorCluster.tsx +++ b/src/components/organisms/HeaderSecond/organisms/SelectorCluster/SelectorCluster.tsx @@ -38,7 +38,7 @@ export const SelectorCluster: FC = ({ clusterName }) => { Cluster: = ({ cluster Cluster: = ({ clusterName, namespac const navigate = useNavigate() const params = useParams() - const [selectedClusterName, setSelectedClusterName] = useState(clusterName) - const [selectedNamespace, setSelectedNamespace] = useState(namespace) + const [selectedClusterName, setSelectedClusterName] = useState(clusterName) + const [selectedNamespace, setSelectedNamespace] = useState(namespace) // const { namespacesInSidebar, clustersInSidebar } = useNavSelectorInside(selectedClusterName) const { namespacesInSidebar } = useNavSelectorInside(selectedClusterName) diff --git a/src/components/organisms/ListInsideClusterAndNs/ListInsideClusterAndNs.tsx b/src/components/organisms/ListInsideClusterAndNs/ListInsideClusterAndNs.tsx index 577ba0f..b6fb99f 100644 --- a/src/components/organisms/ListInsideClusterAndNs/ListInsideClusterAndNs.tsx +++ b/src/components/organisms/ListInsideClusterAndNs/ListInsideClusterAndNs.tsx @@ -18,9 +18,10 @@ export const ListInsideClusterAndNs: FC = () => { const [selectedNamespace, setSelectedNamespace] = useState() const namespacesData = useBuiltinResources({ - clusterName: cluster, + clusterName: selectedCluster || '', typeName: 'namespaces', limit: null, + isEnabled: selectedCluster !== undefined, }) return ( diff --git a/src/components/organisms/Search/molecules/SearchEntry/SearchEntry.tsx b/src/components/organisms/Search/molecules/SearchEntry/SearchEntry.tsx index 5f3cf6e..169bd9f 100644 --- a/src/components/organisms/Search/molecules/SearchEntry/SearchEntry.tsx +++ b/src/components/organisms/Search/molecules/SearchEntry/SearchEntry.tsx @@ -94,7 +94,7 @@ export const SearchEntry: FC = ({ resource, labels, fields, f resourceType={apiGroup.length > 0 ? 'api' : 'builtin'} namespace={isNamespaceResource ? namespace : undefined} apiGroup={apiGroup.length > 0 ? apiGroup : undefined} - apiVersion={apiGroup.length > 0 ? apiVersion : undefined} + apiVersion={apiVersion} typeName={typeName} labels={labels?.length ? labels : undefined} fields={fields?.length ? fields : undefined} diff --git a/src/hooks/useNavSelector/useNavSelector.ts b/src/hooks/useNavSelector/useNavSelector.ts index 6acb35d..4bc12ef 100644 --- a/src/hooks/useNavSelector/useNavSelector.ts +++ b/src/hooks/useNavSelector/useNavSelector.ts @@ -66,6 +66,7 @@ export const useNavSelector = (clusterName?: string, projectName?: string) => { apiVersion: BASE_PROJECTS_VERSION, typeName: BASE_PROJECTS_RESOURCE_NAME, limit: null, + isEnabled: clusterName !== undefined, }) const { data: instances, isSuccess: allInstancesLoadingSuccess } = useApiResources({ @@ -75,6 +76,7 @@ export const useNavSelector = (clusterName?: string, projectName?: string) => { apiVersion: BASE_INSTANCES_VERSION, typeName: BASE_INSTANCES_RESOURCE_NAME, limit: null, + isEnabled: clusterName !== undefined, }) const clustersInSidebar = clusterList ? clusterList.map(mappedClusterToOptionInSidebar) : [] diff --git a/src/hooks/useNavSelectorInside.ts b/src/hooks/useNavSelectorInside.ts index d69405e..5736e2b 100644 --- a/src/hooks/useNavSelectorInside.ts +++ b/src/hooks/useNavSelectorInside.ts @@ -19,6 +19,7 @@ export const useNavSelectorInside = (clusterName?: string) => { clusterName: clusterName || '', typeName: 'namespaces', limit: null, + isEnabled: Boolean(clusterName), }) const clustersInSidebar = clusterList ? clusterList.map(mappedClusterToOptionInSidebar) : [] diff --git a/src/pages/FactoryPage/FactoryPage.tsx b/src/pages/FactoryPage/FactoryPage.tsx index 6ceb1fb..ad6c8e6 100644 --- a/src/pages/FactoryPage/FactoryPage.tsx +++ b/src/pages/FactoryPage/FactoryPage.tsx @@ -5,11 +5,7 @@ import { getBreadcrumbsIdPrefix } from 'utils/getBreadcrumbsIdPrefix' import { getSidebarIdPrefix } from 'utils/getSidebarIdPrefix' import { BaseTemplate } from 'templates' -type TFactoryPageProps = { - forcedTheme?: 'light' | 'dark' -} - -export const FactoryPage: FC = ({ forcedTheme }) => { +export const FactoryPage: FC = () => { const { namespace, syntheticProject, key } = useParams() const [currentTags, setCurrentTags] = useState() @@ -29,7 +25,6 @@ export const FactoryPage: FC = ({ forcedTheme }) => { return ( = ({ forcedTheme }) => { currentTags={currentTags} /> } - withNoCluster + // withNoCluster > diff --git a/src/pages/FormApiPage/FormApiPage.tsx b/src/pages/FormApiPage/FormApiPage.tsx index 96cf7d4..aa623dc 100644 --- a/src/pages/FormApiPage/FormApiPage.tsx +++ b/src/pages/FormApiPage/FormApiPage.tsx @@ -18,11 +18,10 @@ import { BASE_USE_NAMESPACE_NAV } from 'constants/customizationApiGroupAndVersio import { BaseTemplate } from 'templates' type TFormApiPageProps = { - forcedTheme?: 'light' | 'dark' inside?: boolean } -export const FormApiPage: FC = ({ forcedTheme, inside }) => { +export const FormApiPage: FC = ({ inside }) => { const { clusterName, syntheticProject, namespace, apiGroup, apiVersion, typeName, entryName } = useParams() const [searchParams] = useSearchParams() const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) @@ -54,7 +53,6 @@ export const FormApiPage: FC = ({ forcedTheme, inside }) => { return ( = ({ forcedTheme, inside }) => { +export const FormBuiltinPage: FC = ({ inside }) => { const { clusterName, syntheticProject, namespace, typeName, entryName } = useParams() const [searchParams] = useSearchParams() const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) @@ -54,7 +53,6 @@ export const FormBuiltinPage: FC = ({ forcedTheme, inside return ( = ({ forcedTheme, inside }) => { +export const FormCrdPage: FC = ({ inside }) => { const { clusterName, syntheticProject, apiGroup, apiVersion, namespace, typeName, entryName } = useParams() const [searchParams] = useSearchParams() const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) @@ -54,7 +53,6 @@ export const FormCrdPage: FC = ({ forcedTheme, inside }) => { return ( = ({ forcedTheme }) => { +export const ListClustersPage: FC = () => { const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) const breadcrumbItems = [ @@ -26,7 +22,7 @@ export const ListClustersPage: FC = ({ forcedTheme }) => ] return ( - + diff --git a/src/pages/ListInsideApiByApiGroupPage/ListInsideApiByApiGroupPage.tsx b/src/pages/ListInsideApiByApiGroupPage/ListInsideApiByApiGroupPage.tsx index 4f8950a..bb5f561 100644 --- a/src/pages/ListInsideApiByApiGroupPage/ListInsideApiByApiGroupPage.tsx +++ b/src/pages/ListInsideApiByApiGroupPage/ListInsideApiByApiGroupPage.tsx @@ -7,18 +7,17 @@ import { getBreadcrumbsIdPrefix } from 'utils/getBreadcrumbsIdPrefix' import { BaseTemplate } from 'templates' type TListInsideApiByApiGroupPageProps = { - forcedTheme?: 'light' | 'dark' inside?: boolean } -export const ListInsideApiByApiGroupPage: FC = ({ forcedTheme, inside }) => { +export const ListInsideApiByApiGroupPage: FC = ({ inside }) => { const { namespace, apiGroup, apiVersion } = useParams() const sidebarId = `${getSidebarIdPrefix({ namespace: !!namespace, inside })}api-by-api` const breadcrumbsId = `${getBreadcrumbsIdPrefix({ namespace: !!namespace, inside })}api-by-api` return ( - }> + }> diff --git a/src/pages/ListInsideApiPage/ListInsideApiPage.tsx b/src/pages/ListInsideApiPage/ListInsideApiPage.tsx index b38c085..9e5ae09 100644 --- a/src/pages/ListInsideApiPage/ListInsideApiPage.tsx +++ b/src/pages/ListInsideApiPage/ListInsideApiPage.tsx @@ -7,18 +7,17 @@ import { getBreadcrumbsIdPrefix } from 'utils/getBreadcrumbsIdPrefix' import { BaseTemplate } from 'templates' type TListInsideApiPageProps = { - forcedTheme?: 'light' | 'dark' inside?: boolean } -export const ListInsideApiPage: FC = ({ forcedTheme, inside }) => { +export const ListInsideApiPage: FC = ({ inside }) => { const { namespace } = useParams() const sidebarId = `${getSidebarIdPrefix({ namespace: !!namespace, inside })}apis` const breadcrumbsId = `${getBreadcrumbsIdPrefix({ namespace: !!namespace, inside })}apis` return ( - }> + }> diff --git a/src/pages/ListInsideClustersAndNsPage/ListInsideClustersAndNsPage.tsx b/src/pages/ListInsideClustersAndNsPage/ListInsideClustersAndNsPage.tsx index ded39d0..35ab413 100644 --- a/src/pages/ListInsideClustersAndNsPage/ListInsideClustersAndNsPage.tsx +++ b/src/pages/ListInsideClustersAndNsPage/ListInsideClustersAndNsPage.tsx @@ -8,11 +8,10 @@ import { ListInsideClusterAndNs, NavigationContainer } from 'components' import { BaseTemplate } from 'templates' type TListInsideClustersAndNsPageProps = { - forcedTheme?: 'light' | 'dark' inside?: boolean } -export const ListInsideClustersAndNsPage: FC = ({ forcedTheme, inside }) => { +export const ListInsideClustersAndNsPage: FC = ({ inside }) => { const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) const breadcrumbItems = [ @@ -27,7 +26,7 @@ export const ListInsideClustersAndNsPage: FC ] return ( - + diff --git a/src/pages/ListInsideCrdByApiGroupPage/ListInsideCrdByApiGroupPage.tsx b/src/pages/ListInsideCrdByApiGroupPage/ListInsideCrdByApiGroupPage.tsx index 37796a9..19cd151 100644 --- a/src/pages/ListInsideCrdByApiGroupPage/ListInsideCrdByApiGroupPage.tsx +++ b/src/pages/ListInsideCrdByApiGroupPage/ListInsideCrdByApiGroupPage.tsx @@ -7,18 +7,17 @@ import { getBreadcrumbsIdPrefix } from 'utils/getBreadcrumbsIdPrefix' import { BaseTemplate } from 'templates' type TListInsideCrdByApiGroupPageProps = { - forcedTheme?: 'light' | 'dark' inside?: boolean } -export const ListInsideCrdByApiGroupPage: FC = ({ forcedTheme, inside }) => { +export const ListInsideCrdByApiGroupPage: FC = ({ inside }) => { const { namespace, apiGroup, apiVersion, apiExtensionVersion } = useParams() const sidebarId = `${getSidebarIdPrefix({ namespace: !!namespace, inside })}crd-by-api` const breadcrumbsId = `${getBreadcrumbsIdPrefix({ namespace: !!namespace, inside })}crd-by-api` return ( - }> + }> diff --git a/src/pages/ListProjectsPage/ListProjectsPage.tsx b/src/pages/ListProjectsPage/ListProjectsPage.tsx index 1b9c9e4..1d02c38 100644 --- a/src/pages/ListProjectsPage/ListProjectsPage.tsx +++ b/src/pages/ListProjectsPage/ListProjectsPage.tsx @@ -2,13 +2,9 @@ import React, { FC } from 'react' import { RedirectProjectList } from 'components' import { BaseTemplate } from 'templates' -type TListProjectsPageProps = { - forcedTheme?: 'light' | 'dark' -} - -export const ListProjectsPage: FC = ({ forcedTheme }) => { +export const ListProjectsPage: FC = () => { return ( - + ) diff --git a/src/pages/MainPage/MainPage.tsx b/src/pages/MainPage/MainPage.tsx index 11602d3..ec24134 100644 --- a/src/pages/MainPage/MainPage.tsx +++ b/src/pages/MainPage/MainPage.tsx @@ -2,16 +2,12 @@ import React, { FC, useEffect } from 'react' import { useNavigate } from 'react-router-dom' import { BaseTemplate } from 'templates' -type TMainPageProps = { - forcedTheme?: 'light' | 'dark' -} - -export const MainPage: FC = ({ forcedTheme }) => { +export const MainPage: FC = () => { const navigate = useNavigate() useEffect(() => { navigate('./clusters') }, [navigate]) - return + return } diff --git a/src/pages/ProjectInfoPage/ProjectInfoPage.tsx b/src/pages/ProjectInfoPage/ProjectInfoPage.tsx index 8438dc7..f205d63 100644 --- a/src/pages/ProjectInfoPage/ProjectInfoPage.tsx +++ b/src/pages/ProjectInfoPage/ProjectInfoPage.tsx @@ -2,13 +2,9 @@ import React, { FC } from 'react' import { RedirectProjectInfo } from 'components' import { BaseTemplate } from 'templates' -type TProjectInfoPageProps = { - forcedTheme?: 'light' | 'dark' -} - -export const ProjectInfoPage: FC = ({ forcedTheme }) => { +export const ProjectInfoPage: FC = () => { return ( - + ) diff --git a/src/pages/SearchPage/SearchPage.tsx b/src/pages/SearchPage/SearchPage.tsx index c69ed59..33e3e24 100644 --- a/src/pages/SearchPage/SearchPage.tsx +++ b/src/pages/SearchPage/SearchPage.tsx @@ -6,11 +6,7 @@ import { getSidebarIdPrefix } from 'utils/getSidebarIdPrefix' import { getBreadcrumbsIdPrefix } from 'utils/getBreadcrumbsIdPrefix' import { BaseTemplate } from 'templates' -type TSearchPageProps = { - forcedTheme?: 'light' | 'dark' -} - -export const SearchPage: FC = ({ forcedTheme }) => { +export const SearchPage: FC = () => { const { namespace, syntheticProject } = useParams() const possibleProject = syntheticProject && namespace ? syntheticProject : namespace @@ -28,7 +24,6 @@ export const SearchPage: FC = ({ forcedTheme }) => { return ( = ({ forcedTheme, inside }) => { +export const TableApiPage: FC = ({ inside }) => { const { clusterName, namespace, syntheticProject, apiGroup, apiVersion, typeName } = useParams() const [searchParams] = useSearchParams() const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) @@ -62,7 +61,6 @@ export const TableApiPage: FC = ({ forcedTheme, inside }) => return ( = ({ forcedTheme, inside }) => apiGroup={apiGroup} apiVersion={apiVersion} typeName={typeName} + key={`${apiGroup}-${apiVersion}-${namespace}-${typeName}`} limit={searchParams.get('limit')} inside={inside} customizationIdPrefix={tableCustomizationIdPrefix} diff --git a/src/pages/TableBuiltinPage/TableBuiltinPage.tsx b/src/pages/TableBuiltinPage/TableBuiltinPage.tsx index 03ad1da..d36f48b 100644 --- a/src/pages/TableBuiltinPage/TableBuiltinPage.tsx +++ b/src/pages/TableBuiltinPage/TableBuiltinPage.tsx @@ -12,11 +12,10 @@ import { BaseTemplate } from 'templates' import { BASE_USE_NAMESPACE_NAV } from 'constants/customizationApiGroupAndVersion' type TTableBuiltinPageProps = { - forcedTheme?: 'light' | 'dark' inside?: boolean } -export const TableBuiltinPage: FC = ({ forcedTheme, inside }) => { +export const TableBuiltinPage: FC = ({ inside }) => { const { clusterName, namespace, syntheticProject, typeName } = useParams() const [searchParams] = useSearchParams() const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) @@ -49,7 +48,6 @@ export const TableBuiltinPage: FC = ({ forcedTheme, insi return ( = ({ forcedTheme, insi {typeName && ( = ({ forcedTheme, inside }) => { +export const TableCrdPage: FC = ({ inside }) => { const { clusterName, namespace, syntheticProject, apiGroup, apiVersion, apiExtensionVersion, crdName } = useParams() const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) @@ -48,7 +47,6 @@ export const TableCrdPage: FC = ({ forcedTheme, inside }) => return ( = ({ - children, - withNoCluster, - forcedTheme, - inside, - isSearch, - sidebar, -}) => { - const navigate = useNavigate() - const { clusterName } = useParams() - const { useToken } = antdtheme - const { token } = useToken() - const dispatch = useDispatch() - const theme = useSelector((state: RootState) => state.openapiTheme.theme) +export const BaseTemplate: FC = ({ children, inside, isSearch, sidebar }) => { const isFederation = useSelector((state: RootState) => state.federation.isFederation) - const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix) - const clusterListQuery = useClusterList({ refetchInterval: false }) - - useEffect(() => { - if (forcedTheme) { - return - } - const localStorageTheme = localStorage.getItem('theme') - if (localStorageTheme && (localStorageTheme === 'dark' || localStorageTheme === 'light')) { - dispatch(setTheme(localStorageTheme)) - } else if (window.matchMedia('(prefers-color-scheme: dark)').matches) { - localStorage.setItem('theme', 'dark') - dispatch(setTheme('dark')) - } else { - localStorage.setItem('theme', 'light') - dispatch(setTheme('light')) - } - }, [dispatch, forcedTheme]) - - useEffect(() => { - if (forcedTheme) { - dispatch(setTheme(forcedTheme)) - } - }, [dispatch, forcedTheme]) - - const handleStorage = useCallback(() => { - const localStorageTheme = localStorage.getItem('theme') - if (localStorageTheme && (localStorageTheme === 'dark' || localStorageTheme === 'light')) { - dispatch(setTheme(localStorageTheme)) - } - }, [dispatch]) - - useEffect(() => { - window.addEventListener('storage', handleStorage) - - return () => { - window.removeEventListener('storage', handleStorage) - } - }, [handleStorage]) - - useEffect(() => { - if (clusterListQuery.data) { - dispatch(setClusterList(clusterListQuery.data)) - } - }, [clusterListQuery, dispatch]) - - if (clusterName) { - dispatch(setCluster(clusterName)) - } - - if (clusterName === undefined) { - dispatch(setCluster('')) - } - - if (!clusterName && !withNoCluster) { - navigate(`${baseprefix}/`) - } return ( - - - - - -
- - - - - - - - {clusterListQuery.error && ( - - )} - {children} - -