Browse Source

refactored expanded-chart tabs as tabregion

jusrhee 5 years ago
parent
commit
c0788c7a29

+ 8 - 1
dashboard/src/components/TabRegion.tsx

@@ -9,6 +9,8 @@ type PropsType = {
   tabContents: any,
   defaultTab?: string,
   addendum?: any,
+  checkTabExists?: boolean, // Handles the currently selected tab disappearing
+  color?: string | null,
 };
 
 type StateType = {
@@ -33,7 +35,11 @@ export default class TabRegion extends Component<PropsType, StateType> {
   }
 
   componentDidUpdate(prevProps: PropsType) {
-    if (prevProps.options !== this.props.options && !this.state.currentTab) {
+    let { options, checkTabExists } = this.props;
+    if (prevProps.options !== options && !this.state.currentTab) {
+      this.setDefaultTab();
+    } else if (prevProps.checkTabExists !== checkTabExists
+      && !options.some((e: any) => e.value === this.state.currentTab)) {
       this.setDefaultTab();
     }
   }
@@ -56,6 +62,7 @@ export default class TabRegion extends Component<PropsType, StateType> {
       <Div>
         <TabSelector
           options={this.props.options}
+          color={this.props.color}
           currentTab={this.state.currentTab}
           setCurrentTab={(x: string) => this.setState({ currentTab: x })}
           addendum={this.props.addendum}

File diff suppressed because it is too large
+ 1 - 1
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedChart.tsx


Some files were not shown because too many files changed in this diff