factory improvement

This commit is contained in:
typescreep
2025-05-28 13:45:03 +03:00
parent 8316913245
commit 25e9d8841a
3 changed files with 34 additions and 8 deletions

10
package-lock.json generated
View File

@@ -11,8 +11,8 @@
"@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.16",
"@readme/openapi-parser": "^4.0.0",
"@prorobotech/openapi-k8s-toolkit": "^0.0.1-alpha.17",
"@readme/openapi-parser": "4.0.0",
"@reduxjs/toolkit": "2.2.5",
"@tanstack/react-query": "5.62.2",
"@tanstack/react-query-devtools": "5.62.2",
@@ -2752,9 +2752,9 @@
}
},
"node_modules/@prorobotech/openapi-k8s-toolkit": {
"version": "0.0.1-alpha.16",
"resolved": "https://registry.npmjs.org/@prorobotech/openapi-k8s-toolkit/-/openapi-k8s-toolkit-0.0.1-alpha.16.tgz",
"integrity": "sha512-mo+4Fbp+bi1zTuaheq53vpiS9Ole4a823IiwElsY1PM0eJs5EYprqhXI7l5BRlYQTeyL8tDTtfNQ6Ck4wikbAw==",
"version": "0.0.1-alpha.17",
"resolved": "https://registry.npmjs.org/@prorobotech/openapi-k8s-toolkit/-/openapi-k8s-toolkit-0.0.1-alpha.17.tgz",
"integrity": "sha512-nGJXsCN01Q/h4KMrS557xdKdE9XrKDuoepiR9CZf6kQcd/c338TcJ6P8X3CVDCd6hNVJ3QzpPK+0oU6LhArQ4w==",
"license": "MIT",
"dependencies": {
"@monaco-editor/react": "4.6.0",

View File

@@ -17,7 +17,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.16",
"@prorobotech/openapi-k8s-toolkit": "^0.0.1-alpha.17",
"@readme/openapi-parser": "4.0.0",
"@reduxjs/toolkit": "2.2.5",
"@tanstack/react-query": "5.62.2",

View File

@@ -1,6 +1,32 @@
import React, { FC } from 'react'
import { DynamicExample } from '@prorobotech/openapi-k8s-toolkit'
import { useParams } from 'react-router-dom'
import {
DynamicComponents,
DynamicRendererWithProviders,
TDynamicComponentsAppTypeMap,
useDirectUnknownResource,
TFactoryResponse,
} from '@prorobotech/openapi-k8s-toolkit'
import { useSelector } from 'react-redux'
import { RootState } from 'store/store'
import { BASE_API_GROUP, BASE_API_VERSION } from 'constants/customizationApiGroupAndVersion'
export const Factory: FC = () => {
return <DynamicExample />
const cluster = useSelector((state: RootState) => state.cluster.cluster)
const { key } = useParams()
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 { spec } = factoryData?.items.find(({ spec }) => spec.key === key) ?? { spec: undefined }
if (!spec) {
return null
}
return <DynamicRendererWithProviders items={spec.data} components={DynamicComponents} />
}