update routing

This commit is contained in:
typescreep
2025-05-30 18:55:04 +03:00
parent 76ca4b344b
commit 1d189d3e40
16 changed files with 108 additions and 77 deletions

3
.env
View File

@@ -1,3 +1,4 @@
VITE_CUSTOMIZATION_API_GROUP=incloud.io
VITE_CUSTOMIZATION_API_VERSION=v1alpha
VITE_RPROJECTS_VERSION=v1alpha
VITE_PROJECTS_VERSION=v1alpha
VITE_INSTANCES_VERSION=v1alpha1

View File

@@ -28,7 +28,7 @@ export const getPathToNav = ({
}
if (type === 'nonCrd') {
return `${baseprefix}/${clusterName}/${namespace}/non-crd-table/${apiGroup}/${apiVersion}/${typeName}`
return `${baseprefix}/${clusterName}/${namespace}/api-table/${apiGroup}/${apiVersion}/${typeName}`
}
return `${baseprefix}/${clusterName}/${namespace}/builtin-table/${typeName}`

View File

@@ -41,7 +41,7 @@ export const Selector: FC<TSelectorProps> = ({ clusterName, projectName, instanc
const handleInstanceChange = (value: string) => {
setSelectedInstanceName(value)
navigate(`${baseprefix}/${selectedClusterName}/${value}/${selectedProjectName}/non-crd-table/apps/v1/deployments`)
navigate(`${baseprefix}/${selectedClusterName}/${value}/${selectedProjectName}/api-table/apps/v1/deployments`)
}
useMountEffect(() => {

View File

@@ -1,3 +1,4 @@
export const BASE_API_GROUP = import.meta.env.VITE_CUSTOMIZATION_API_GROUP
export const BASE_API_VERSION = import.meta.env.VITE_CUSTOMIZATION_API_VERSION
export const BASE_RPROJECTS_VERSION = import.meta.env.VITE_RPROJECTS_VERSION
export const BASE_RPROJECTS_VERSION = import.meta.env.VITE_PROJECTS_VERSION
export const BASE_INSTANCES_VERSION = import.meta.env.VITE_INSTANCES_VERSION

View File

@@ -1,7 +1,11 @@
import { useApiResources, TClusterList, TSingleResource } from '@prorobotech/openapi-k8s-toolkit'
import { useSelector } from 'react-redux'
import { RootState } from 'store/store'
import { BASE_API_GROUP, BASE_RPROJECTS_VERSION } from 'constants/customizationApiGroupAndVersion'
import {
BASE_API_GROUP,
BASE_RPROJECTS_VERSION,
BASE_INSTANCES_VERSION,
} from 'constants/customizationApiGroupAndVersion'
const mappedClusterToOptionInSidebar = ({ name }: TClusterList[number]): { value: string; label: string } => ({
value: name,
@@ -29,7 +33,7 @@ export const useNavSelector = (clusterName?: string, projectName?: string) => {
clusterName: clusterName || '',
namespace: '',
apiGroup: BASE_API_GROUP,
apiVersion: BASE_RPROJECTS_VERSION,
apiVersion: BASE_INSTANCES_VERSION,
typeName: 'instances',
limit: null,
})

View File

@@ -1,6 +1,8 @@
import React, { FC } from 'react'
import { Spacer } from '@prorobotech/openapi-k8s-toolkit'
import { useParams, useSearchParams } from 'react-router-dom'
import { useSelector } from 'react-redux'
import type { RootState } from 'store/store'
import { CreateApisForm, UpdateApisForm, BackLink, ManageableBreadcrumbs } from 'components'
import { BaseTemplate } from 'templates'
@@ -11,10 +13,15 @@ type TFormApiPageProps = {
export const FormApiPage: FC<TFormApiPageProps> = ({ forcedTheme }) => {
const { clusterName, syntheticProject, namespace, apiGroup, apiVersion, typeName, entryName } = useParams()
const [searchParams] = useSearchParams()
const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix)
const possibleProject = syntheticProject && namespace ? syntheticProject : namespace
const possibleInstance = syntheticProject && namespace ? namespace : undefined
const customBacklink = possibleInstance
? `${baseprefix}/${clusterName}/${possibleInstance}/${possibleProject}/api-table/apps/v1/deployments`
: `${baseprefix}/clusters/${clusterName}/projects/${possibleProject}`
if (!typeName || !apiGroup || !apiVersion) {
return null
}
@@ -25,12 +32,7 @@ export const FormApiPage: FC<TFormApiPageProps> = ({ forcedTheme }) => {
<BaseTemplate forcedTheme={forcedTheme}>
<ManageableBreadcrumbs />
<BackLink
to={
backLink ||
`/core/clusters/${clusterName}/projects/${possibleProject}${
possibleInstance ? `/instances/${possibleInstance}` : ''
}`
}
to={backLink || customBacklink}
title={`${entryName ? 'Update' : 'Create'} ${apiGroup}/${apiVersion}/${typeName}${
entryName ? `/${entryName}` : ''
}`}

View File

@@ -1,6 +1,8 @@
import React, { FC } from 'react'
import { Spacer } from '@prorobotech/openapi-k8s-toolkit'
import { useParams, useSearchParams } from 'react-router-dom'
import { useSelector } from 'react-redux'
import type { RootState } from 'store/store'
import { CreateBuiltinForm, UpdateBuiltinForm, BackLink, ManageableBreadcrumbs } from 'components'
import { BaseTemplate } from 'templates'
@@ -11,10 +13,15 @@ type TFormBuiltinPageProps = {
export const FormBuiltinPage: FC<TFormBuiltinPageProps> = ({ forcedTheme }) => {
const { clusterName, syntheticProject, namespace, typeName, entryName } = useParams()
const [searchParams] = useSearchParams()
const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix)
const possibleProject = syntheticProject && namespace ? syntheticProject : namespace
const possibleInstance = syntheticProject && namespace ? namespace : undefined
const customBacklink = possibleInstance
? `${baseprefix}/${clusterName}/${possibleInstance}/${possibleProject}/api-table/apps/v1/deployments`
: `${baseprefix}/clusters/${clusterName}/projects/${possibleProject}`
if (!typeName) {
return null
}
@@ -25,12 +32,7 @@ export const FormBuiltinPage: FC<TFormBuiltinPageProps> = ({ forcedTheme }) => {
<BaseTemplate forcedTheme={forcedTheme}>
<ManageableBreadcrumbs />
<BackLink
to={
backLink ||
`/core/clusters/${clusterName}/projects/${possibleProject}${
possibleInstance ? `/instances/${possibleInstance}` : ''
}`
}
to={backLink || customBacklink}
title={`${entryName ? 'Update' : 'Create'} ${typeName}${entryName ? `/${entryName}` : ''}`}
/>
<Spacer $space={16} $samespace />

View File

@@ -1,6 +1,8 @@
import React, { FC } from 'react'
import { Spacer } from '@prorobotech/openapi-k8s-toolkit'
import { useParams, useSearchParams } from 'react-router-dom'
import { useSelector } from 'react-redux'
import type { RootState } from 'store/store'
import { CreateCrdsForm, UpdateCrdsForm, BackLink, ManageableBreadcrumbs } from 'components'
import { BaseTemplate } from 'templates'
@@ -11,10 +13,15 @@ type TFormCrdPageProps = {
export const FormCrdPage: FC<TFormCrdPageProps> = ({ forcedTheme }) => {
const { clusterName, syntheticProject, apiGroup, apiVersion, namespace, typeName, entryName } = useParams()
const [searchParams] = useSearchParams()
const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix)
const possibleProject = syntheticProject && namespace ? syntheticProject : namespace
const possibleInstance = syntheticProject && namespace ? namespace : undefined
const customBacklink = possibleInstance
? `${baseprefix}/${clusterName}/${possibleInstance}/${possibleProject}/api-table/apps/v1/deployments`
: `${baseprefix}/clusters/${clusterName}/projects/${possibleProject}`
if (!typeName || !apiGroup || !apiVersion) {
return null
}
@@ -25,12 +32,7 @@ export const FormCrdPage: FC<TFormCrdPageProps> = ({ forcedTheme }) => {
<BaseTemplate forcedTheme={forcedTheme}>
<ManageableBreadcrumbs />
<BackLink
to={
backLink ||
`/core/clusters/${clusterName}/projects/${possibleProject}${
possibleInstance ? `/instances/${possibleInstance}` : ''
}`
}
to={backLink || customBacklink}
title={`${entryName ? 'Update' : 'Create'} ${apiGroup}/${apiVersion}/${typeName}${
entryName ? `/${entryName}` : ''
}`}

View File

@@ -4,7 +4,6 @@ import { Spacer } from '@prorobotech/openapi-k8s-toolkit'
import { Link } from 'react-router-dom'
import { useSelector } from 'react-redux'
import type { RootState } from 'store/store'
import { HomeOutlined } from '@ant-design/icons'
import { ListClusters } from 'components'
import { BaseTemplate } from 'templates'
@@ -17,11 +16,7 @@ export const ListClustersPage: FC<TListClustersPageProps> = ({ forcedTheme }) =>
const breadcrumbItems = [
{
title: (
<Link to={`${baseprefix}/`}>
<HomeOutlined />
</Link>
),
title: <Link to={`${baseprefix}/`}>In-Cloud</Link>,
key: 'home',
},
{

View File

@@ -4,7 +4,6 @@ import { Spacer } from '@prorobotech/openapi-k8s-toolkit'
import { useParams, Link } from 'react-router-dom'
import { useSelector } from 'react-redux'
import type { RootState } from 'store/store'
import { HomeOutlined } from '@ant-design/icons'
import { ListInsideApisByApiGroup } from 'components'
import { BaseTemplate } from 'templates'
@@ -18,11 +17,7 @@ export const ListInsideApiByApiGroupPage: FC<TListInsideApiByApiGroupPageProps>
const breadcrumbItems = [
{
title: (
<Link to={`${baseprefix}/inside/clusters`}>
<HomeOutlined />
</Link>
),
title: <Link to={`${baseprefix}/inside/clusters`}>In-Cloud: inside</Link>,
key: 'home',
},
{

View File

@@ -4,7 +4,6 @@ import { Spacer } from '@prorobotech/openapi-k8s-toolkit'
import { useParams, Link } from 'react-router-dom'
import { useSelector } from 'react-redux'
import type { RootState } from 'store/store'
import { HomeOutlined } from '@ant-design/icons'
import { ListInsideAllResources } from 'components'
import { BaseTemplate } from 'templates'
@@ -18,11 +17,7 @@ export const ListInsideApiPage: FC<TListInsideApiPageProps> = ({ forcedTheme })
const breadcrumbItems = [
{
title: (
<Link to={`${baseprefix}/inside/clusters`}>
<HomeOutlined />
</Link>
),
title: <Link to={`${baseprefix}/inside/clusters`}>In-Cloud: inside</Link>,
key: 'home',
},
{

View File

@@ -1,4 +1,9 @@
import React, { FC } from 'react'
import { Breadcrumb } from 'antd'
import { Spacer } from '@prorobotech/openapi-k8s-toolkit'
import { Link } from 'react-router-dom'
import { useSelector } from 'react-redux'
import type { RootState } from 'store/store'
import { ListInsideClusterAndNs } from 'components'
import { BaseTemplate } from 'templates'
@@ -6,8 +11,25 @@ type TListInsideClustersAndNsPageProps = {
forcedTheme?: 'light' | 'dark'
}
export const ListInsideClustersAndNsPage: FC<TListInsideClustersAndNsPageProps> = ({ forcedTheme }) => (
<BaseTemplate withNoCluster forcedTheme={forcedTheme}>
<ListInsideClusterAndNs />
</BaseTemplate>
)
export const ListInsideClustersAndNsPage: FC<TListInsideClustersAndNsPageProps> = ({ forcedTheme }) => {
const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix)
const breadcrumbItems = [
{
title: <Link to={`${baseprefix}/inside/clusters`}>In-Cloud: inside</Link>,
key: 'home',
},
{
title: 'Select cluster / namespace',
key: 'select-cluster-and-ns',
},
]
return (
<BaseTemplate withNoCluster forcedTheme={forcedTheme}>
<Breadcrumb items={breadcrumbItems} separator=">" />
<Spacer $space={16} $samespace />
<ListInsideClusterAndNs />
</BaseTemplate>
)
}

View File

@@ -4,7 +4,6 @@ import { Spacer } from '@prorobotech/openapi-k8s-toolkit'
import { useParams, Link } from 'react-router-dom'
import { useSelector } from 'react-redux'
import type { RootState } from 'store/store'
import { HomeOutlined } from '@ant-design/icons'
import { ListInsideCrdsByApiGroup } from 'components'
import { BaseTemplate } from 'templates'
@@ -18,11 +17,7 @@ export const ListInsideCrdByApiGroupPage: FC<TListInsideCrdByApiGroupPageProps>
const breadcrumbItems = [
{
title: (
<Link to={`${baseprefix}/inside/clusters`}>
<HomeOutlined />
</Link>
),
title: <Link to={`${baseprefix}/inside/clusters`}>In-Cloud: inside</Link>,
key: 'home',
},
{

View File

@@ -1,8 +1,11 @@
import React, { FC } from 'react'
import { Spacer } from '@prorobotech/openapi-k8s-toolkit'
import { useParams, useSearchParams } from 'react-router-dom'
import { useSelector } from 'react-redux'
import type { RootState } from 'store/store'
import { TableNonCrdInfo, BackLink, ManageableBreadcrumbs } from 'components'
import { BaseTemplate } from 'templates'
import { BASE_API_GROUP, BASE_INSTANCES_VERSION } from 'constants/customizationApiGroupAndVersion'
type TTableApiPageProps = {
forcedTheme?: 'light' | 'dark'
@@ -11,21 +14,29 @@ type TTableApiPageProps = {
export const TableApiPage: FC<TTableApiPageProps> = ({ forcedTheme }) => {
const { clusterName, namespace, syntheticProject, apiGroup, apiVersion, typeName } = useParams()
const [searchParams] = useSearchParams()
const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix)
const possibleProject = syntheticProject && namespace ? syntheticProject : namespace
const possibleInstance = syntheticProject && namespace ? namespace : undefined
const customBacklink = possibleInstance
? // ? `${baseprefix}/${clusterName}/${possibleInstance}/${possibleProject}/api-table/apps/v1/deployments`
`${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_API_GROUP}/${BASE_INSTANCES_VERSION}/instances`
: `${baseprefix}/clusters/${clusterName}/projects/${possibleProject}`
const clustererBacklink = `${baseprefix}/clusters`
// const instancesBacklink =
// apiGroup === 'apps' && apiVersion === 'v1' && typeName === 'deployments'
// ? `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_API_GROUP}/${BASE_INSTANCES_VERSION}/instances`
// : undefined
// const nonInstanceBackLink = namespace ? customBacklink : clustererBacklink
return (
<BaseTemplate forcedTheme={forcedTheme}>
<ManageableBreadcrumbs />
<BackLink
to={
possibleInstance
? `/instances-federation/clusters/${clusterName}/projects/${possibleProject}/${possibleInstance}`
: `/core/clusters/${clusterName}/projects/${possibleProject}`
}
title={`${apiGroup}/${apiVersion}/${typeName}`}
/>
<BackLink to={namespace ? customBacklink : clustererBacklink} title={`${apiGroup}/${apiVersion}/${typeName}`} />
<Spacer $space={16} $samespace />
{typeName && apiGroup && apiVersion && (
<TableNonCrdInfo

View File

@@ -1,8 +1,11 @@
import React, { FC } from 'react'
import { Spacer } from '@prorobotech/openapi-k8s-toolkit'
import { useParams, useSearchParams } from 'react-router-dom'
import { useSelector } from 'react-redux'
import type { RootState } from 'store/store'
import { TableBuiltinInfo, BackLink, ManageableBreadcrumbs } from 'components'
import { BaseTemplate } from 'templates'
import { BASE_API_GROUP, BASE_INSTANCES_VERSION } from 'constants/customizationApiGroupAndVersion'
type TTableBuiltinPageProps = {
forcedTheme?: 'light' | 'dark'
@@ -11,21 +14,21 @@ type TTableBuiltinPageProps = {
export const TableBuiltinPage: FC<TTableBuiltinPageProps> = ({ forcedTheme }) => {
const { clusterName, namespace, syntheticProject, typeName } = useParams()
const [searchParams] = useSearchParams()
const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix)
const possibleProject = syntheticProject && namespace ? syntheticProject : namespace
const possibleInstance = syntheticProject && namespace ? namespace : undefined
const customBacklink = possibleInstance
? `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_API_GROUP}/${BASE_INSTANCES_VERSION}/instances`
: `${baseprefix}/clusters/${clusterName}/projects/${possibleProject}`
const clustererBacklink = `${baseprefix}/clusters`
return (
<BaseTemplate forcedTheme={forcedTheme}>
<ManageableBreadcrumbs />
<BackLink
to={
possibleInstance
? `/instances-federation/clusters/${clusterName}/projects/${possibleProject}/${possibleInstance}`
: `/core/clusters/${clusterName}/projects/${possibleProject}`
}
title={typeName}
/>
<BackLink to={namespace ? customBacklink : clustererBacklink} title={typeName} />
<Spacer $space={16} $samespace />
{typeName && <TableBuiltinInfo namespace={namespace} typeName={typeName} limit={searchParams.get('limit')} />}
</BaseTemplate>

View File

@@ -1,8 +1,11 @@
import React, { FC } from 'react'
import { Spacer } from '@prorobotech/openapi-k8s-toolkit'
import { useParams } from 'react-router-dom'
import { useSelector } from 'react-redux'
import type { RootState } from 'store/store'
import { TableCrdInfo, BackLink, ManageableBreadcrumbs } from 'components'
import { BaseTemplate } from 'templates'
import { BASE_API_GROUP, BASE_INSTANCES_VERSION } from 'constants/customizationApiGroupAndVersion'
type TTableCrdPageProps = {
forcedTheme?: 'light' | 'dark'
@@ -10,21 +13,21 @@ type TTableCrdPageProps = {
export const TableCrdPage: FC<TTableCrdPageProps> = ({ forcedTheme }) => {
const { clusterName, 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 customBacklink = possibleInstance
? `${baseprefix}/${clusterName}/${possibleProject}/api-table/${BASE_API_GROUP}/${BASE_INSTANCES_VERSION}/instances`
: `${baseprefix}/clusters/${clusterName}/projects/${possibleProject}`
const clustererBacklink = `${baseprefix}/clusters`
return (
<BaseTemplate forcedTheme={forcedTheme}>
<ManageableBreadcrumbs />
<BackLink
to={
possibleInstance
? `/instances-federation/clusters/${clusterName}/projects/${possibleProject}/${possibleInstance}`
: `/core/clusters/${clusterName}/projects/${possibleProject}`
}
title={`${apiGroup}/${apiVersion}/${crdName}`}
/>
<BackLink to={namespace ? customBacklink : clustererBacklink} title={`${apiGroup}/${apiVersion}/${crdName}`} />
<Spacer $space={16} $samespace />
{crdName && apiGroup && apiVersion && apiExtensionVersion && (
<TableCrdInfo