mirror of
https://github.com/outbackdingo/openapi-ui.git
synced 2026-01-27 10:19:49 +00:00
sync naming
This commit is contained in:
30
src/App.tsx
30
src/App.tsx
@@ -59,29 +59,29 @@ export const App: FC<TAppProps> = ({ isFederation, forcedTheme }) => {
|
||||
<Route path={`${prefix}/`} element={<MainPage />} />
|
||||
<Route path={`${prefix}/clusters`} element={<ListClustersPage />} />
|
||||
|
||||
<Route path={`${prefix}/:clusterName/:namespace?/:syntheticProject?/*`} element={<AppShell />}>
|
||||
<Route path={`${prefix}/:cluster/:namespace?/:syntheticProject?/*`} element={<AppShell />}>
|
||||
{/* <Route path="crd-table/:apiGroup/:apiVersion/:apiExtensionVersion/:crdName" element={<TableCrdPage />} /> */}
|
||||
<Route path="api-table/:apiGroup/:apiVersion/:typeName" element={<TableApiPage />} />
|
||||
<Route path="builtin-table/:typeName" element={<TableBuiltinPage />} />
|
||||
{/* <Route path="forms/crds/:apiGroup/:apiVersion/:typeName/:entryName?/"" element={<FormCrdPage />} /> */}
|
||||
<Route path="forms/apis/:apiGroup/:apiVersion/:typeName/:entryName?/" element={<FormApiPage />} />
|
||||
<Route path="forms/builtin/:apiVersion/:typeName/:entryName?/" element={<FormBuiltinPage />} />
|
||||
<Route path="api-table/:apiGroup/:apiVersion/:plural" element={<TableApiPage />} />
|
||||
<Route path="builtin-table/:plural" element={<TableBuiltinPage />} />
|
||||
{/* <Route path="forms/crds/:apiGroup/:apiVersion/:plural/:name?/"" element={<FormCrdPage />} /> */}
|
||||
<Route path="forms/apis/:apiGroup/:apiVersion/:plural/:name?/" element={<FormApiPage />} />
|
||||
<Route path="forms/builtin/:apiVersion/:plural/:name?/" element={<FormBuiltinPage />} />
|
||||
<Route path="factory/:key/*" element={<FactoryPage />} />
|
||||
<Route path="search/*" element={<SearchPage />} />
|
||||
</Route>
|
||||
|
||||
<Route path={`${prefix}/inside/:clusterName/:namespace?/:syntheticProject?/*`} element={<AppShell inside />}>
|
||||
<Route path={`${prefix}/inside/:cluster/:namespace?/:syntheticProject?/*`} element={<AppShell inside />}>
|
||||
{/* <Route path="crd-table/:apiGroup/:apiVersion/:apiExtensionVersion/:crdName" element={<TableCrdPage inside />} /> */}
|
||||
<Route path="api-table/:apiGroup/:apiVersion/:typeName" element={<TableApiPage inside />} />
|
||||
<Route path="builtin-table/:typeName" element={<TableBuiltinPage inside />} />
|
||||
{/* <Route path="forms/crds/:apiGroup/:apiVersion/:typeName/:entryName?/"" element={<FormCrdPage />} /> */}
|
||||
<Route path="forms/builtin/:apiVersion/:typeName/:entryName?/" element={<FormBuiltinPage />} />
|
||||
<Route path="forms/apis/:apiGroup/:apiVersion/:typeName/:entryName?/" element={<FormApiPage />} />
|
||||
<Route path="api-table/:apiGroup/:apiVersion/:plural" element={<TableApiPage inside />} />
|
||||
<Route path="builtin-table/:plural" element={<TableBuiltinPage inside />} />
|
||||
{/* <Route path="forms/crds/:apiGroup/:apiVersion/:plural/:name?/"" element={<FormCrdPage />} /> */}
|
||||
<Route path="forms/builtin/:apiVersion/:plural/:name?/" element={<FormBuiltinPage />} />
|
||||
<Route path="forms/apis/:apiGroup/:apiVersion/:plural/:name?/" element={<FormApiPage />} />
|
||||
</Route>
|
||||
|
||||
<Route path={`${prefix}/inside/`} element={<MainPage />} />
|
||||
<Route path={`${prefix}/inside/clusters`} element={<ListInsideClustersAndNsPage inside />} />
|
||||
<Route path={`${prefix}/inside/:clusterName/:namespace?/*`} element={<AppShell inside />}>
|
||||
<Route path={`${prefix}/inside/:cluster/:namespace?/*`} element={<AppShell inside />}>
|
||||
<Route path="apis" element={<ListInsideApiPage />} />
|
||||
<Route
|
||||
path="crds-by-api/:apiGroup/:apiVersion/:apiExtensionVersion"
|
||||
@@ -90,8 +90,8 @@ export const App: FC<TAppProps> = ({ isFederation, forcedTheme }) => {
|
||||
<Route path="apis-by-api/:apiGroup/:apiVersion/" element={<ListInsideApiByApiGroupPage />} />
|
||||
</Route>
|
||||
|
||||
<Route path={`${prefix}/clusters/:clusterName`} element={<RedirectProjectsPage />} />
|
||||
<Route path={`${prefix}/clusters/:clusterName/projects/:namespace`} element={<RedirectProjectInfoPage />} />
|
||||
<Route path={`${prefix}/clusters/:cluster`} element={<RedirectProjectsPage />} />
|
||||
<Route path={`${prefix}/clusters/:cluster/projects/:namespace`} element={<RedirectProjectInfoPage />} />
|
||||
</Route>
|
||||
</Routes>
|
||||
)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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<TBlackholeFormProps> = ({ 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 (
|
||||
|
||||
@@ -12,13 +12,13 @@ export const ManageableBreadcrumbs: FC<TManageableBreadCrumbsProps> = ({ 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<TManageableBreadCrumbsProps> = ({ idToCom
|
||||
return (
|
||||
<ManageableBreadcrumbsProvider
|
||||
idToCompare={idToCompare}
|
||||
cluster={clusterName}
|
||||
cluster={cluster}
|
||||
apiGroup={BASE_API_GROUP}
|
||||
apiVersion={BASE_API_VERSION}
|
||||
plural={inside ? 'breadcrumbsinsides' : 'breadcrumbs'}
|
||||
isEnabled={clusterName !== undefined}
|
||||
isEnabled={cluster !== undefined}
|
||||
replaceValues={{
|
||||
clusterName,
|
||||
cluster,
|
||||
projectName: '',
|
||||
instanceName: '',
|
||||
namespace,
|
||||
@@ -46,8 +46,8 @@ export const ManageableBreadcrumbs: FC<TManageableBreadCrumbsProps> = ({ idToCom
|
||||
entryType: '',
|
||||
apiGroup,
|
||||
apiVersion,
|
||||
typeName,
|
||||
entryName,
|
||||
plural,
|
||||
name,
|
||||
apiExtensionVersion,
|
||||
crdName,
|
||||
...replaceValuesPartsOfUrls,
|
||||
|
||||
@@ -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<TManageableSidebarProps> = ({
|
||||
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<TManageableSidebarProps> = ({
|
||||
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<TManageableSidebarProps> = ({
|
||||
$maxHeight={height}
|
||||
>
|
||||
<ManageableSidebarProvider
|
||||
cluster={clusterName}
|
||||
cluster={cluster}
|
||||
apiGroup={BASE_API_GROUP}
|
||||
apiVersion={BASE_API_VERSION}
|
||||
plural="sidebars"
|
||||
isEnabled={clusterName !== undefined}
|
||||
isEnabled={cluster !== undefined}
|
||||
replaceValues={{
|
||||
clusterName,
|
||||
cluster,
|
||||
projectName,
|
||||
instanceName,
|
||||
namespace,
|
||||
|
||||
@@ -10,8 +10,6 @@ import {
|
||||
usePermissions,
|
||||
DeleteModal,
|
||||
DeleteModalMany,
|
||||
// checkIfBuiltInInstanceNamespaceScoped,
|
||||
// checkIfApiInstanceNamespaceScoped,
|
||||
useK8sSmartResource,
|
||||
Spacer,
|
||||
getLinkToForm,
|
||||
@@ -28,14 +26,13 @@ import {
|
||||
TABLE_ADD_BUTTON_HEIGHT,
|
||||
} from 'constants/blocksSizes'
|
||||
import { OverflowContainer } from './atoms'
|
||||
// import { getDataItems } from './utils'
|
||||
|
||||
type TTableApiBuiltinProps = {
|
||||
namespace?: string
|
||||
resourceType: 'builtin' | 'api'
|
||||
apiGroup?: string // api
|
||||
apiVersion: string // api
|
||||
typeName: string
|
||||
plural: string
|
||||
labels?: string[]
|
||||
fields?: string[]
|
||||
limit?: number
|
||||
@@ -50,7 +47,7 @@ export const TableApiBuiltin: FC<TTableApiBuiltinProps> = ({
|
||||
resourceType,
|
||||
apiGroup,
|
||||
apiVersion,
|
||||
typeName,
|
||||
plural,
|
||||
labels,
|
||||
fields,
|
||||
limit,
|
||||
@@ -72,8 +69,6 @@ export const TableApiBuiltin: FC<TTableApiBuiltinProps> = ({
|
||||
)
|
||||
const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([])
|
||||
const [selectedRowsData, setSelectedRowsData] = useState<{ name: string; endpoint: string }[]>([])
|
||||
// const [isNamespaced, setIsNamespaced] = useState<boolean>()
|
||||
// const [isNamespacedLoading, setIsNamespacedLoading] = useState<boolean>()
|
||||
|
||||
const [height, setHeight] = useState(0)
|
||||
|
||||
@@ -99,45 +94,11 @@ export const TableApiBuiltin: FC<TTableApiBuiltinProps> = ({
|
||||
}
|
||||
}, [])
|
||||
|
||||
// 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<TTableApiBuiltinProps> = ({
|
||||
} = 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<TTableApiBuiltinProps> = ({
|
||||
<OverflowContainer height={height} searchMount={searchMount}>
|
||||
{!error && dataItems && (
|
||||
<EnrichedTableProvider
|
||||
key={resourceType === 'builtin' ? `/v1/${typeName}` : `/${apiGroup}/${apiVersion}/${typeName}`}
|
||||
key={resourceType === 'builtin' ? `/v1/${plural}` : `/${apiGroup}/${apiVersion}/${plural}`}
|
||||
customizationId={
|
||||
resourceType === 'builtin'
|
||||
? `${customizationIdPrefix}/v1/${typeName}`
|
||||
: `${customizationIdPrefix}/${apiGroup}/${apiVersion}/${typeName}`
|
||||
? `${customizationIdPrefix}/v1/${plural}`
|
||||
: `${customizationIdPrefix}/${apiGroup}/${apiVersion}/${plural}`
|
||||
}
|
||||
tableMappingsReplaceValues={{
|
||||
clusterName: params.clusterName,
|
||||
cluster: params.cluster,
|
||||
projectName: params.projectName,
|
||||
instanceName: params.instanceName,
|
||||
namespace: params.namespace,
|
||||
@@ -197,8 +158,8 @@ export const TableApiBuiltin: FC<TTableApiBuiltinProps> = ({
|
||||
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<TTableApiBuiltinProps> = ({
|
||||
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<TTableApiBuiltinProps> = ({
|
||||
},
|
||||
}}
|
||||
tableProps={{ ...TABLE_PROPS, disablePagination: !searchMount }}
|
||||
// maxHeight={height - 65}
|
||||
/>
|
||||
)}
|
||||
{/* {selectedRowKeys.length > 0 && (
|
||||
<MarginTopContainer $top={-40}>
|
||||
<Flex gap={16}>
|
||||
<Button type="primary" onClick={clearSelected}>
|
||||
<ClearOutlined />
|
||||
Clear
|
||||
</Button>
|
||||
<Button type="primary" onClick={() => setIsDeleteModalManyOpen(selectedRowsData)}>
|
||||
<MinusOutlined />
|
||||
Delete
|
||||
</Button>
|
||||
</Flex>
|
||||
</MarginTopContainer>
|
||||
)} */}
|
||||
</OverflowContainer>
|
||||
{searchMount ? <Spacer $space={12} $samespace /> : <FlexGrow />}
|
||||
<PaddingContainer $padding="4px">
|
||||
@@ -264,15 +208,13 @@ export const TableApiBuiltin: FC<TTableApiBuiltinProps> = ({
|
||||
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}
|
||||
>
|
||||
|
||||
@@ -34,12 +34,6 @@ export const TableCrdInfo: FC<TTableCrdInfoProps> = ({
|
||||
|
||||
const [isNamespaced, setIsNamespaced] = useState<boolean>()
|
||||
|
||||
// const { isPending, error, data } = useCrdData({
|
||||
// clusterName: cluster,
|
||||
// crdName,
|
||||
// apiExtensionVersion,
|
||||
// })
|
||||
|
||||
const {
|
||||
data: dataArr,
|
||||
isLoading: isPending,
|
||||
@@ -48,8 +42,8 @@ export const TableCrdInfo: FC<TTableCrdInfoProps> = ({
|
||||
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<TTableCrdInfoProps> = ({
|
||||
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<TTableCrdInfoProps> = ({
|
||||
}, [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<TTableCrdInfoProps> = ({
|
||||
)}
|
||||
{!error && data && data.spec && (
|
||||
<ResourceInfo
|
||||
clusterName={cluster}
|
||||
cluster={cluster}
|
||||
namespace={namespace}
|
||||
crdName={crdName}
|
||||
crdPluralName={data.spec.names.plural}
|
||||
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
} from 'constants/blocksSizes'
|
||||
|
||||
type TResourceInfoProps = {
|
||||
clusterName: string
|
||||
cluster: string
|
||||
namespace?: string
|
||||
crdName: string
|
||||
crdPluralName: string
|
||||
@@ -44,7 +44,7 @@ type TResourceInfoProps = {
|
||||
}
|
||||
|
||||
export const ResourceInfo: FC<TResourceInfoProps> = ({
|
||||
clusterName,
|
||||
cluster,
|
||||
namespace,
|
||||
crdName,
|
||||
crdPluralName,
|
||||
@@ -59,7 +59,6 @@ export const ResourceInfo: FC<TResourceInfoProps> = ({
|
||||
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<TResourceInfoProps> = ({
|
||||
}
|
||||
}, [])
|
||||
|
||||
// const { isPending, error, data } = useCrdResources({
|
||||
// clusterName,
|
||||
// namespace,
|
||||
// apiGroup,
|
||||
// apiVersion,
|
||||
// crdName: crdPluralName,
|
||||
// })
|
||||
|
||||
const {
|
||||
data,
|
||||
isLoading: isPending,
|
||||
@@ -109,9 +100,9 @@ export const ResourceInfo: FC<TResourceInfoProps> = ({
|
||||
} = useK8sSmartResource<{
|
||||
items: TJSON[]
|
||||
}>({
|
||||
cluster: clusterName,
|
||||
group: apiGroup,
|
||||
version: apiVersion,
|
||||
cluster,
|
||||
apiGroup,
|
||||
apiVersion,
|
||||
plural: crdPluralName,
|
||||
})
|
||||
|
||||
@@ -158,7 +149,7 @@ export const ResourceInfo: FC<TResourceInfoProps> = ({
|
||||
// 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<TResourceInfoProps> = ({
|
||||
// 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<TResourceInfoProps> = ({
|
||||
// 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,
|
||||
|
||||
@@ -4,7 +4,6 @@ import {
|
||||
DynamicComponents,
|
||||
DynamicRendererWithProviders,
|
||||
TDynamicComponentsAppTypeMap,
|
||||
// useDirectUnknownResource,
|
||||
useK8sSmartResource,
|
||||
TFactoryResponse,
|
||||
ContentCard,
|
||||
@@ -45,16 +44,10 @@ export const Factory: FC<TFactoryProps> = ({ setSidebarTags }) => {
|
||||
}
|
||||
}, [])
|
||||
|
||||
// const { data: factoryData } = useDirectUnknownResource<TFactoryResponse<TDynamicComponentsAppTypeMap>>({
|
||||
// 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<TFactoryResponse<TDynamicComponentsAppTypeMap>>({
|
||||
cluster,
|
||||
group: BASE_API_GROUP,
|
||||
version: BASE_API_VERSION,
|
||||
apiGroup: BASE_API_GROUP,
|
||||
apiVersion: BASE_API_VERSION,
|
||||
plural: 'factories',
|
||||
})
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ type TCreateApisFormProps = {
|
||||
namespace?: string
|
||||
apiGroup: string
|
||||
apiVersion: string
|
||||
typeName: string
|
||||
plural: string
|
||||
backLink?: string | null
|
||||
}
|
||||
|
||||
export const CreateApisForm: FC<TCreateApisFormProps> = ({ namespace, apiGroup, apiVersion, typeName, backLink }) => {
|
||||
export const CreateApisForm: FC<TCreateApisFormProps> = ({ namespace, apiGroup, apiVersion, plural, backLink }) => {
|
||||
const [currentMode, setCurrentMode] = useState<string>('OpenAPI')
|
||||
const [currentModeDisabled, setCurrentModeDisabled] = useState<boolean>(false)
|
||||
|
||||
@@ -45,10 +45,10 @@ export const CreateApisForm: FC<TCreateApisFormProps> = ({ 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}
|
||||
|
||||
@@ -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<TUpdateApisFormProps> = ({
|
||||
apiGroup,
|
||||
apiVersion,
|
||||
typeName,
|
||||
entryName,
|
||||
plural,
|
||||
name,
|
||||
namespace,
|
||||
backLink,
|
||||
}) => {
|
||||
@@ -42,12 +42,12 @@ export const UpdateApisForm: FC<TUpdateApisFormProps> = ({
|
||||
}
|
||||
|
||||
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<TUpdateApisFormProps> = ({
|
||||
return <Alert message={`An error has occurred: ${error?.message} `} type="error" />
|
||||
}
|
||||
|
||||
/* 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<TUpdateApisFormProps> = ({
|
||||
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}
|
||||
/>
|
||||
|
||||
@@ -5,11 +5,11 @@ import { BlackholeForm } from 'components'
|
||||
|
||||
type TCreateBuiltinFormProps = {
|
||||
namespace?: string
|
||||
typeName: string
|
||||
plural: string
|
||||
backLink?: string | null
|
||||
}
|
||||
|
||||
export const CreateBuiltinForm: FC<TCreateBuiltinFormProps> = ({ namespace, typeName, backLink }) => {
|
||||
export const CreateBuiltinForm: FC<TCreateBuiltinFormProps> = ({ namespace, plural, backLink }) => {
|
||||
const [currentMode, setCurrentMode] = useState<string>('OpenAPI')
|
||||
const [currentModeDisabled, setCurrentModeDisabled] = useState<boolean>(false)
|
||||
|
||||
@@ -41,10 +41,10 @@ export const CreateBuiltinForm: FC<TCreateBuiltinFormProps> = ({ namespace, type
|
||||
<BlackholeForm
|
||||
data={{
|
||||
type: 'builtin',
|
||||
typeName,
|
||||
plural,
|
||||
prefillValueNamespaceOnly: namespace,
|
||||
}}
|
||||
customizationId={`default-/v1/${typeName}`}
|
||||
customizationId={`default-/v1/${plural}`}
|
||||
isCreate
|
||||
backlink={backLink}
|
||||
modeData={modeData}
|
||||
|
||||
@@ -6,13 +6,13 @@ import { RootState } from 'store/store'
|
||||
import { BlackholeForm } from 'components'
|
||||
|
||||
type TUpdateBuiltinFormProps = {
|
||||
typeName: string
|
||||
entryName: string
|
||||
plural: string
|
||||
name: string
|
||||
namespace?: string
|
||||
backLink?: string | null
|
||||
}
|
||||
|
||||
export const UpdateBuiltinForm: FC<TUpdateBuiltinFormProps> = ({ typeName, entryName, namespace, backLink }) => {
|
||||
export const UpdateBuiltinForm: FC<TUpdateBuiltinFormProps> = ({ plural, name, namespace, backLink }) => {
|
||||
const cluster = useSelector((state: RootState) => state.cluster.cluster)
|
||||
|
||||
const [currentMode, setCurrentMode] = useState<string>('OpenAPI')
|
||||
@@ -33,10 +33,10 @@ export const UpdateBuiltinForm: FC<TUpdateBuiltinFormProps> = ({ 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<TUpdateBuiltinFormProps> = ({ typeName, entry
|
||||
return <Alert message={`An error has occurred: ${error?.message} `} type="error" />
|
||||
}
|
||||
|
||||
/* 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<TUpdateBuiltinFormProps> = ({ typeName, entry
|
||||
<BlackholeForm
|
||||
data={{
|
||||
type: 'builtin',
|
||||
typeName,
|
||||
// prefillValuesSchema: { ...noStatusData, metadata },
|
||||
plural,
|
||||
prefillValuesSchema: { ...data, metadata },
|
||||
}}
|
||||
customizationId={`default-/v1/${typeName}`}
|
||||
customizationId={`default-/v1/${plural}`}
|
||||
backlink={backLink}
|
||||
modeData={modeData}
|
||||
/>
|
||||
|
||||
@@ -7,11 +7,11 @@ type TCreateCrdsFormProps = {
|
||||
namespace?: string
|
||||
apiGroup: string
|
||||
apiVersion: string
|
||||
typeName: string
|
||||
plural: string
|
||||
backLink?: string | null
|
||||
}
|
||||
|
||||
export const CreateCrdsForm: FC<TCreateCrdsFormProps> = ({ namespace, apiGroup, apiVersion, typeName, backLink }) => {
|
||||
export const CreateCrdsForm: FC<TCreateCrdsFormProps> = ({ namespace, apiGroup, apiVersion, plural, backLink }) => {
|
||||
const [currentMode, setCurrentMode] = useState<string>('OpenAPI')
|
||||
const [currentModeDisabled, setCurrentModeDisabled] = useState<boolean>(false)
|
||||
|
||||
@@ -45,10 +45,10 @@ export const CreateCrdsForm: FC<TCreateCrdsFormProps> = ({ 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}
|
||||
|
||||
@@ -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<TUpdateCrdsFormProps> = ({
|
||||
apiGroup,
|
||||
apiVersion,
|
||||
typeName,
|
||||
entryName,
|
||||
plural,
|
||||
name,
|
||||
namespace,
|
||||
backLink,
|
||||
}) => {
|
||||
@@ -46,16 +41,6 @@ export const UpdateCrdsForm: FC<TUpdateCrdsFormProps> = ({
|
||||
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<TUpdateCrdsFormProps> = ({
|
||||
}>({
|
||||
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<TUpdateCrdsFormProps> = ({
|
||||
return <Alert message={`An error has occurred: No data `} type="error" />
|
||||
}
|
||||
|
||||
/* 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<TUpdateCrdsFormProps> = ({
|
||||
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}
|
||||
/>
|
||||
|
||||
@@ -20,10 +20,6 @@ export const User: FC = () => {
|
||||
placement="top"
|
||||
menu={{
|
||||
items: [
|
||||
// {
|
||||
// key: '1',
|
||||
// label: <ThemeSelector />,
|
||||
// },
|
||||
...(BASE_HIDE_INSIDE === 'true'
|
||||
? []
|
||||
: [
|
||||
|
||||
@@ -12,8 +12,7 @@ type THeaderProps = {
|
||||
}
|
||||
|
||||
export const HeaderSecond: FC<THeaderProps> = ({ 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<THeaderProps> = ({ inside, isSearch }) => {
|
||||
<Styled.BackgroundContainer $bgColor={token.colorFillSecondary} $borderRadius={token.borderRadius}>
|
||||
<Styled.PaddingContainer $height={HEAD_SECOND_ROW}>
|
||||
<Flex gap={18}>
|
||||
{inside ? <SelectorClusterInside clusterName={clusterName} /> : <SelectorCluster clusterName={clusterName} />}
|
||||
{inside && <SelectorInside clusterName={clusterName} namespace={namespace} />}
|
||||
{inside ? <SelectorClusterInside cluster={cluster} /> : <SelectorCluster cluster={cluster} />}
|
||||
{inside && <SelectorInside cluster={cluster} namespace={namespace} />}
|
||||
{!inside && !isSearch && BASE_USE_NAMESPACE_NAV !== 'true' && (
|
||||
<Selector
|
||||
clusterName={clusterName}
|
||||
cluster={cluster}
|
||||
projectName={projectName || possibleProject}
|
||||
instanceName={instanceName || possibleInstance}
|
||||
/>
|
||||
)}
|
||||
{!inside && (isSearch || BASE_USE_NAMESPACE_NAV === 'true') && (
|
||||
<SelectorNamespace clusterName={clusterName} namespace={namespace} />
|
||||
<SelectorNamespace cluster={cluster} namespace={namespace} />
|
||||
)}
|
||||
</Flex>
|
||||
</Styled.PaddingContainer>
|
||||
|
||||
@@ -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<TSelectorProps> = ({ clusterName, projectName, instanceName }) => {
|
||||
export const Selector: FC<TSelectorProps> = ({ 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<TSelectorProps> = ({ 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 (
|
||||
<Flex gap={18} justify="start" align="center">
|
||||
{/* <EntrySelect
|
||||
placeholder="Cluster"
|
||||
options={clustersInSidebar}
|
||||
value={selectedClusterName}
|
||||
value={selectedCluster}
|
||||
onChange={handleClusterChange}
|
||||
/> */}
|
||||
<Typography.Text>Project: </Typography.Text>
|
||||
@@ -117,7 +98,7 @@ export const Selector: FC<TSelectorProps> = ({ 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}
|
||||
/>
|
||||
<Typography.Text>Instance: </Typography.Text>
|
||||
<EntrySelect
|
||||
@@ -126,7 +107,7 @@ export const Selector: FC<TSelectorProps> = ({ clusterName, projectName, instanc
|
||||
value={selectedInstanceName || 'all'}
|
||||
onChange={handleInstanceChange}
|
||||
disabled={
|
||||
selectedClusterName === undefined ||
|
||||
selectedCluster === undefined ||
|
||||
selectedProjectName === undefined ||
|
||||
(allInstancesLoadingSuccess && instancesInSidebar.length === 0)
|
||||
}
|
||||
|
||||
@@ -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<TSelectorClusterProps> = ({ clusterName }) => {
|
||||
export const SelectorCluster: FC<TSelectorClusterProps> = ({ 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<TSelectorClusterProps> = ({ clusterName }) => {
|
||||
}
|
||||
|
||||
useMountEffect(() => {
|
||||
setSelectedClusterName(clusterName)
|
||||
}, [clusterName])
|
||||
setSelectedCluster(cluster)
|
||||
}, [cluster])
|
||||
|
||||
return (
|
||||
<Flex gap={18} justify="start" align="center">
|
||||
@@ -40,9 +39,8 @@ export const SelectorCluster: FC<TSelectorClusterProps> = ({ clusterName }) => {
|
||||
<EntrySelect
|
||||
placeholder="Select Cluster"
|
||||
options={clustersInSidebar}
|
||||
value={selectedClusterName}
|
||||
value={selectedCluster}
|
||||
onChange={handleClusterChange}
|
||||
// fullwidth
|
||||
/>
|
||||
</Flex>
|
||||
)
|
||||
|
||||
@@ -8,20 +8,20 @@ import { useMountEffect } from 'hooks/useMountEffect'
|
||||
import { EntrySelect } from 'components/atoms'
|
||||
|
||||
type TSelectorClusterInsideProps = {
|
||||
clusterName?: string
|
||||
cluster?: string
|
||||
}
|
||||
|
||||
export const SelectorClusterInside: FC<TSelectorClusterInsideProps> = ({ clusterName }) => {
|
||||
export const SelectorClusterInside: FC<TSelectorClusterInsideProps> = ({ 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<TSelectorClusterInsideProps> = ({ cluster
|
||||
}
|
||||
|
||||
useMountEffect(() => {
|
||||
setSelectedClusterName(clusterName)
|
||||
}, [clusterName])
|
||||
setSelectedCluster(cluster)
|
||||
}, [cluster])
|
||||
|
||||
return (
|
||||
<Flex gap={18} justify="start" align="center">
|
||||
@@ -38,9 +38,8 @@ export const SelectorClusterInside: FC<TSelectorClusterInsideProps> = ({ cluster
|
||||
<EntrySelect
|
||||
placeholder="Select Cluster"
|
||||
options={clustersInSidebar}
|
||||
value={selectedClusterName}
|
||||
value={selectedCluster}
|
||||
onChange={handleClusterChange}
|
||||
// fullwidth
|
||||
/>
|
||||
</Flex>
|
||||
)
|
||||
|
||||
@@ -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<TSelectorInsideProps> = ({ clusterName, namespace }) => {
|
||||
export const SelectorInside: FC<TSelectorInsideProps> = ({ cluster, namespace }) => {
|
||||
const navigate = useNavigate()
|
||||
const params = useParams()
|
||||
|
||||
const [selectedClusterName, setSelectedClusterName] = useState<string | undefined>(clusterName)
|
||||
const [selectedCluster, setSelectedCluster] = useState<string | undefined>(cluster)
|
||||
const [selectedNamespace, setSelectedNamespace] = useState<string | undefined>(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<TSelectorInsideProps> = ({ clusterName, namespac
|
||||
}
|
||||
|
||||
useMountEffect(() => {
|
||||
setSelectedClusterName(clusterName)
|
||||
setSelectedCluster(cluster)
|
||||
setSelectedNamespace(namespace)
|
||||
}, [namespace, clusterName])
|
||||
}, [namespace, cluster])
|
||||
|
||||
return (
|
||||
<Flex gap={18} justify="start" align="center">
|
||||
{/* <EntrySelect
|
||||
placeholder="Cluster"
|
||||
options={clustersInSidebar}
|
||||
value={selectedClusterName}
|
||||
onChange={handleClusterChange}
|
||||
/> */}
|
||||
<Typography.Text>Namespace: </Typography.Text>
|
||||
<EntrySelect
|
||||
placeholder="Namespace"
|
||||
options={[{ value: 'all', label: 'All Namespaces' }, ...namespacesInSidebar]}
|
||||
value={selectedNamespace || 'all'}
|
||||
onChange={handleNamepsaceChange}
|
||||
disabled={selectedClusterName === undefined || namespacesInSidebar.length === 0}
|
||||
disabled={selectedCluster === undefined || namespacesInSidebar.length === 0}
|
||||
/>
|
||||
</Flex>
|
||||
)
|
||||
|
||||
@@ -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<TSelectorNamespaceProps> = ({ clusterName, namespace }) => {
|
||||
export const SelectorNamespace: FC<TSelectorNamespaceProps> = ({ 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<TSelectorNamespaceProps> = ({ 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<TSelectorNamespaceProps> = ({ 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 (
|
||||
<Flex gap={18} justify="start" align="center">
|
||||
@@ -125,7 +112,7 @@ export const SelectorNamespace: FC<TSelectorNamespaceProps> = ({ 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}
|
||||
/>
|
||||
</Flex>
|
||||
)
|
||||
|
||||
@@ -33,16 +33,16 @@ export const ListInsideAllResources: FC<TListInsideAllResourcesProps> = ({ 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,
|
||||
|
||||
@@ -27,13 +27,13 @@ export const ListInsideApisByApiGroup: FC<TListInsideApisByApiGroupProps> = ({ 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])
|
||||
|
||||
@@ -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={() => {
|
||||
|
||||
@@ -30,13 +30,13 @@ export const ListInsideCrdsByApiGroup: FC<TListInsideCrdsByApiGroupProps> = ({
|
||||
const [filteredResources, setFilteredResources] = useState<TApiGroupResourceTypeList['resources']>()
|
||||
|
||||
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])
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -40,7 +40,7 @@ export const SearchEntry: FC<TSearchEntryProps> = ({ 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<TSearchEntryProps> = ({ resource, labels, fields, f
|
||||
{isOpen && (
|
||||
<>
|
||||
<Spacer $space={12} $samespace />
|
||||
{typeName && (
|
||||
{plural && (
|
||||
<TableApiBuiltin
|
||||
resourceType={apiGroup.length > 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}
|
||||
|
||||
@@ -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<TBackgroundContainerProps>`
|
||||
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,
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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 =>
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 (
|
||||
<ContentCard flexGrow={1} displayFlex flexFlow="column">
|
||||
{entryName ? (
|
||||
{name ? (
|
||||
<UpdateApisForm
|
||||
namespace={namespace}
|
||||
apiGroup={apiGroup}
|
||||
apiVersion={apiVersion}
|
||||
typeName={typeName}
|
||||
entryName={entryName}
|
||||
plural={plural}
|
||||
name={name}
|
||||
backLink={backLink}
|
||||
/>
|
||||
) : (
|
||||
@@ -78,7 +76,7 @@ export const FormApiPage: FC = () => {
|
||||
namespace={namespace}
|
||||
apiGroup={apiGroup}
|
||||
apiVersion={apiVersion}
|
||||
typeName={typeName}
|
||||
plural={plural}
|
||||
backLink={backLink}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -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 (
|
||||
<ContentCard flexGrow={1} displayFlex flexFlow="column">
|
||||
{entryName ? (
|
||||
<UpdateBuiltinForm namespace={namespace} typeName={typeName} entryName={entryName} backLink={backLink} />
|
||||
{name ? (
|
||||
<UpdateBuiltinForm namespace={namespace} plural={plural} name={name} backLink={backLink} />
|
||||
) : (
|
||||
<CreateBuiltinForm namespace={namespace} typeName={typeName} backLink={backLink} />
|
||||
<CreateBuiltinForm namespace={namespace} plural={plural} backLink={backLink} />
|
||||
)}
|
||||
</ContentCard>
|
||||
)
|
||||
|
||||
@@ -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 (
|
||||
<ContentCard flexGrow={1} displayFlex flexFlow="column">
|
||||
{entryName ? (
|
||||
{name ? (
|
||||
<UpdateCrdsForm
|
||||
namespace={namespace}
|
||||
apiGroup={apiGroup}
|
||||
apiVersion={apiVersion}
|
||||
typeName={typeName}
|
||||
entryName={entryName}
|
||||
plural={plural}
|
||||
name={name}
|
||||
backLink={backLink}
|
||||
/>
|
||||
) : (
|
||||
@@ -78,7 +76,7 @@ export const FormCrdPage: FC = () => {
|
||||
namespace={namespace}
|
||||
apiGroup={apiGroup}
|
||||
apiVersion={apiVersion}
|
||||
typeName={typeName}
|
||||
plural={plural}
|
||||
backLink={backLink}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
// export { FormCrdPage } from './FormCrdPage'
|
||||
export { FormApiPage } from './FormApiPage'
|
||||
export { FormBuiltinPage } from './FormBuiltinPage'
|
||||
|
||||
@@ -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<TTableApiPageProps> = ({ 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<TTableApiPageProps> = ({ 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<TTableApiPageProps> = ({ 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<TTableApiPageProps> = ({ inside }) => {
|
||||
|
||||
return (
|
||||
<ContentCard flexGrow={1} displayFlex flexFlow="column">
|
||||
{typeName && apiGroup && apiVersion && (
|
||||
{plural && apiGroup && apiVersion && (
|
||||
<TableApiBuiltin
|
||||
resourceType="api"
|
||||
namespace={namespace}
|
||||
apiGroup={apiGroup}
|
||||
apiVersion={apiVersion}
|
||||
typeName={typeName}
|
||||
key={`${apiGroup}-${apiVersion}-${namespace}-${typeName}`}
|
||||
plural={plural}
|
||||
key={`${apiGroup}-${apiVersion}-${namespace}-${plural}`}
|
||||
limit={limitSp && limitSp.length > 0 ? Number(limitSp) : undefined}
|
||||
inside={inside}
|
||||
customizationIdPrefix={tableCustomizationIdPrefix}
|
||||
|
||||
@@ -14,7 +14,7 @@ type TTableBuiltinPageProps = {
|
||||
}
|
||||
|
||||
export const TableBuiltinPage: FC<TTableBuiltinPageProps> = ({ 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<TTableBuiltinPageProps> = ({ inside }) => {
|
||||
const possibleInstance = syntheticProject && namespace ? namespace : undefined
|
||||
|
||||
const preparedBacklink = getTablesBackLink({
|
||||
clusterName,
|
||||
cluster,
|
||||
possibleProject,
|
||||
possibleInstance,
|
||||
namespace,
|
||||
@@ -37,9 +37,9 @@ export const TableBuiltinPage: FC<TTableBuiltinPageProps> = ({ 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<TTableBuiltinPageProps> = ({ inside }) => {
|
||||
setBacklinkTitle(undefined)
|
||||
}
|
||||
}, [
|
||||
typeName,
|
||||
plural,
|
||||
preparedBacklink,
|
||||
setSidebarSuffix,
|
||||
setBreadcrumbsSuffix,
|
||||
@@ -69,13 +69,13 @@ export const TableBuiltinPage: FC<TTableBuiltinPageProps> = ({ inside }) => {
|
||||
|
||||
return (
|
||||
<ContentCard flexGrow={1} displayFlex flexFlow="column">
|
||||
{typeName && (
|
||||
{plural && (
|
||||
<TableApiBuiltin
|
||||
resourceType="builtin"
|
||||
apiVersion="v1"
|
||||
key={`${namespace}-${typeName}`}
|
||||
key={`${namespace}-${plural}`}
|
||||
namespace={namespace}
|
||||
typeName={typeName}
|
||||
plural={plural}
|
||||
limit={limitSp && limitSp.length > 0 ? Number(limitSp) : undefined}
|
||||
inside={inside}
|
||||
customizationIdPrefix={tableCustomizationIdPrefix}
|
||||
|
||||
@@ -14,14 +14,14 @@ type TTableCrdPageProps = {
|
||||
}
|
||||
|
||||
export const TableCrdPage: FC<TTableCrdPageProps> = ({ 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,
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
// export { TableCrdPage } from './TableCrdPage'
|
||||
export { TableApiPage } from './TableApiPage'
|
||||
export { TableBuiltinPage } from './TableBuiltinPage'
|
||||
|
||||
@@ -21,5 +21,3 @@ export const themeSlice = createSlice({
|
||||
})
|
||||
|
||||
export const { setTheme } = themeSlice.actions
|
||||
|
||||
// export default themeSlice
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// AppShell.tsx
|
||||
import React, { FC, useState, useMemo } from 'react'
|
||||
import { Outlet, useParams } from 'react-router-dom'
|
||||
import { BaseTemplate } from 'templates'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -16,7 +16,7 @@ type TMainLayoutProps = {
|
||||
}
|
||||
|
||||
export const MainLayout: FC<TMainLayoutProps> = ({ 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<TMainLayoutProps> = ({ 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 (
|
||||
<DefaultColorProvider $color={token.colorText}>
|
||||
|
||||
@@ -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`
|
||||
|
||||
Reference in New Issue
Block a user