Просмотр исходного кода

Fix merge conflicts with chart list

jnfrati 4 лет назад
Родитель
Сommit
7a05542e80
1 измененных файлов с 20 добавлено и 11 удалено
  1. 20 11
      dashboard/src/main/home/cluster-dashboard/chart/ChartList.tsx

+ 20 - 11
dashboard/src/main/home/cluster-dashboard/chart/ChartList.tsx

@@ -19,7 +19,7 @@ import { useWebsockets } from "shared/hooks/useWebsockets";
 
 type Props = {
   currentCluster: ClusterType;
-  lastRunStatus?: JobStatusType | null;
+  lastRunStatus?: JobStatusType | null | "all";
   namespace: string;
   // TODO Convert to enum
   sortType: string;
@@ -119,23 +119,26 @@ const ChartList: React.FunctionComponent<Props> = ({
           getChartKey(chart.name, chart.namespace) ===
           getChartKey(newChart.name, newChart.namespace);
         setCharts((currentCharts) => {
+          const tmpCharts = Array.isArray(currentCharts)
+            ? [...currentCharts]
+            : [];
           switch (event.event_type) {
             case "ADD":
-              if (currentCharts?.find(isSameChart)) {
-                return currentCharts;
+              if (tmpCharts.find(isSameChart)) {
+                return tmpCharts;
               }
-              return currentCharts?.concat(newChart);
+              return tmpCharts.concat(newChart);
             case "UPDATE":
-              return currentCharts?.map((chart) => {
+              return tmpCharts.map((chart) => {
                 if (isSameChart(chart) && newChart.version >= chart.version) {
                   return newChart;
                 }
                 return chart;
               });
             case "DELETE":
-              return currentCharts?.filter((chart) => !isSameChart(chart));
+              return tmpCharts.filter((chart) => !isSameChart(chart));
             default:
-              return currentCharts;
+              return tmpCharts;
           }
         });
       },
@@ -206,6 +209,11 @@ const ChartList: React.FunctionComponent<Props> = ({
       },
       onmessage: (evt: MessageEvent) => {
         let event = JSON.parse(evt.data);
+
+        if (event.event_type === "DELETE") {
+          return;
+        }
+
         let object = event.Object;
 
         if (_.get(object.metadata, ["annotations", "helm.sh/hook"])) {
@@ -239,7 +247,8 @@ const ChartList: React.FunctionComponent<Props> = ({
 
           if (
             !existingValue ||
-            newValue.resource_version > existingValue.resource_version
+            Number(newValue.resource_version) >
+              Number(existingValue.resource_version)
           ) {
             return {
               ...currentStatus,
@@ -327,7 +336,7 @@ const ChartList: React.FunctionComponent<Props> = ({
         if (currentView !== "jobs") {
           return true;
         }
-        if (lastRunStatus === null) {
+        if (lastRunStatus === null || lastRunStatus === "all") {
           return true;
         }
         const status: JobStatusWithTimeAndVersion = _.get(
@@ -370,7 +379,7 @@ const ChartList: React.FunctionComponent<Props> = ({
           <i className="material-icons">error</i> Error connecting to cluster.
         </Placeholder>
       );
-    } else if (filteredCharts.length === 0) {
+    } else if (filteredCharts?.length === 0) {
       return (
         <Placeholder>
           <i className="material-icons">category</i> No
@@ -380,7 +389,7 @@ const ChartList: React.FunctionComponent<Props> = ({
       );
     }
 
-    return filteredCharts.map((chart: ChartType, i: number) => {
+    return filteredCharts?.map((chart: ChartType, i: number) => {
       return (
         <Chart
           key={getChartKey(chart.name, chart.namespace)}