Sean Rhee před 5 roky
rodič
revize
6bfb6ae5be
1 změnil soubory, kde provedl 14 přidání a 2 odebrání
  1. 14 2
      dashboard/src/main/home/sidebar/ClusterSection.tsx

+ 14 - 2
dashboard/src/main/home/sidebar/ClusterSection.tsx

@@ -56,8 +56,20 @@ export default class ClusterSection extends Component<PropsType, StateType> {
           clusters.sort((a: any, b: any) => a.id - b.id);
           if (clusters.length > 0) {
             this.setState({ clusters });
-            setCurrentCluster(JSON.parse(localStorage.getItem('currentCluster')));
-            if (localStorage.getItem('currentCluster') === 'null') {
+            let saved = JSON.parse(localStorage.getItem('currentCluster'));
+            if (localStorage.getItem('currentCluster') !== 'null') {
+              setCurrentCluster(clusters[0]);
+              for (let i = 0; i < clusters.length; i++) {
+                if (
+                  clusters[i].id = saved.id &&
+                  clusters[i].project_id === saved.project_id && 
+                  clusters[i].name === saved.name &&
+                ) {
+                  setCurrentCluster(clusters[i]);
+                  break;
+                }
+              }
+            } else {
               setCurrentCluster(clusters[0]);
             }
           } else if (this.props.currentView !== 'provisioner') {