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

Fix chart list not showing anything

jnfrati 3 лет назад
Родитель
Сommit
a284f19184

+ 17 - 7
dashboard/src/main/home/cluster-dashboard/chart/ChartList.tsx

@@ -338,12 +338,22 @@ const ChartList: React.FunctionComponent<Props> = ({
         });
       })
       .filter((chart: ChartType) => {
-        return (
-          (currentView == "jobs" && chart.chart.metadata.name == "job") ||
-          ((currentView == "applications" ||
-            currentView == "cluster-dashboard") &&
-            chart.chart.metadata.name != "job")
-        );
+        if (currentView === "jobs" && chart.chart.metadata.name === "job") {
+          return true;
+        }
+
+        if (
+          ["applications", "cluster-dashboard"].includes(currentView) &&
+          chart.chart.metadata.name !== "job"
+        ) {
+          return true;
+        }
+
+        if (currentView === "stacks") {
+          return true;
+        }
+
+        return false;
       })
       .filter((chart: ChartType) => {
         if (currentView !== "jobs") {
@@ -365,7 +375,7 @@ const ChartList: React.FunctionComponent<Props> = ({
         }
 
         return appFilters.some((filter) => {
-          return chart.name.toLowerCase().includes(filter.toLowerCase());
+          return chart.name.toLowerCase() === filter.toLowerCase();
         });
       });
 

+ 20 - 9
dashboard/src/main/home/cluster-dashboard/stacks/ExpandedStack.tsx

@@ -3,6 +3,7 @@ import React, { useContext, useEffect, useState } from "react";
 import { useParams } from "react-router";
 import api from "shared/api";
 import { Context } from "shared/Context";
+import styled from "styled-components";
 import ChartList from "../chart/ChartList";
 import DashboardHeader from "../DashboardHeader";
 import SortSelector from "../SortSelector";
@@ -64,17 +65,27 @@ const ExpandedStack = () => {
         currentView="stacks"
       />
 
-      <ChartList
-        currentCluster={currentCluster}
-        currentView="stacks"
-        namespace={namespace}
-        sortType="Alphabetical"
-        appFilters={
-          stack?.latest_revision?.resources?.map((res) => res.name) || []
-        }
-      />
+      <ChartListWrapper>
+        <ChartList
+          currentCluster={currentCluster}
+          currentView="stacks"
+          namespace={namespace}
+          sortType="Alphabetical"
+          appFilters={
+            stack?.latest_revision?.resources?.map((res) => res.name) || []
+          }
+          closeChartRedirectUrl={`${window.location.pathname}${window.location.search}`}
+        />
+      </ChartListWrapper>
     </div>
   );
 };
 
 export default ExpandedStack;
+
+const ChartListWrapper = styled.div`
+  width: 100%;
+  margin: auto;
+  margin-top: 20px;
+  padding-bottom: 125px;
+`;

+ 1 - 1
dashboard/src/main/home/cluster-dashboard/stacks/_StackList.tsx

@@ -49,7 +49,7 @@ const StackList = ({ namespace }: { namespace: string }) => {
     return <Loading />;
   }
 
-  if (stacks.length === 0) {
+  if (stacks?.length === 0) {
     return (
       <div>
         <h3>No stacks found</h3>