sunguroku 5 лет назад
Родитель
Сommit
39366c7cad

+ 2 - 2
dashboard/src/main/home/cluster-dashboard/chart/Chart.tsx

@@ -6,7 +6,7 @@ import { Context } from '../../../../shared/Context';
 
 type PropsType = {
   chart: ChartType,
-  setCurrentChart: (c: ChartType) => void
+  setCurrentChart: (c: ChartType) => void,
   controllers: Record<string, any>,
 };
 
@@ -34,7 +34,7 @@ export default class Chart extends Component<PropsType, StateType> {
     expand: false,
     controllers: {} as Record<string, boolean>,
     update: [] as any[],
-    getAvailability: this.getAvailability.bind(this)
+    getAvailability: this.getAvailability.bind(this),
   }
 
   renderIcon = () => {

+ 5 - 12
dashboard/src/main/home/cluster-dashboard/chart/ChartList.tsx

@@ -36,11 +36,6 @@ export default class ChartList extends Component<PropsType, StateType> {
   updateCharts = (callback: Function) => {
     let { currentCluster, currentProject, setCurrentError } = this.context;
     this.setState({ loading: true });
-    setTimeout(() => {
-      if (this.state.loading) {
-        this.setState({ loading: false, error: true });
-      }
-    }, 3000);
 
     api.getCharts('<token>', {
       namespace: this.props.namespace,
@@ -58,13 +53,11 @@ export default class ChartList extends Component<PropsType, StateType> {
         setCurrentError(JSON.stringify(err));
         this.setState({ loading: false, error: true });
       } else {
-        if (res.data) {
-          this.setState({ charts: res.data });
-          callback(res.data)
-        } else {
-          this.setState({ charts: [] });
-        }
-        this.setState({ loading: false, error: false });
+        let charts = res.data || [];
+        this.setState({ charts }, () => {
+          this.setState({ loading: false, error: false });
+        });
+        callback(charts)
       }
     });
   }