diff --git a/src/apps/console/hooks/use-cluster-status-v3.tsx b/src/apps/console/hooks/use-cluster-status-v3.tsx index e844adf27..7eb96ff75 100644 --- a/src/apps/console/hooks/use-cluster-status-v3.tsx +++ b/src/apps/console/hooks/use-cluster-status-v3.tsx @@ -24,8 +24,8 @@ const ctx = createContext<{ }>({ // clusters: {}, // setClusters: () => {}, - addToWatchList: () => {}, - removeFromWatchList: () => {}, + addToWatchList: () => { }, + removeFromWatchList: () => { }, }); const ClusterStatusProvider = ({ @@ -167,7 +167,6 @@ export const useClusterStatusV3 = ({ }) => { const cCtx = useOutletContext(); - logger.trace('useClusterStatusV3', cCtx); const { clustersMap } = cCtx || {}; const { addToWatchList, removeFromWatchList: _ } = useContext(ctx); @@ -176,11 +175,11 @@ export const useClusterStatusV3 = ({ useDebounce( () => { if (isLoading) { - return () => {}; + return () => { }; } if (!clusterName && !clusterNames) { - return () => {}; + return () => { }; } if (clusterName) { diff --git a/src/apps/console/page-components/handle-environment.tsx b/src/apps/console/page-components/handle-environment.tsx index 4cd9a5762..084882c76 100644 --- a/src/apps/console/page-components/handle-environment.tsx +++ b/src/apps/console/page-components/handle-environment.tsx @@ -13,7 +13,7 @@ import { NameIdView } from '../components/name-id-view'; import { IDialog } from '../components/types.d'; import { useConsoleApi } from '../server/gql/api-provider'; import { IEnvironment } from '../server/gql/queries/environment-queries'; -import { parseName } from '../server/r-utils/common'; +import { parseName, parseNodes } from '../server/r-utils/common'; import { DIALOG_TYPE } from '../utils/commons'; import { useClusterStatusV3 } from '../hooks/use-cluster-status-v3'; @@ -63,25 +63,30 @@ const HandleEnvironment = ({ show, setShow }: IDialog) => { const getClusters = useCallback(async () => { try { - const data = Object.values(clustersMap).map((cm) => { - if (cm == null) { - return {}; - } - const { name, displayName, isOnline } = cm; - return { - label: displayName, - value: name, - ready: isOnline, - disabled: () => !isOnline, + const { data: cl, errors } = await api.listAllClusters({}) + if (errors) { + throw errors[0] + } + + const data = parseNodes(cl).map((c) => { + const n = parseName(c) + let cs = clustersMap[n] + + return ({ + label: c.displayName, + value: n, + ready: cs?.isOnline, + disabled: () => !cs?.isOnline, render: ({ disabled }: { disabled: boolean }) => ( ), - }; - }); + }) + }) + setClusterList(data); } catch (err) { handleError(err); diff --git a/src/apps/console/routes/_main+/$account+/env+/$environment+/workloads+/helm-charts/helm-chart-resources-v2.tsx b/src/apps/console/routes/_main+/$account+/env+/$environment+/workloads+/helm-charts/helm-chart-resources-v2.tsx index 8e05ce27e..f43faa179 100644 --- a/src/apps/console/routes/_main+/$account+/env+/$environment+/workloads+/helm-charts/helm-chart-resources-v2.tsx +++ b/src/apps/console/routes/_main+/$account+/env+/$environment+/workloads+/helm-charts/helm-chart-resources-v2.tsx @@ -2,6 +2,7 @@ import { Trash } from '~/console/components/icons'; import { generateKey, titleCase } from '@kloudlite/design-system/utils'; import { ListItem, + ListItemV2, ListTitle, } from '~/console/components/console-list-components'; import Grid from '~/console/components/grid'; @@ -28,6 +29,8 @@ import ListV2 from '~/console/components/listV2'; import { SyncStatusV2 } from '~/console/components/sync-status'; import { constants } from '~/console/server/utils/constants'; import { IEnvironmentContext } from '../../_layout'; +import { useClusterStatusV3 } from '~/console/hooks/use-cluster-status-v3'; +import { Badge } from '@kloudlite/design-system/atoms/badge'; const RESOURCE_NAME = 'helm chart'; type BaseType = ExtractNodeType; @@ -119,6 +122,12 @@ const GridView = ({ items = [], onAction }: IResource) => { }; const ListView = ({ items = [], onAction }: IResource) => { + const { environment } = useOutletContext(); + const { clustersMap: clusterStatus } = useClusterStatusV3({ + clusterName: environment.clusterName, + }); + + return ( { ], rows: items.map((i) => { const { name, id, updateInfo } = parseItem(i); + const isClusterOnline = + !!clusterStatus[environment.clusterName]?.isOnline; + return { columns: { name: { render: () => , }, - status: { - render: () => , + render: () => { + if (environment.spec?.suspend) { + return null; + } + + if (environment.clusterName === '') { + return ; + } + + if (clusterStatus[environment.clusterName] === undefined) { + return null; + } + + if (!isClusterOnline) { + return Cluster Offline; + } + + return ; + }, }, updated: { render: () => ( diff --git a/src/apps/console/routes/_main+/$account+/environments/clone-environment.tsx b/src/apps/console/routes/_main+/$account+/environments/clone-environment.tsx index 7fa5bd96e..502b2523b 100644 --- a/src/apps/console/routes/_main+/$account+/environments/clone-environment.tsx +++ b/src/apps/console/routes/_main+/$account+/environments/clone-environment.tsx @@ -10,7 +10,7 @@ import { IDialogBase } from '~/console/components/types.d'; import { ClusterSelectItem } from '~/console/page-components/handle-environment'; import { useConsoleApi } from '~/console/server/gql/api-provider'; import { IEnvironments } from '~/console/server/gql/queries/environment-queries'; -import { ExtractNodeType, parseName } from '~/console/server/r-utils/common'; +import { ExtractNodeType, parseName, parseNodes } from '~/console/server/r-utils/common'; import { useReload } from '~/root/lib/client/helpers/reloader'; import useForm, { dummyEvent } from '~/root/lib/client/hooks/use-form'; import Yup from '~/root/lib/server/helpers/yup'; @@ -30,26 +30,29 @@ const Root = (props: IDialog) => { const getClusters = useCallback(async () => { try { - const data = Object.values(clustersMap).map((cm) => { - if (cm == null) { - return {}; - } + const { data: cl, errors } = await api.listAllClusters({}) + if (errors) { + throw errors[0] + } - const { name, displayName, isOnline } = cm; - return { - label: displayName, - value: name, - ready: isOnline, - disabled: () => !isOnline, + const data = parseNodes(cl).map((c) => { + const n = parseName(c) + let cs = clustersMap[n] + return ({ + label: c.displayName, + value: n, + ready: cs?.isOnline, + disabled: () => !cs?.isOnline, render: ({ disabled }: { disabled: boolean }) => ( ), - }; - }); + }) + }) + setClusterList(data); } catch (err) { handleError(err); diff --git a/src/apps/console/routes/_main+/$account+/new-managed-service/managed-service-layout-v2.tsx b/src/apps/console/routes/_main+/$account+/new-managed-service/managed-service-layout-v2.tsx index 822727e8b..4a2d16c78 100644 --- a/src/apps/console/routes/_main+/$account+/new-managed-service/managed-service-layout-v2.tsx +++ b/src/apps/console/routes/_main+/$account+/new-managed-service/managed-service-layout-v2.tsx @@ -33,7 +33,7 @@ import { IMSvPlugin, IMsvPlugins, } from '~/console/server/gql/queries/managed-templates-queries'; -import { parseName } from '~/console/server/r-utils/common'; +import { parseName, parseNodes } from '~/console/server/r-utils/common'; import { keyconstants } from '~/console/server/r-utils/key-constants'; import { ensureAccountClientSide } from '~/console/server/utils/auth-utils'; import { flatM, flatMapValidations } from '~/console/utils/commons'; @@ -201,8 +201,8 @@ const RenderHelmFields = ({ Search for or enter the repo url } - // error={!!errors[fieldKey]} - // message={errors[fieldKey]} + // error={!!errors[fieldKey]} + // message={errors[fieldKey]} /> ); case 'chart.name': @@ -351,8 +351,7 @@ const RenderField = ({ onChange={({ target }) => { onChange(`res.${field.input}`)( dummyEvent( - `${parseFloat(target.value) * (field.multiplier || 1)}${ - field.unit + `${parseFloat(target.value) * (field.multiplier || 1)}${field.unit }` ) ); @@ -397,9 +396,8 @@ const RenderField = ({ if (field.type === 'int-range') { return (
-
{`${field.label}${ - field.required ? ' *' : '' - }`}
+
{`${field.label}${field.required ? ' *' : '' + }`}
@@ -412,16 +410,14 @@ const RenderField = ({ onChange={({ target }) => { onChange(`res.${field.input}.min`)( dummyEvent( - `${parseFloat(target.value) * (field.multiplier || 1)}${ - field.unit + `${parseFloat(target.value) * (field.multiplier || 1)}${field.unit }` ) ); if (qos) { onChange(`res.${field.input}.max`)( dummyEvent( - `${parseFloat(target.value) * (field.multiplier || 1)}${ - field.unit + `${parseFloat(target.value) * (field.multiplier || 1)}${field.unit }` ) ); @@ -441,8 +437,7 @@ const RenderField = ({ onChange={({ target }) => { onChange(`res.${field.input}.max`)( dummyEvent( - `${parseFloat(target.value) * (field.multiplier || 1)}${ - field.unit + `${parseFloat(target.value) * (field.multiplier || 1)}${field.unit }` ) ); @@ -459,9 +454,8 @@ const RenderField = ({ if (field.type === 'Resource') { return (
-
{`${field.label}${ - field.required ? ' *' : '' - }`}
+
{`${field.label}${field.required ? ' *' : '' + }`}
@@ -474,16 +468,14 @@ const RenderField = ({ onChange={({ target }) => { onChange(`res.${field.input}.min`)( dummyEvent( - `${parseFloat(target.value) * (field.multiplier || 1)}${ - field.unit + `${parseFloat(target.value) * (field.multiplier || 1)}${field.unit }` ) ); if (qos) { onChange(`res.${field.input}.max`)( dummyEvent( - `${parseFloat(target.value) * (field.multiplier || 1)}${ - field.unit + `${parseFloat(target.value) * (field.multiplier || 1)}${field.unit }` ) ); @@ -503,8 +495,7 @@ const RenderField = ({ onChange={({ target }) => { onChange(`res.${field.input}.max`)( dummyEvent( - `${parseFloat(target.value) * (field.multiplier || 1)}${ - field.unit + `${parseFloat(target.value) * (field.multiplier || 1)}${field.unit }` ) ); @@ -716,7 +707,7 @@ const FieldView = ({ showclear error={!!errors.clusterName} message={errors.clusterName} - // loading={cIsLoading || byokCIsLoading} + // loading={cIsLoading || byokCIsLoading} /> {getRenderField()} @@ -923,28 +914,29 @@ export const ManagedServiceLayoutV2 = () => { const getClusters = useCallback(async () => { ensureAccountClientSide(params); try { - const data = Object.values(clustersMap).map((cm) => { - if (cm == null) { - return {}; - } - - const { name, displayName, isOnline } = cm; + const { data: cl, errors } = await api.listAllClusters({}) + if (errors) { + throw errors[0] + } - return { - label: displayName, - value: name, - ready: isOnline, - disabled: () => !isOnline, - // eslint-disable-next-line react/no-unused-prop-types + const data = parseNodes(cl).map((c) => { + const n = parseName(c) + let cs = clustersMap[n] + return ({ + label: c.displayName, + value: n, + ready: cs?.isOnline, + disabled: () => !cs?.isOnline, render: ({ disabled }: { disabled: boolean }) => ( ), - }; - }); + }) + }) + setClusterList(data); } catch (err) { handleError(err);