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

call updateTabs after chart data is retrieved

jusrhee 5 лет назад
Родитель
Сommit
7468688ddc

+ 3 - 10
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedChart.tsx

@@ -98,7 +98,9 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
         }
       )
       .then((res) => {
-        this.setState({ currentChart: res.data, loading: false });
+        this.setState({ currentChart: res.data, loading: false }, () => {
+          this.updateTabs();
+        });
       })
       .catch(console.log);
   };
@@ -560,15 +562,6 @@ export default class ExpandedChart extends Component<PropsType, StateType> {
         })
       )
       .catch(console.log);
-
-    this.updateTabs();
-  }
-
-  componentDidUpdate(prevProps: PropsType) {
-    if (this.props.currentChart !== prevProps.currentChart) {
-      this.updateTabs();
-      this.updateResources();
-    }
   }
 
   componentWillUnmount() {

+ 3 - 16
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedJobChart.tsx

@@ -73,7 +73,9 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
         }
       )
       .then((res) => {
-        this.setState({ currentChart: res.data, loading: false });
+        this.setState({ currentChart: res.data, loading: false }, () => {
+          this.updateTabs();
+        });
       })
       .catch(console.log);
   };
@@ -357,24 +359,9 @@ export default class ExpandedJobChart extends Component<PropsType, StateType> {
 
     this.getChartData(currentChart);
     this.getJobs(currentChart);
-    this.updateTabs();
     this.setupJobWebsocket(currentChart);
   }
 
-  componentDidUpdate(prevProps: PropsType) {
-    if (this.props.currentChart !== prevProps.currentChart) {
-      this.updateTabs();
-    }
-  }
-
-  //   componentWillUnmount() {
-  //     if (this.state.websockets) {
-  //       this.state.websockets.forEach((ws: WebSocket) => {
-  //         ws.close();
-  //       });
-  //     }
-  //   }
-
   handleUninstallChart = () => {
     let { currentProject, currentCluster } = this.context;
     let { currentChart } = this.state;