Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove test data, uncomment route protection, fix redirect #4081

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 28 additions & 35 deletions web/src/Root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ type State = {
selectedAppName: string | null;
snapshotInProgressApps: string[];
themeState: ThemeState;
isKurl: boolean | null;
isHelmVM: boolean | null;
};

let interval: ReturnType<typeof setInterval> | undefined;
Expand Down Expand Up @@ -134,8 +132,6 @@ const Root = () => {
navbarLogo: null,
},
app: null,
isKurl: null,
isHelmVM: null,
}
);

Expand Down Expand Up @@ -307,8 +303,6 @@ const Root = () => {
adminConsoleMetadata: data.adminConsoleMetadata,
featureFlags: data.consoleFeatureFlags,
fetchingMetadata: false,
isKurl: data.isKurl,
isHelmVM: data.isHelmVM,
});
})
.catch((err) => {
Expand Down Expand Up @@ -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)}
/>
}
/>
Expand Down Expand Up @@ -582,33 +575,33 @@ const Root = () => {
}
/>
<Route path="/unsupported" element={<UnsupportedBrowser />} />
{/* {state.adminConsoleMetadata?.isHelmVM && ( */}
<Route
path="/:slug/cluster/manage"
element={
<HelmVMClusterManagement
fromLicenseFlow={true}
appName={state.selectedAppName || undefined}
/>
}
/>
{/* )} */}
{/* {(state.adminConsoleMetadata?.isKurl ||
state.adminConsoleMetadata?.isHelmVM) && ( */}
<Route
path="/cluster/manage"
element={
state.adminConsoleMetadata?.isKurl ? (
<KurlClusterManagement />
) : (
<HelmVMClusterManagement />
)
}
/>
{/* )} */}
{/* {state.adminConsoleMetadata?.isHelmVM && ( */}
<Route path="/cluster/:nodeName" element={<HelmVMViewNode />} />
{/* )} */}
{state.adminConsoleMetadata?.isHelmVM && (
<Route
path="/:slug/cluster/manage"
element={
<HelmVMClusterManagement
fromLicenseFlow={true}
appName={state.selectedAppName || undefined}
/>
}
/>
)}
{(state.adminConsoleMetadata?.isKurl ||
state.adminConsoleMetadata?.isHelmVM) && (
<Route
path="/cluster/manage"
element={
state.adminConsoleMetadata?.isKurl ? (
<KurlClusterManagement />
) : (
<HelmVMClusterManagement />
)
}
/>
)}
{state.adminConsoleMetadata?.isHelmVM && (
<Route path="/cluster/:nodeName" element={<HelmVMViewNode />} />
)}
<Route
path="/gitops"
element={<GitOps appName={state.selectedAppName || ""} />}
Expand Down
3 changes: 1 addition & 2 deletions web/src/components/UploadLicenseFile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ type Props = {
logo: string | null;
snapshot?: { name: string };
isHelmVM: boolean;
isKurl: boolean;
};

const UploadLicenseFile = (props: Props) => {
Expand Down Expand Up @@ -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;
}
Expand Down
170 changes: 45 additions & 125 deletions web/src/components/apps/HelmVMClusterManagement.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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;
Expand Down Expand Up @@ -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;
};

Expand Down Expand Up @@ -338,44 +253,49 @@ const HelmVMClusterManagement = ({
};

const mappedNodes = useMemo(() => {
return (nodesData?.nodes || testData.nodes).map((n) => ({
name: slug ? (
n.name
) : (
<Link
to={`/cluster/${n.name}`}
className="tw-font-semibold tw-text-blue-300 hover:tw-underline"
>
{n.name}
</Link>
),
roles: (
<div className="tw-w-full tw-flex tw-flex-wrap tw-gap-1">
{n.labels.map((l) => (
<span
key={l}
className="tw-font-semibold tw-text-xs tw-px-1 tw-rounded-sm tw-border tw-border-solid tw-bg-white tw-border-gray-100"
>
{l}
</span>
))}
</div>
),
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: (
<>
<button className="btn secondary">Pause</button>
</>
),
delete: (
<>
<button className="btn red primary">Delete</button>
</>
),
}));
return (
nodesData?.nodes?.map((n) => ({
name: slug ? (
n.name
) : (
<Link
to={`/cluster/${n.name}`}
className="tw-font-semibold tw-text-blue-300 hover:tw-underline"
>
{n.name}
</Link>
),
roles: (
<div className="tw-w-full tw-flex tw-flex-wrap tw-gap-1">
{n.labels.map((l) => (
<span
key={l}
className="tw-font-semibold tw-text-xs tw-px-1 tw-rounded-sm tw-border tw-border-solid tw-bg-white tw-border-gray-100"
>
{l}
</span>
))}
</div>
),
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: (
<>
<button className="btn secondary">Pause</button>
</>
),
delete: (
<>
<button className="btn red primary">Delete</button>
</>
),
})) || []
);
}, [nodesData?.nodes?.toString()]);
// #endregion

Expand Down Expand Up @@ -412,7 +332,7 @@ const HelmVMClusterManagement = ({
{nodesError?.message}
</p>
)}
{(nodesData?.nodes || testData?.nodes) && (
{nodesData?.nodes && (
<MaterialReactTable
columns={columns}
data={mappedNodes}
Expand Down
Loading
Loading