From fc134a5e2e63c9fab96023e31569e1afc5b45038 Mon Sep 17 00:00:00 2001 From: Star Richardson <67430892+alicenstar@users.noreply.github.com> Date: Thu, 19 Oct 2023 10:50:01 -0600 Subject: [PATCH] remove test data, uncomment route protection, fix redirect after license upload --- web/src/Root.tsx | 63 ++-- web/src/components/UploadLicenseFile.tsx | 3 +- .../apps/HelmVMClusterManagement.tsx | 170 +++-------- web/src/components/apps/HelmVMViewNode.jsx | 268 +----------------- 4 files changed, 75 insertions(+), 429 deletions(-) diff --git a/web/src/Root.tsx b/web/src/Root.tsx index 866fb6fd44..86bef0aa94 100644 --- a/web/src/Root.tsx +++ b/web/src/Root.tsx @@ -101,8 +101,6 @@ type State = { selectedAppName: string | null; snapshotInProgressApps: string[]; themeState: ThemeState; - isKurl: boolean | null; - isHelmVM: boolean | null; }; let interval: ReturnType | undefined; @@ -134,8 +132,6 @@ const Root = () => { navbarLogo: null, }, app: null, - isKurl: null, - isHelmVM: null, } ); @@ -307,8 +303,6 @@ const Root = () => { adminConsoleMetadata: data.adminConsoleMetadata, featureFlags: data.consoleFeatureFlags, fetchingMetadata: false, - isKurl: data.isKurl, - isHelmVM: data.isHelmVM, }); }) .catch((err) => { @@ -538,8 +532,7 @@ const Root = () => { appSlugFromMetadata={state.appSlugFromMetadata || ""} fetchingMetadata={state.fetchingMetadata} onUploadSuccess={getAppsList} - isKurl={!!state.isKurl} - isHelmVM={!!state.isHelmVM} + isHelmVM={Boolean(state.adminConsoleMetadata?.isHelmVM)} /> } /> @@ -582,33 +575,33 @@ const Root = () => { } /> } /> - {/* {state.adminConsoleMetadata?.isHelmVM && ( */} - - } - /> - {/* )} */} - {/* {(state.adminConsoleMetadata?.isKurl || - state.adminConsoleMetadata?.isHelmVM) && ( */} - - ) : ( - - ) - } - /> - {/* )} */} - {/* {state.adminConsoleMetadata?.isHelmVM && ( */} - } /> - {/* )} */} + {state.adminConsoleMetadata?.isHelmVM && ( + + } + /> + )} + {(state.adminConsoleMetadata?.isKurl || + state.adminConsoleMetadata?.isHelmVM) && ( + + ) : ( + + ) + } + /> + )} + {state.adminConsoleMetadata?.isHelmVM && ( + } /> + )} } diff --git a/web/src/components/UploadLicenseFile.tsx b/web/src/components/UploadLicenseFile.tsx index 2fe1ed8a12..8992f063b2 100644 --- a/web/src/components/UploadLicenseFile.tsx +++ b/web/src/components/UploadLicenseFile.tsx @@ -68,7 +68,6 @@ type Props = { logo: string | null; snapshot?: { name: string }; isHelmVM: boolean; - isKurl: boolean; }; const UploadLicenseFile = (props: Props) => { @@ -267,7 +266,7 @@ const UploadLicenseFile = (props: Props) => { return; } - if (props.isHelmVM && !props.isKurl) { + if (props.isHelmVM) { navigate(`/${data.slug}/cluster/manage`, { replace: true }); return; } diff --git a/web/src/components/apps/HelmVMClusterManagement.tsx b/web/src/components/apps/HelmVMClusterManagement.tsx index 1101c11352..aa38833731 100644 --- a/web/src/components/apps/HelmVMClusterManagement.tsx +++ b/web/src/components/apps/HelmVMClusterManagement.tsx @@ -1,8 +1,8 @@ +import { useQuery } from "@tanstack/react-query"; import classNames from "classnames"; import MaterialReactTable from "material-react-table"; import React, { ChangeEvent, useMemo, useReducer, useState } from "react"; import Modal from "react-modal"; -import { useQuery } from "@tanstack/react-query"; import { Link, useParams } from "react-router-dom"; import { KotsPageTitle } from "@components/Head"; @@ -14,82 +14,6 @@ import CodeSnippet from "../shared/CodeSnippet"; import "@src/scss/components/apps/HelmVMClusterManagement.scss"; -const testData = { - isHelmVMEnabled: true, - ha: false, - nodes: [ - { - name: "test-helmvm-node", - isConnected: true, - isReady: true, - isPrimaryNode: true, - canDelete: false, - kubeletVersion: "v1.28.2", - cpu: { - capacity: 8, - available: 7.466876775, - }, - memory: { - capacity: 31.33294677734375, - available: 24.23790740966797, - }, - pods: { - capacity: 110, - available: 77, - }, - labels: [ - "beta.kubernetes.io/arch:amd64", - "beta.kubernetes.io/os:linux", - "node-role.kubernetes.io/master:", - "node.kubernetes.io/exclude-from-external-load-balancers:", - "kubernetes.io/arch:amd64", - "kubernetes.io/hostname:laverya-kurl", - "kubernetes.io/os:linux", - "node-role.kubernetes.io/control-plane:", - ], - conditions: { - memoryPressure: false, - diskPressure: false, - pidPressure: false, - ready: true, - }, - }, - { - name: "test-helmvm-worker", - isConnected: true, - isReady: true, - isPrimaryNode: false, - canDelete: false, - kubeletVersion: "v1.28.2", - cpu: { - capacity: 4, - available: 3.761070507, - }, - memory: { - capacity: 15.50936508178711, - available: 11.742542266845703, - }, - pods: { - capacity: 110, - available: 94, - }, - labels: [ - "beta.kubernetes.io/arch:amd64", - "beta.kubernetes.io/os:linux", - "kubernetes.io/arch:amd64", - "kubernetes.io/os:linux", - "kurl.sh/cluster:true", - ], - conditions: { - memoryPressure: false, - diskPressure: false, - pidPressure: false, - ready: true, - }, - }, - ], -}; - type State = { displayAddNode: boolean; confirmDeleteNode: string; @@ -260,15 +184,6 @@ const HelmVMClusterManagement = ({ const NODE_TYPES = ["controller"]; const determineDisabledState = () => { - // if (nodeType === "controller") { - // const numControllers = testData.nodes.reduce((acc, node) => { - // if (node.labels.includes("controller")) { - // acc += 1; - // } - // return acc; - // }, 0); - // return numControllers === 3; - // } return false; }; @@ -338,44 +253,49 @@ const HelmVMClusterManagement = ({ }; const mappedNodes = useMemo(() => { - return (nodesData?.nodes || testData.nodes).map((n) => ({ - name: slug ? ( - n.name - ) : ( - - {n.name} - - ), - roles: ( -
- {n.labels.map((l) => ( - - {l} - - ))} -
- ), - status: n.isReady ? "Ready" : "Not Ready", - cpu: `${calculateUtilization(n.cpu.capacity, n.cpu.available)}%`, - memory: `${calculateUtilization(n.memory.capacity, n.memory.available)}%`, - pods: `${n.pods.capacity - n.pods.available} / ${n.pods.capacity}`, - pause: ( - <> - - - ), - delete: ( - <> - - - ), - })); + return ( + nodesData?.nodes?.map((n) => ({ + name: slug ? ( + n.name + ) : ( + + {n.name} + + ), + roles: ( +
+ {n.labels.map((l) => ( + + {l} + + ))} +
+ ), + status: n.isReady ? "Ready" : "Not Ready", + cpu: `${calculateUtilization(n.cpu.capacity, n.cpu.available)}%`, + memory: `${calculateUtilization( + n.memory.capacity, + n.memory.available + )}%`, + pods: `${n.pods.capacity - n.pods.available} / ${n.pods.capacity}`, + pause: ( + <> + + + ), + delete: ( + <> + + + ), + })) || [] + ); }, [nodesData?.nodes?.toString()]); // #endregion @@ -412,7 +332,7 @@ const HelmVMClusterManagement = ({ {nodesError?.message}

)} - {(nodesData?.nodes || testData?.nodes) && ( + {nodesData?.nodes && ( { const { nodeName } = useParams(); const { data: nodeData } = useQuery({ @@ -306,7 +40,7 @@ const HelmVMViewNode = () => { }, }); - const node = nodeData || testData.nodes[0]; + const node = nodeData; // #region table data const columns = useMemo(