Przeglądaj źródła

refactored expanded-chart tabs as tabregion

jusrhee 5 lat temu
rodzic
commit
c0788c7a29

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

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

Plik diff jest za duży
+ 1 - 1
dashboard/src/main/home/cluster-dashboard/expanded-chart/ExpandedChart.tsx


Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików