mirror of
https://github.com/outbackdingo/openapi-ui.git
synced 2026-01-27 18:19:50 +00:00
tables on bff
This commit is contained in:
8
package-lock.json
generated
8
package-lock.json
generated
@@ -11,7 +11,7 @@
|
||||
"@ant-design/icons": "5.6.0",
|
||||
"@monaco-editor/react": "4.6.0",
|
||||
"@originjs/vite-plugin-federation": "1.3.6",
|
||||
"@prorobotech/openapi-k8s-toolkit": "^0.0.1-alpha.51",
|
||||
"@prorobotech/openapi-k8s-toolkit": "^0.0.1-alpha.52",
|
||||
"@readme/openapi-parser": "4.0.0",
|
||||
"@reduxjs/toolkit": "2.2.5",
|
||||
"@tanstack/react-query": "5.62.2",
|
||||
@@ -2807,9 +2807,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@prorobotech/openapi-k8s-toolkit": {
|
||||
"version": "0.0.1-alpha.51",
|
||||
"resolved": "https://registry.npmjs.org/@prorobotech/openapi-k8s-toolkit/-/openapi-k8s-toolkit-0.0.1-alpha.51.tgz",
|
||||
"integrity": "sha512-XvEXoYSzSyhf1xeoURREi3c9dRWI1G3si6cGAMME51hIIxkx06ZCl1LqmU0aTQuRaHuMMf9zDFWjj7OAXpsXwQ==",
|
||||
"version": "0.0.1-alpha.52",
|
||||
"resolved": "https://registry.npmjs.org/@prorobotech/openapi-k8s-toolkit/-/openapi-k8s-toolkit-0.0.1-alpha.52.tgz",
|
||||
"integrity": "sha512-Tj61DQG68HW0tdYof16Z/ndPMLle5Xr0sxuXFStqGkicLp+V2scV0/hrkivzuWXUrW4QVBUYhTwfhDV+L4pZIw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@monaco-editor/react": "4.6.0",
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"@ant-design/icons": "5.6.0",
|
||||
"@monaco-editor/react": "4.6.0",
|
||||
"@originjs/vite-plugin-federation": "1.3.6",
|
||||
"@prorobotech/openapi-k8s-toolkit": "0.0.1-alpha.51",
|
||||
"@prorobotech/openapi-k8s-toolkit": "0.0.1-alpha.52",
|
||||
"@readme/openapi-parser": "4.0.0",
|
||||
"@reduxjs/toolkit": "2.2.5",
|
||||
"@tanstack/react-query": "5.62.2",
|
||||
|
||||
@@ -1,25 +1,17 @@
|
||||
import React, { FC, useState } from 'react'
|
||||
import { useNavigate, useLocation, useParams } from 'react-router-dom'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
import { Spin, Alert, Button, Flex } from 'antd'
|
||||
import { PlusOutlined } from '@ant-design/icons'
|
||||
import {
|
||||
EnrichedTableProvider,
|
||||
useDirectUnknownResource,
|
||||
usePermissions,
|
||||
DeleteModal,
|
||||
DeleteModalMany,
|
||||
TTableMappingResponse,
|
||||
TAdditionalPrinterColumns,
|
||||
prepareTableMappings,
|
||||
useApiResources,
|
||||
useCrdResources,
|
||||
parseCustomOverrides,
|
||||
} from '@prorobotech/openapi-k8s-toolkit'
|
||||
import { useSelector } from 'react-redux'
|
||||
import { RootState } from 'store/store'
|
||||
import {
|
||||
BASE_API_GROUP,
|
||||
BASE_API_VERSION,
|
||||
BASE_PROJECTS_API_GROUP,
|
||||
BASE_PROJECTS_VERSION,
|
||||
BASE_PROJECTS_RESOURCE_NAME,
|
||||
@@ -29,12 +21,10 @@ import { TABLE_PROPS } from 'constants/tableProps'
|
||||
|
||||
export const ListProjects: FC = () => {
|
||||
const navigate = useNavigate()
|
||||
const { pathname } = useLocation()
|
||||
const theme = useSelector((state: RootState) => state.openapiTheme.theme)
|
||||
const baseprefix = useSelector((state: RootState) => state.baseprefix.baseprefix)
|
||||
|
||||
const { clusterName } = useParams()
|
||||
const path = pathname
|
||||
const cluster = clusterName || ''
|
||||
const apiGroup = BASE_PROJECTS_API_GROUP
|
||||
const apiVersion = BASE_PROJECTS_VERSION
|
||||
@@ -84,52 +74,6 @@ export const ListProjects: FC = () => {
|
||||
limit: null,
|
||||
})
|
||||
|
||||
const columnsOverrides = useCrdResources({
|
||||
clusterName: cluster,
|
||||
crdName: 'customcolumnsoverrides',
|
||||
apiGroup: BASE_API_GROUP,
|
||||
apiVersion: BASE_API_VERSION,
|
||||
})
|
||||
|
||||
const additionalPrinterColumns: TAdditionalPrinterColumns = [
|
||||
{
|
||||
name: 'Name',
|
||||
type: 'string',
|
||||
jsonPath: '.metadata.name',
|
||||
},
|
||||
{
|
||||
name: 'Timestamp',
|
||||
type: 'string',
|
||||
jsonPath: '.metadata.creationTimestamp',
|
||||
},
|
||||
]
|
||||
|
||||
const {
|
||||
ensuredCustomOverrides,
|
||||
ensuredCustomOverridesUndefinedValues,
|
||||
ensuredCustomOverridesTrimLengths,
|
||||
ensuredCustomOverridesColWidths,
|
||||
} = parseCustomOverrides({
|
||||
columnsOverridesData: columnsOverrides.data,
|
||||
overrideType: `${apiGroup}/${apiVersion}/${typeName}`,
|
||||
})
|
||||
|
||||
const { data: tableMappingsData } = useDirectUnknownResource<TTableMappingResponse>({
|
||||
uri: `/api/clusters/${cluster}/k8s/apis/${BASE_API_GROUP}/${BASE_API_VERSION}/tableurimappings/`,
|
||||
refetchInterval: 5000,
|
||||
queryKey: ['tableMappings', cluster || 'no-cluster'],
|
||||
isEnabled: cluster !== undefined,
|
||||
})
|
||||
|
||||
const tableMappingsDataSpecs = tableMappingsData?.items.map(({ spec }) => spec)
|
||||
const tableMappingSpecific = tableMappingsDataSpecs
|
||||
? prepareTableMappings({
|
||||
data: tableMappingsDataSpecs,
|
||||
clusterName,
|
||||
pathname: path,
|
||||
})
|
||||
: undefined
|
||||
|
||||
const onDeleteHandle = (name: string, endpoint: string) => {
|
||||
setIsDeleteModalOpen({ name, endpoint })
|
||||
}
|
||||
@@ -145,13 +89,12 @@ export const ListProjects: FC = () => {
|
||||
{error && <Alert message={`An error has occurred: ${error?.message} `} type="error" />}
|
||||
{!error && data && (
|
||||
<EnrichedTableProvider
|
||||
customizationId={`default-/${apiGroup}/${apiVersion}/${typeName}`}
|
||||
tableMappingsReplaceValues={{ clusterName }}
|
||||
cluster={cluster}
|
||||
theme={theme}
|
||||
baseprefix={baseprefix}
|
||||
dataItems={data.items}
|
||||
additionalPrinterColumns={ensuredCustomOverrides || additionalPrinterColumns}
|
||||
additionalPrinterColumnsUndefinedValues={ensuredCustomOverridesUndefinedValues}
|
||||
additionalPrinterColumnsTrimLengths={ensuredCustomOverridesTrimLengths}
|
||||
additionalPrinterColumnsColWidths={ensuredCustomOverridesColWidths}
|
||||
dataForControls={{
|
||||
cluster,
|
||||
syntheticProject: undefined,
|
||||
@@ -166,8 +109,6 @@ export const ListProjects: FC = () => {
|
||||
canDelete: isNamespaced ? true : deletePermission.data?.status.allowed,
|
||||
},
|
||||
}}
|
||||
pathToNavigate={tableMappingSpecific?.pathToNavigate}
|
||||
recordKeysForNavigation={tableMappingSpecific?.keysToParse}
|
||||
selectData={{
|
||||
selectedRowKeys,
|
||||
onChange: (selectedRowKeys: React.Key[], selectedRowsData: { name: string; endpoint: string }[]) => {
|
||||
|
||||
@@ -1,24 +1,17 @@
|
||||
import React, { FC, useState, useEffect } from 'react'
|
||||
import { useNavigate, useParams, useLocation } from 'react-router-dom'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
import { Spin, Alert, Button, Flex } from 'antd'
|
||||
import { PlusOutlined, ClearOutlined, MinusOutlined } from '@ant-design/icons'
|
||||
import { useSelector } from 'react-redux'
|
||||
import { RootState } from 'store/store'
|
||||
import {
|
||||
EnrichedTableProvider,
|
||||
useDirectUnknownResource,
|
||||
usePermissions,
|
||||
DeleteModal,
|
||||
DeleteModalMany,
|
||||
checkIfBuiltInInstanceNamespaceScoped,
|
||||
TTableMappingResponse,
|
||||
useCrdResources,
|
||||
prepareTableMappings,
|
||||
parseCustomOverrides,
|
||||
TAdditionalPrinterColumns,
|
||||
useBuiltinResources,
|
||||
} from '@prorobotech/openapi-k8s-toolkit'
|
||||
import { BASE_API_GROUP, BASE_API_VERSION } from 'constants/customizationApiGroupAndVersion'
|
||||
import { FlexGrow, OverflowMaxHeightContainer, MarginTopContainer } from 'components'
|
||||
import { TABLE_PROPS } from 'constants/tableProps'
|
||||
import {
|
||||
@@ -39,9 +32,7 @@ type TTableBuiltinInfoProps = {
|
||||
|
||||
export const TableBuiltinInfo: FC<TTableBuiltinInfoProps> = ({ namespace, typeName, limit, inside }) => {
|
||||
const navigate = useNavigate()
|
||||
const { pathname } = useLocation()
|
||||
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)
|
||||
@@ -123,60 +114,6 @@ export const TableBuiltinInfo: FC<TTableBuiltinInfoProps> = ({ namespace, typeNa
|
||||
limit,
|
||||
})
|
||||
|
||||
const additionalPrinterColumns: TAdditionalPrinterColumns = [
|
||||
{
|
||||
name: 'Name',
|
||||
type: 'string',
|
||||
jsonPath: '.metadata.name',
|
||||
},
|
||||
{
|
||||
name: 'Timestamp',
|
||||
type: 'string',
|
||||
jsonPath: '.metadata.creationTimestamp',
|
||||
},
|
||||
]
|
||||
|
||||
const columnsOverrides = useCrdResources({
|
||||
clusterName: cluster,
|
||||
crdName: 'customcolumnsoverrides',
|
||||
apiGroup: BASE_API_GROUP,
|
||||
apiVersion: BASE_API_VERSION,
|
||||
})
|
||||
|
||||
const {
|
||||
ensuredCustomOverrides,
|
||||
ensuredCustomOverridesUndefinedValues,
|
||||
ensuredCustomOverridesTrimLengths,
|
||||
ensuredCustomOverridesColWidths,
|
||||
} = parseCustomOverrides({ columnsOverridesData: columnsOverrides.data, overrideType: `v1/${typeName}` })
|
||||
|
||||
const { data: tableMappingsData } = useDirectUnknownResource<TTableMappingResponse>({
|
||||
uri: `/api/clusters/${cluster}/k8s/apis/${BASE_API_GROUP}/${BASE_API_VERSION}/tableurimappings/`,
|
||||
refetchInterval: 5000,
|
||||
queryKey: ['tableMappings', cluster || 'no-cluster'],
|
||||
isEnabled: cluster !== undefined,
|
||||
})
|
||||
|
||||
const tableMappingsDataSpecs = tableMappingsData?.items.map(({ spec }) => spec)
|
||||
const tableMappingSpecific = tableMappingsDataSpecs
|
||||
? prepareTableMappings({
|
||||
data: tableMappingsDataSpecs,
|
||||
clusterName: params.clusterName,
|
||||
projectName: params.projectName,
|
||||
instanceName: params.instanceName,
|
||||
namespace: params.namespace,
|
||||
syntheticProject: params.syntheticProject,
|
||||
entryType: params.entryType,
|
||||
apiGroup: params.apiGroup,
|
||||
apiVersion: params.apiVersion,
|
||||
typeName: params.typeName,
|
||||
entryName: params.entryName,
|
||||
apiExtensionVersion: params.apiExtensionVersion,
|
||||
crdName: params.crdName,
|
||||
pathname,
|
||||
})
|
||||
: undefined
|
||||
|
||||
const onDeleteHandle = (name: string, endpoint: string) => {
|
||||
setIsDeleteModalOpen({ name, endpoint })
|
||||
}
|
||||
@@ -193,13 +130,25 @@ export const TableBuiltinInfo: FC<TTableBuiltinInfoProps> = ({ namespace, typeNa
|
||||
<OverflowMaxHeightContainer $maxHeight={height}>
|
||||
{!error && data && (
|
||||
<EnrichedTableProvider
|
||||
customizationId={`default-/v1/${typeName}`}
|
||||
tableMappingsReplaceValues={{
|
||||
clusterName: params.clusterName,
|
||||
projectName: params.projectName,
|
||||
instanceName: params.instanceName,
|
||||
namespace: params.namespace,
|
||||
syntheticProject: params.syntheticProject,
|
||||
entryType: params.entryType,
|
||||
apiGroup: params.apiGroup,
|
||||
apiVersion: params.apiVersion,
|
||||
typeName: params.typeName,
|
||||
entryName: params.entryName,
|
||||
apiExtensionVersion: params.apiExtensionVersion,
|
||||
crdName: params.crdName,
|
||||
}}
|
||||
cluster={cluster}
|
||||
theme={theme}
|
||||
baseprefix={inside ? `${baseprefix}/inside` : baseprefix}
|
||||
dataItems={data.items}
|
||||
additionalPrinterColumns={ensuredCustomOverrides || additionalPrinterColumns}
|
||||
additionalPrinterColumnsUndefinedValues={ensuredCustomOverridesUndefinedValues}
|
||||
additionalPrinterColumnsTrimLengths={ensuredCustomOverridesTrimLengths}
|
||||
additionalPrinterColumnsColWidths={ensuredCustomOverridesColWidths}
|
||||
dataForControls={{
|
||||
cluster,
|
||||
syntheticProject: params.syntheticProject,
|
||||
@@ -216,8 +165,6 @@ export const TableBuiltinInfo: FC<TTableBuiltinInfoProps> = ({ namespace, typeNa
|
||||
canDelete: isNamespaced ? true : deletePermission.data?.status.allowed,
|
||||
},
|
||||
}}
|
||||
pathToNavigate={tableMappingSpecific?.pathToNavigate}
|
||||
recordKeysForNavigation={tableMappingSpecific?.keysToParse}
|
||||
selectData={{
|
||||
selectedRowKeys,
|
||||
onChange: (selectedRowKeys: React.Key[], selectedRowsData: { name: string; endpoint: string }[]) => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React, { FC, useState, useEffect } from 'react'
|
||||
// import { Typography, Spin, Alert, Tabs } from 'antd'
|
||||
import { Spin, Alert } from 'antd'
|
||||
import { usePermissions, checkIfApiInstanceNamespaceScoped, useCrdData } from '@prorobotech/openapi-k8s-toolkit'
|
||||
import { useSelector } from 'react-redux'
|
||||
@@ -102,54 +101,3 @@ export const TableCrdInfo: FC<TTableCrdInfoProps> = ({
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
// return (
|
||||
// <Tabs defaultActiveKey="instances">
|
||||
// <Tabs.TabPane tab="Details" key="details">
|
||||
// {isPending && <Spin />}
|
||||
// {!error && data && (
|
||||
// <>
|
||||
// <div>
|
||||
// <Typography.Text type="secondary">Kind Name: </Typography.Text>
|
||||
// <Typography.Text>{data.spec.names.kind}</Typography.Text>
|
||||
// </div>
|
||||
// <div>
|
||||
// <Typography.Text type="secondary">Plural Name: </Typography.Text>
|
||||
// <Typography.Text>{data.spec.names.plural}</Typography.Text>
|
||||
// </div>
|
||||
// <div>
|
||||
// <Typography.Text type="secondary">Versions: </Typography.Text>
|
||||
// <Typography.Text>
|
||||
// {data.spec.versions.length > 0 && data.spec.versions.map(({ name }) => name).join(', ')}
|
||||
// </Typography.Text>
|
||||
// </div>
|
||||
// </>
|
||||
// )}
|
||||
// {error && <Alert message={`An error has occurred: ${error?.message} `} type="error" />}
|
||||
// </Tabs.TabPane>
|
||||
// <Tabs.TabPane tab="Instances" key="instances">
|
||||
// {isPending && <Spin />}
|
||||
// {error && <Alert message={`An error has occurred: ${error?.message} `} type="error" />}
|
||||
// {!error && data && data.spec && (
|
||||
// <ResourceInfo
|
||||
// clusterName={cluster}
|
||||
// namespace={namespace}
|
||||
// crdName={crdName}
|
||||
// crdPluralName={data.spec.names.plural}
|
||||
// apiGroup={data.spec.group}
|
||||
// apiVersion={apiVersion}
|
||||
// apiExtensionVersion={apiExtensionVersion}
|
||||
// crdAdditionalPrinterColumns={
|
||||
// data.spec.versions.find(({ name }) => name === apiVersion)?.additionalPrinterColumns
|
||||
// }
|
||||
// permissions={{
|
||||
// canCreate: isNamespaced ? true : createPermission.data?.status.allowed,
|
||||
// canUpdate: isNamespaced ? true : updatePermission.data?.status.allowed,
|
||||
// canDelete: isNamespaced ? true : deletePermission.data?.status.allowed,
|
||||
// }}
|
||||
// />
|
||||
// )}
|
||||
// </Tabs.TabPane>
|
||||
// </Tabs>
|
||||
// )
|
||||
// }
|
||||
|
||||
@@ -1,21 +1,16 @@
|
||||
import React, { FC, useState, useEffect } from 'react'
|
||||
import { useNavigate, useParams, useLocation } from 'react-router-dom'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
import { Spin, Alert, Button, Flex } from 'antd'
|
||||
import { PlusOutlined, ClearOutlined, MinusOutlined } from '@ant-design/icons'
|
||||
import { useSelector } from 'react-redux'
|
||||
import { RootState } from 'store/store'
|
||||
import {
|
||||
EnrichedTableProvider,
|
||||
useDirectUnknownResource,
|
||||
DeleteModal,
|
||||
DeleteModalMany,
|
||||
TAdditionalPrinterColumns,
|
||||
TTableMappingResponse,
|
||||
useCrdResources,
|
||||
prepareTableMappings,
|
||||
parseCustomOverrides,
|
||||
} from '@prorobotech/openapi-k8s-toolkit'
|
||||
import { BASE_API_GROUP, BASE_API_VERSION } from 'constants/customizationApiGroupAndVersion'
|
||||
import { FlexGrow, OverflowMaxHeightContainer, MarginTopContainer } from 'components'
|
||||
import { TABLE_PROPS } from 'constants/tableProps'
|
||||
import {
|
||||
@@ -57,7 +52,6 @@ export const ResourceInfo: FC<TResourceInfoProps> = ({
|
||||
inside,
|
||||
}) => {
|
||||
const navigate = useNavigate()
|
||||
const { pathname } = useLocation()
|
||||
const params = useParams()
|
||||
const cluster = useSelector((state: RootState) => state.cluster.cluster)
|
||||
const theme = useSelector((state: RootState) => state.openapiTheme.theme)
|
||||
@@ -117,50 +111,6 @@ export const ResourceInfo: FC<TResourceInfoProps> = ({
|
||||
}
|
||||
}
|
||||
|
||||
const columnsOverrides = useCrdResources({
|
||||
clusterName,
|
||||
crdName: 'customcolumnsoverrides',
|
||||
apiGroup: BASE_API_GROUP,
|
||||
apiVersion: BASE_API_VERSION,
|
||||
})
|
||||
|
||||
const {
|
||||
ensuredCustomOverrides,
|
||||
ensuredCustomOverridesUndefinedValues,
|
||||
ensuredCustomOverridesTrimLengths,
|
||||
ensuredCustomOverridesColWidths,
|
||||
} = parseCustomOverrides({
|
||||
columnsOverridesData: columnsOverrides.data,
|
||||
overrideType: `${apiGroup}/${apiVersion}/${crdPluralName}`,
|
||||
})
|
||||
|
||||
const { data: tableMappingsData } = useDirectUnknownResource<TTableMappingResponse>({
|
||||
uri: `/api/clusters/${cluster}/k8s/apis/${BASE_API_GROUP}/${BASE_API_VERSION}/tableurimappings/`,
|
||||
refetchInterval: 5000,
|
||||
queryKey: ['tableMappings', cluster || 'no-cluster'],
|
||||
isEnabled: cluster !== undefined,
|
||||
})
|
||||
|
||||
const tableMappingsDataSpecs = tableMappingsData?.items.map(({ spec }) => spec)
|
||||
const tableMappingSpecific = tableMappingsDataSpecs
|
||||
? prepareTableMappings({
|
||||
data: tableMappingsDataSpecs,
|
||||
clusterName: params.clusterName,
|
||||
projectName: params.projectName,
|
||||
instanceName: params.instanceName,
|
||||
namespace: params.namespace,
|
||||
syntheticProject: params.syntheticProject,
|
||||
entryType: params.entryType,
|
||||
apiGroup: params.apiGroup,
|
||||
apiVersion: params.apiVersion,
|
||||
typeName: params.typeName,
|
||||
entryName: params.entryName,
|
||||
apiExtensionVersion: params.apiExtensionVersion,
|
||||
crdName: params.crdName,
|
||||
pathname,
|
||||
})
|
||||
: undefined
|
||||
|
||||
const onDeleteHandle = (name: string, endpoint: string) => {
|
||||
setIsDeleteModalOpen({ name, endpoint })
|
||||
}
|
||||
@@ -177,14 +127,27 @@ export const ResourceInfo: FC<TResourceInfoProps> = ({
|
||||
<OverflowMaxHeightContainer $maxHeight={height}>
|
||||
{!error && data && (
|
||||
<EnrichedTableProvider
|
||||
customizationId={`default-/${apiGroup}/${apiVersion}/${crdPluralName}`}
|
||||
tableMappingsReplaceValues={{
|
||||
clusterName: params.clusterName,
|
||||
projectName: params.projectName,
|
||||
instanceName: params.instanceName,
|
||||
namespace: params.namespace,
|
||||
syntheticProject: params.syntheticProject,
|
||||
entryType: params.entryType,
|
||||
apiGroup: params.apiGroup,
|
||||
apiVersion: params.apiVersion,
|
||||
typeName: params.typeName,
|
||||
entryName: params.entryName,
|
||||
apiExtensionVersion: params.apiExtensionVersion,
|
||||
crdName: params.crdName,
|
||||
}}
|
||||
forceDefaultAdditionalPrinterColumns={crdAdditionalPrinterColumns}
|
||||
cluster={cluster}
|
||||
theme={theme}
|
||||
baseprefix={inside ? `${baseprefix}/inside` : baseprefix}
|
||||
dataItems={data.items}
|
||||
resourceSchema={resourceSchema}
|
||||
additionalPrinterColumns={ensuredCustomOverrides || crdAdditionalPrinterColumns}
|
||||
additionalPrinterColumnsUndefinedValues={ensuredCustomOverridesUndefinedValues}
|
||||
additionalPrinterColumnsTrimLengths={ensuredCustomOverridesTrimLengths}
|
||||
additionalPrinterColumnsColWidths={ensuredCustomOverridesColWidths}
|
||||
dataForControls={{
|
||||
cluster,
|
||||
syntheticProject: params.syntheticProject,
|
||||
@@ -201,8 +164,6 @@ export const ResourceInfo: FC<TResourceInfoProps> = ({
|
||||
canDelete: permissions.canDelete,
|
||||
},
|
||||
}}
|
||||
pathToNavigate={tableMappingSpecific?.pathToNavigate}
|
||||
recordKeysForNavigation={tableMappingSpecific?.keysToParse}
|
||||
selectData={{
|
||||
selectedRowKeys,
|
||||
onChange: (selectedRowKeys: React.Key[], selectedRowsData: { name: string; endpoint: string }[]) => {
|
||||
|
||||
@@ -1,25 +1,18 @@
|
||||
/* eslint-disable max-lines-per-function */
|
||||
import React, { FC, useState, useEffect } from 'react'
|
||||
import { useNavigate, useParams, useLocation } from 'react-router-dom'
|
||||
import { useNavigate, useParams } from 'react-router-dom'
|
||||
import { Spin, Alert, Button, Flex } from 'antd'
|
||||
import { PlusOutlined, ClearOutlined, MinusOutlined } from '@ant-design/icons'
|
||||
import { useSelector } from 'react-redux'
|
||||
import { RootState } from 'store/store'
|
||||
import {
|
||||
EnrichedTableProvider,
|
||||
useDirectUnknownResource,
|
||||
usePermissions,
|
||||
DeleteModal,
|
||||
DeleteModalMany,
|
||||
checkIfApiInstanceNamespaceScoped,
|
||||
TTableMappingResponse,
|
||||
TAdditionalPrinterColumns,
|
||||
prepareTableMappings,
|
||||
useApiResources,
|
||||
useCrdResources,
|
||||
parseCustomOverrides,
|
||||
} from '@prorobotech/openapi-k8s-toolkit'
|
||||
import { BASE_API_GROUP, BASE_API_VERSION } from 'constants/customizationApiGroupAndVersion'
|
||||
import { FlexGrow, OverflowMaxHeightContainer, MarginTopContainer } from 'components'
|
||||
import { TABLE_PROPS } from 'constants/tableProps'
|
||||
import {
|
||||
@@ -49,7 +42,6 @@ export const TableNonCrdInfo: FC<TTableNonCrdInfoProps> = ({
|
||||
inside,
|
||||
}) => {
|
||||
const navigate = useNavigate()
|
||||
const { pathname } = useLocation()
|
||||
const params = useParams()
|
||||
const cluster = useSelector((state: RootState) => state.cluster.cluster)
|
||||
const theme = useSelector((state: RootState) => state.openapiTheme.theme)
|
||||
@@ -136,63 +128,6 @@ export const TableNonCrdInfo: FC<TTableNonCrdInfoProps> = ({
|
||||
limit,
|
||||
})
|
||||
|
||||
const columnsOverrides = useCrdResources({
|
||||
clusterName: cluster,
|
||||
crdName: 'customcolumnsoverrides',
|
||||
apiGroup: BASE_API_GROUP,
|
||||
apiVersion: BASE_API_VERSION,
|
||||
})
|
||||
|
||||
const additionalPrinterColumns: TAdditionalPrinterColumns = [
|
||||
{
|
||||
name: 'Name',
|
||||
type: 'string',
|
||||
jsonPath: '.metadata.name',
|
||||
},
|
||||
{
|
||||
name: 'Timestamp',
|
||||
type: 'string',
|
||||
jsonPath: '.metadata.creationTimestamp',
|
||||
},
|
||||
]
|
||||
|
||||
const {
|
||||
ensuredCustomOverrides,
|
||||
ensuredCustomOverridesUndefinedValues,
|
||||
ensuredCustomOverridesTrimLengths,
|
||||
ensuredCustomOverridesColWidths,
|
||||
} = parseCustomOverrides({
|
||||
columnsOverridesData: columnsOverrides.data,
|
||||
overrideType: `${apiGroup}/${apiVersion}/${typeName}`,
|
||||
})
|
||||
|
||||
const { data: tableMappingsData } = useDirectUnknownResource<TTableMappingResponse>({
|
||||
uri: `/api/clusters/${cluster}/k8s/apis/${BASE_API_GROUP}/${BASE_API_VERSION}/tableurimappings/`,
|
||||
refetchInterval: 5000,
|
||||
queryKey: ['tableMappings', cluster || 'no-cluster'],
|
||||
isEnabled: cluster !== undefined,
|
||||
})
|
||||
|
||||
const tableMappingsDataSpecs = tableMappingsData?.items.map(({ spec }) => spec)
|
||||
const tableMappingSpecific = tableMappingsDataSpecs
|
||||
? prepareTableMappings({
|
||||
data: tableMappingsDataSpecs,
|
||||
clusterName: params.clusterName,
|
||||
projectName: params.projectName,
|
||||
instanceName: params.instanceName,
|
||||
namespace: params.namespace,
|
||||
syntheticProject: params.syntheticProject,
|
||||
entryType: params.entryType,
|
||||
apiGroup: params.apiGroup,
|
||||
apiVersion: params.apiVersion,
|
||||
typeName: params.typeName,
|
||||
entryName: params.entryName,
|
||||
apiExtensionVersion: params.apiExtensionVersion,
|
||||
crdName: params.crdName,
|
||||
pathname,
|
||||
})
|
||||
: undefined
|
||||
|
||||
const onDeleteHandle = (name: string, endpoint: string) => {
|
||||
setIsDeleteModalOpen({ name, endpoint })
|
||||
}
|
||||
@@ -209,13 +144,25 @@ export const TableNonCrdInfo: FC<TTableNonCrdInfoProps> = ({
|
||||
<OverflowMaxHeightContainer $maxHeight={height}>
|
||||
{!error && data && (
|
||||
<EnrichedTableProvider
|
||||
customizationId={`default-/${apiGroup}/${apiVersion}/${typeName}`}
|
||||
tableMappingsReplaceValues={{
|
||||
clusterName: params.clusterName,
|
||||
projectName: params.projectName,
|
||||
instanceName: params.instanceName,
|
||||
namespace: params.namespace,
|
||||
syntheticProject: params.syntheticProject,
|
||||
entryType: params.entryType,
|
||||
apiGroup: params.apiGroup,
|
||||
apiVersion: params.apiVersion,
|
||||
typeName: params.typeName,
|
||||
entryName: params.entryName,
|
||||
apiExtensionVersion: params.apiExtensionVersion,
|
||||
crdName: params.crdName,
|
||||
}}
|
||||
cluster={cluster}
|
||||
theme={theme}
|
||||
baseprefix={inside ? `${baseprefix}/inside` : baseprefix}
|
||||
dataItems={data.items}
|
||||
additionalPrinterColumns={ensuredCustomOverrides || additionalPrinterColumns}
|
||||
additionalPrinterColumnsUndefinedValues={ensuredCustomOverridesUndefinedValues}
|
||||
additionalPrinterColumnsTrimLengths={ensuredCustomOverridesTrimLengths}
|
||||
additionalPrinterColumnsColWidths={ensuredCustomOverridesColWidths}
|
||||
dataForControls={{
|
||||
cluster,
|
||||
syntheticProject: params.syntheticProject,
|
||||
@@ -232,8 +179,6 @@ export const TableNonCrdInfo: FC<TTableNonCrdInfoProps> = ({
|
||||
canDelete: isNamespaced ? true : deletePermission.data?.status.allowed,
|
||||
},
|
||||
}}
|
||||
pathToNavigate={tableMappingSpecific?.pathToNavigate}
|
||||
recordKeysForNavigation={tableMappingSpecific?.keysToParse}
|
||||
selectData={{
|
||||
selectedRowKeys,
|
||||
onChange: (selectedRowKeys: React.Key[], selectedRowsData: { name: string; endpoint: string }[]) => {
|
||||
|
||||
Reference in New Issue
Block a user