mirror of
https://github.com/outbackdingo/openapi-ui.git
synced 2026-01-27 18:19:50 +00:00
crds sockets
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
import React, { FC, useState, useEffect } from 'react'
|
||||
import { Spin, Alert } from 'antd'
|
||||
import { usePermissions, checkIfApiInstanceNamespaceScoped, useCrdData } from '@prorobotech/openapi-k8s-toolkit'
|
||||
import {
|
||||
usePermissions,
|
||||
checkIfApiInstanceNamespaceScoped,
|
||||
// useCrdData,
|
||||
useK8sSmartResource,
|
||||
TCRD,
|
||||
} from '@prorobotech/openapi-k8s-toolkit'
|
||||
import { useSelector } from 'react-redux'
|
||||
import { RootState } from 'store/store'
|
||||
import { ResourceInfo } from './molecules'
|
||||
@@ -28,12 +34,28 @@ export const TableCrdInfo: FC<TTableCrdInfoProps> = ({
|
||||
|
||||
const [isNamespaced, setIsNamespaced] = useState<boolean>()
|
||||
|
||||
const { isPending, error, data } = useCrdData({
|
||||
clusterName: cluster,
|
||||
crdName,
|
||||
apiExtensionVersion,
|
||||
// const { isPending, error, data } = useCrdData({
|
||||
// clusterName: cluster,
|
||||
// crdName,
|
||||
// apiExtensionVersion,
|
||||
// })
|
||||
|
||||
const {
|
||||
data: dataArr,
|
||||
isLoading: isPending,
|
||||
error,
|
||||
} = useK8sSmartResource<{
|
||||
items: TCRD[]
|
||||
}>({
|
||||
cluster,
|
||||
group: 'apiextensions.k8s.io',
|
||||
version: apiExtensionVersion,
|
||||
plural: 'customresourcedefinitions',
|
||||
fieldSelector: `metadata.name=${crdName}`,
|
||||
})
|
||||
|
||||
const data = dataArr?.items && dataArr.items.length > 0 ? dataArr.items[0] : undefined
|
||||
|
||||
useEffect(() => {
|
||||
if (data && !isPending && !error) {
|
||||
checkIfApiInstanceNamespaceScoped({
|
||||
@@ -79,7 +101,9 @@ export const TableCrdInfo: FC<TTableCrdInfoProps> = ({
|
||||
return (
|
||||
<>
|
||||
{isPending && <Spin />}
|
||||
{error && <Alert message={`An error has occurred: ${error?.message} `} type="error" />}
|
||||
{error && (
|
||||
<Alert message={`An error has occurred: ${typeof error === 'string' ? error : error?.message} `} type="error" />
|
||||
)}
|
||||
{!error && data && data.spec && (
|
||||
<ResourceInfo
|
||||
clusterName={cluster}
|
||||
|
||||
@@ -10,7 +10,9 @@ import {
|
||||
DeleteModal,
|
||||
DeleteModalMany,
|
||||
TAdditionalPrinterColumns,
|
||||
useCrdResources,
|
||||
// useCrdResources,
|
||||
useK8sSmartResource,
|
||||
TJSON,
|
||||
} from '@prorobotech/openapi-k8s-toolkit'
|
||||
import { FlexGrow, OverflowMaxHeightContainer, PaddingContainer } from 'components'
|
||||
import { TABLE_PROPS } from 'constants/tableProps'
|
||||
@@ -92,12 +94,25 @@ export const ResourceInfo: FC<TResourceInfoProps> = ({
|
||||
}
|
||||
}, [])
|
||||
|
||||
const { isPending, error, data } = useCrdResources({
|
||||
clusterName,
|
||||
namespace,
|
||||
apiGroup,
|
||||
apiVersion,
|
||||
crdName: crdPluralName,
|
||||
// const { isPending, error, data } = useCrdResources({
|
||||
// clusterName,
|
||||
// namespace,
|
||||
// apiGroup,
|
||||
// apiVersion,
|
||||
// crdName: crdPluralName,
|
||||
// })
|
||||
|
||||
const {
|
||||
data,
|
||||
isLoading: isPending,
|
||||
error,
|
||||
} = useK8sSmartResource<{
|
||||
items: TJSON[]
|
||||
}>({
|
||||
cluster: clusterName,
|
||||
group: apiGroup,
|
||||
version: apiVersion,
|
||||
plural: crdPluralName,
|
||||
})
|
||||
|
||||
let resourceSchema = {}
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import React, { FC, useState } from 'react'
|
||||
import { Spin, Alert, Segmented } from 'antd'
|
||||
import { useCrdResourceSingle, Spacer } from '@prorobotech/openapi-k8s-toolkit'
|
||||
import {
|
||||
// useCrdResourceSingle,
|
||||
useK8sSmartResource,
|
||||
TSingleResource,
|
||||
Spacer,
|
||||
} from '@prorobotech/openapi-k8s-toolkit'
|
||||
import { useSelector } from 'react-redux'
|
||||
import { RootState } from 'store/store'
|
||||
import { BlackholeForm } from 'components'
|
||||
@@ -41,22 +46,45 @@ export const UpdateCrdsForm: FC<TUpdateCrdsFormProps> = ({
|
||||
onDisabled: onCurrentModeDisabled,
|
||||
}
|
||||
|
||||
const { data, isPending, error } = useCrdResourceSingle({
|
||||
clusterName: cluster,
|
||||
// const { data, isPending, error } = useCrdResourceSingle({
|
||||
// clusterName: cluster,
|
||||
// namespace,
|
||||
// apiGroup,
|
||||
// apiVersion,
|
||||
// crdName: typeName,
|
||||
// entryName,
|
||||
// refetchInterval: false,
|
||||
// })
|
||||
|
||||
const {
|
||||
data: dataArr,
|
||||
isLoading: isPending,
|
||||
error,
|
||||
} = useK8sSmartResource<{
|
||||
items: TSingleResource[]
|
||||
}>({
|
||||
cluster,
|
||||
namespace,
|
||||
apiGroup,
|
||||
apiVersion,
|
||||
crdName: typeName,
|
||||
entryName,
|
||||
refetchInterval: false,
|
||||
group: apiGroup,
|
||||
version: apiVersion,
|
||||
plural: typeName,
|
||||
fieldSelector: `metadata.name=${entryName}`,
|
||||
})
|
||||
|
||||
const data = dataArr?.items && dataArr.items.length > 0 ? dataArr.items[0] : undefined
|
||||
|
||||
if (isPending) {
|
||||
return <Spin />
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return <Alert message={`An error has occurred: ${error?.message} `} type="error" />
|
||||
return (
|
||||
<Alert message={`An error has occurred: ${typeof error === 'string' ? error : error?.message} `} type="error" />
|
||||
)
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
return <Alert message={`An error has occurred: No data `} type="error" />
|
||||
}
|
||||
|
||||
/* eslint-disable-next-line @typescript-eslint/no-unused-vars */
|
||||
|
||||
Reference in New Issue
Block a user