Преглед на файлове

Added logic for node status on expanded node view

jnfrati преди 4 години
родител
ревизия
4ccc2f957d
променени са 1 файла, в които са добавени 22 реда и са изтрити 8 реда
  1. 22 8
      dashboard/src/main/home/cluster-dashboard/dashboard/node-view/ExpandedNodeView.tsx

+ 22 - 8
dashboard/src/main/home/cluster-dashboard/dashboard/node-view/ExpandedNodeView.tsx

@@ -73,6 +73,22 @@ export const ExpandedNodeView = () => {
     }
   }, [currentTab, node]);
 
+  const nodeStatus = useMemo(() => {
+    if (!node || !node.node_conditions) {
+      return "loading";
+    }
+
+    return node.node_conditions.reduce((prevValue: boolean, current: any) => {
+      if (current.type !== "Ready" && current.status !== "False") {
+        return "failed";
+      }
+      if (current.type === "Ready" && current.status !== "True") {
+        return "failed";
+      }
+      return prevValue;
+    }, "healthy");
+  }, [node]);
+
   return (
     <>
       <CloseOverlay onClick={closeNodeView} />
@@ -84,9 +100,7 @@ export const ExpandedNodeView = () => {
                 <img src={nodePng} />
               </IconWrapper>
               {nodeId}
-              <InstanceType>
-                {instanceType}
-              </InstanceType>
+              <InstanceType>{instanceType}</InstanceType>
             </Title>
           </TitleSection>
 
@@ -96,11 +110,11 @@ export const ExpandedNodeView = () => {
         </HeaderWrapper>
         <BodyWrapper>
           <NodeUsage node={node} />
-          {/*
-            <StatusWrapper>
-              <StatusSection status="healthy" />
-            </StatusWrapper>
-          */}
+
+          <StatusWrapper>
+            <StatusSection status={nodeStatus} />
+          </StatusWrapper>
+
           <TabSelector
             options={tabOptions}
             currentTab={currentTab}