diff --git a/web/src/components/apps/HelmVMClusterManagement.jsx b/web/src/components/apps/HelmVMClusterManagement.jsx index 5d2ef854af..28d2c56860 100644 --- a/web/src/components/apps/HelmVMClusterManagement.jsx +++ b/web/src/components/apps/HelmVMClusterManagement.jsx @@ -1,6 +1,6 @@ import classNames from "classnames"; import dayjs from "dayjs"; -import React, { useEffect, useReducer } from "react"; +import React, { useEffect, useReducer, useState } from "react"; import Modal from "react-modal"; import { useQuery } from "react-query"; @@ -111,6 +111,8 @@ const HelmVMClusterManagement = () => { drainNodeSuccessful: false, } ); + const [selectedNodeTypes, setSelectedNodeTypes] = useState([]); + const [useStaticToken, setUseStaticToken] = useState(false); const { data: nodes, isLoading: nodesLoading } = useQuery({ queryKey: "helmVmNodes", @@ -309,37 +311,57 @@ const HelmVMClusterManagement = () => { }; const onAddNodeClick = () => { - setState( - { - displayAddNode: true, - }, - async () => { - await generateWorkerAddNodeCommand(); - } - ); - }; - - const onSelectNodeType = (event) => { - const value = event.currentTarget.value; - setState( - { - selectedNodeType: value, - }, - async () => { - if (state.selectedNodeType === "secondary") { - await generateWorkerAddNodeCommand(); - } else { - await generatePrimaryAddNodeCommand(); - } - } - ); + setState({ + displayAddNode: true, + }); }; const ackDeleteNodeError = () => { setState({ deleteNodeError: "" }); }; - const { displayAddNode, generateCommandErrMsg } = state; + const NODE_TYPES = [ + "controlplane", + "db", + "app", + "search", + "webserver", + "jobs", + ]; + + const determineDisabledState = (nodeType, selectedNodeTypes) => { + if (nodeType === "controlplane") { + const numControlPlanes = testData.nodes.reduce((acc, node) => { + if (node.labels.includes("controlplane")) { + acc++; + } + return acc; + }); + return numControlPlanes === 3; + } + if ( + (nodeType === "db" || nodeType === "search") && + selectedNodeTypes.includes("webserver") + ) { + return true; + } + return false; + }; + + const handleSelectNodeType = (e) => { + const nodeType = e.currentTarget.value; + let types = selectedNodeTypes; + + if (nodeType === "webserver") { + types = types.filter((type) => type !== "db" && type !== "search"); + } + + if (selectedNodeTypes.includes(nodeType)) { + setSelectedNodeTypes(types.filter((type) => type !== nodeType)); + } else { + setSelectedNodeTypes([...types, nodeType]); + } + }; if (nodesLoading) { return ( @@ -350,7 +372,7 @@ const HelmVMClusterManagement = () => { } return ( -
Cluster Nodes
-+
This section lists the nodes that are configured and shows the status/health of each. To add additional nodes to this cluster, click the "Add node" button at the bottom of this page. @@ -377,146 +399,113 @@ const HelmVMClusterManagement = () => { ))}
- Add a node -
-- Run this command on the node you wish to join the cluster -
-+ To add a node to this cluster, select the type of node you are + adding, and then select an installation method below. This screen + will automatically show the status when the node successfully joins + the cluster. +
+