diff --git a/packages/refine/src/App.tsx b/packages/refine/src/App.tsx index 542d4fde..584cd048 100644 --- a/packages/refine/src/App.tsx +++ b/packages/refine/src/App.tsx @@ -1,171 +1,174 @@ import { createBrowserHistory } from 'history'; -import React, { useMemo } from 'react'; -import { useTranslation } from 'react-i18next'; -import { Route, Router } from 'react-router-dom'; -import { Layout } from './components'; -import { Dovetail } from './Dovetail'; -import { ConfigMapConfig } from './pages/configmaps'; -import { CronJobForm, CronJobList, CronJobShow } from './pages/cronjobs'; -import { DaemonSetForm, DaemonSetList, DaemonSetShow } from './pages/daemonsets'; -import { DeploymentForm, DeploymentList, DeploymentShow } from './pages/deployments'; -import { JobConfig } from './pages/jobs'; -import { PodShow, PodList, PodForm } from './pages/pods'; -import { SecretsConfig } from './pages/secrets'; -import { ServicesConfig } from './pages/services'; -import { StatefulSetShow, StatefulSetList, StatefulSetForm } from './pages/statefulsets'; - -import { RESOURCE_GROUP, ResourceConfig } from './types'; - -function App() { - const { t } = useTranslation(); - const histroy = createBrowserHistory(); - - const resourcesConfig = useMemo(() => { - return [ - { - name: 'cronjobs', - basePath: '/apis/batch/v1beta1', - kind: 'CronJob', - parent: RESOURCE_GROUP.WORKLOAD, - label: 'CronJobs', - isCustom: true, - }, - { - name: 'daemonsets', - basePath: '/apis/apps/v1', - kind: 'DaemonSet', - parent: RESOURCE_GROUP.WORKLOAD, - label: 'DaemonSets', - isCustom: true, - }, - { - name: 'deployments', - basePath: '/apis/apps/v1', - kind: 'Deployment', - parent: RESOURCE_GROUP.WORKLOAD, - label: 'Deployments', - isCustom: true, - }, - { - name: 'statefulsets', - basePath: '/apis/apps/v1', - kind: 'StatefulSet', - parent: RESOURCE_GROUP.WORKLOAD, - label: 'StatefulSets', - isCustom: true, - }, - { - name: 'pods', - basePath: '/api/v1', - kind: 'Pod', - parent: RESOURCE_GROUP.WORKLOAD, - label: 'Pods', - isCustom: true, - }, - JobConfig, - ConfigMapConfig, - SecretsConfig, - ServicesConfig, - ]; - }, []); - - const refineResources = useMemo(() => { - return [ - { - name: t('dovetail.cluster'), - identifier: RESOURCE_GROUP.CLUSTER, - }, - { - name: t('dovetail.workload'), - identifier: RESOURCE_GROUP.WORKLOAD, - }, - { - name: t('dovetail.network'), - identifier: RESOURCE_GROUP.NETWORK, - }, - { - name: t('dovetail.storage'), - identifier: RESOURCE_GROUP.STORAGE, - }, - ]; - }, [t]); - - return ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ); -} - -export default App; + import React, { useMemo } from 'react'; + import { useTranslation } from 'react-i18next'; + import { Route, Router } from 'react-router-dom'; + import { Layout } from './components'; + import { Dovetail } from './Dovetail'; + import { ConfigMapConfig } from './pages/configmaps'; + import { NetworkPolicyConfig } from './pages/networkpolicies'; + import { CronJobForm, CronJobList, CronJobShow } from './pages/cronjobs'; + import { DaemonSetForm, DaemonSetList, DaemonSetShow } from './pages/daemonsets'; + import { DeploymentForm, DeploymentList, DeploymentShow } from './pages/deployments'; + import { JobConfig } from './pages/jobs'; + import { PodShow, PodList, PodForm } from './pages/pods'; + import { SecretsConfig } from './pages/secrets'; + import { ServicesConfig } from './pages/services'; + import { StatefulSetShow, StatefulSetList, StatefulSetForm } from './pages/statefulsets'; + + import { RESOURCE_GROUP, ResourceConfig } from './types'; + + function App() { + const { t } = useTranslation(); + const histroy = createBrowserHistory(); + + const resourcesConfig = useMemo(() => { + return [ + { + name: 'cronjobs', + basePath: '/apis/batch/v1beta1', + kind: 'CronJob', + parent: RESOURCE_GROUP.WORKLOAD, + label: 'CronJobs', + isCustom: true, + }, + { + name: 'daemonsets', + basePath: '/apis/apps/v1', + kind: 'DaemonSet', + parent: RESOURCE_GROUP.WORKLOAD, + label: 'DaemonSets', + isCustom: true, + }, + { + name: 'deployments', + basePath: '/apis/apps/v1', + kind: 'Deployment', + parent: RESOURCE_GROUP.WORKLOAD, + label: 'Deployments', + isCustom: true, + }, + { + name: 'statefulsets', + basePath: '/apis/apps/v1', + kind: 'StatefulSet', + parent: RESOURCE_GROUP.WORKLOAD, + label: 'StatefulSets', + isCustom: true, + }, + { + name: 'pods', + basePath: '/api/v1', + kind: 'Pod', + parent: RESOURCE_GROUP.WORKLOAD, + label: 'Pods', + isCustom: true, + }, + JobConfig, + ConfigMapConfig, + SecretsConfig, + ServicesConfig, + NetworkPolicyConfig, + ]; + }, []); + + const refineResources = useMemo(() => { + return [ + { + name: t('dovetail.cluster'), + identifier: RESOURCE_GROUP.CLUSTER, + }, + { + name: t('dovetail.workload'), + identifier: RESOURCE_GROUP.WORKLOAD, + }, + { + name: t('dovetail.network'), + identifier: RESOURCE_GROUP.NETWORK, + }, + { + name: t('dovetail.storage'), + identifier: RESOURCE_GROUP.STORAGE, + }, + ]; + }, [t]); + + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ); + } + + export default App; + \ No newline at end of file diff --git a/packages/refine/src/components/ShowContent/fields.tsx b/packages/refine/src/components/ShowContent/fields.tsx index ce7ea255..8388bb8a 100644 --- a/packages/refine/src/components/ShowContent/fields.tsx +++ b/packages/refine/src/components/ShowContent/fields.tsx @@ -1,166 +1,216 @@ import { i18n } from 'i18next'; -import { ExtendObjectMeta } from 'k8s-api-provider'; -import { Condition } from 'kubernetes-types/meta/v1'; -import React from 'react'; -import { JobModel, ResourceModel, WorkloadModel } from '../../model'; -import { ConditionsTable } from '../ConditionsTable'; -import { CronjobJobsTable } from '../CronjobJobsTable'; -import { ImageNames } from '../ImageNames'; -import { KeyValue } from '../KeyValue'; -import Time from '../Time'; -import { WorkloadPodsTable } from '../WorkloadPodsTable'; -import { WorkloadReplicas } from '../WorkloadReplicas'; -import { ShowField } from '../../types'; - -export const ImageField = (i18n: i18n): ShowField => { - return { - key: 'Image', - title: i18n.t('image'), - path: ['imageNames'], - render(value) { - return ; - }, + import { ExtendObjectMeta } from 'k8s-api-provider'; + import { Condition } from 'kubernetes-types/meta/v1'; + import React from 'react'; + import { JobModel, ResourceModel, WorkloadModel } from '../../model'; + import { ConditionsTable } from '../ConditionsTable'; + import { CronjobJobsTable } from '../CronjobJobsTable'; + import { ImageNames } from '../ImageNames'; + import { KeyValue } from '../KeyValue'; + import Time from '../Time'; + import { WorkloadPodsTable } from '../WorkloadPodsTable'; + import { WorkloadReplicas } from '../WorkloadReplicas'; + import { ShowField } from '../../types'; + + export const ImageField = (i18n: i18n): ShowField => { + return { + key: 'Image', + title: i18n.t('image'), + path: ['imageNames'], + render(value) { + return ; + }, + }; }; -}; - -export const ReplicaField = (i18n: i18n): ShowField => { - return { - key: 'Replicas', - title: i18n.t('replicas'), - path: ['status', 'replicas'], - render: (_, record) => { - return ; - }, + + export const ReplicaField = (i18n: i18n): ShowField => { + return { + key: 'Replicas', + title: i18n.t('replicas'), + path: ['status', 'replicas'], + render: (_, record) => { + return ; + }, + }; }; -}; - -export const ConditionsField = (i18n: i18n): ShowField => { - return { - key: 'Conditions', - title: i18n.t('condition'), - path: ['status', 'conditions'], - render: value => { - return ; - }, + + export const ConditionsField = (i18n: i18n): ShowField => { + return { + key: 'Conditions', + title: i18n.t('condition'), + path: ['status', 'conditions'], + render: value => { + return ; + }, + }; }; -}; - -export const PodsField = (_: i18n): ShowField => { - return { - key: 'pods', - title: 'Pods', - path: [], - render: (_, record) => { - return ( - { - return r.kind === 'Pod' && r.type === 'creates'; - })?.selector - } - /> - ); - }, + + export const PodsField = (_: i18n): ShowField => { + return { + key: 'pods', + title: 'Pods', + path: [], + render: (_, record) => { + return ( + { + return r.kind === 'Pod' && r.type === 'creates'; + })?.selector + } + /> + ); + }, + }; }; -}; - -export const JobsField = (_: i18n): ShowField => { - return { - key: 'jobs', - title: 'Jobs', - path: [], - render: (_, record) => { - return ( - - ); - }, + + export const JobsField = (_: i18n): ShowField => { + return { + key: 'jobs', + title: 'Jobs', + path: [], + render: (_, record) => { + return ( + + ); + }, + }; }; -}; - -export const DataField = (i18n: i18n): ShowField => { - return { - key: 'data', - title: i18n.t('data'), - path: ['rawYaml', 'data'], - render: val => { - return } />; - }, + + export const DataField = (i18n: i18n): ShowField => { + return { + key: 'data', + title: i18n.t('data'), + path: ['rawYaml', 'data'], + render: val => { + return } />; + }, + }; }; -}; - -export const SecretDataField = (i18n: i18n): ShowField => { - return { - key: 'data', - title: i18n.t('data'), - path: ['rawYaml', 'data'], - render: val => { - const decodeVal: Record = {}; - for (const key in val as Record) { - decodeVal[key] = atob((val as Record)[key]); - } - return ; - }, + + export const SecretDataField = (i18n: i18n): ShowField => { + return { + key: 'data', + title: i18n.t('data'), + path: ['rawYaml', 'data'], + render: val => { + const decodeVal: Record = {}; + for (const key in val as Record) { + decodeVal[key] = atob((val as Record)[key]); + } + return ; + }, + }; }; -}; - -export const StartTimeField = (i18n: i18n): ShowField => { - return { - key: 'started', - title: i18n.t('started'), - path: ['status', 'startTime'], - render(value) { - return