Sfoglia il codice sorgente

Merge branch 'sean-testing' of https://github.com/porter-dev/porter into beta.3.integration-frontend

jusrhee 5 anni fa
parent
commit
c5c386e48c

+ 3 - 1
dashboard/src/main/home/cluster-dashboard/ClusterDashboard.tsx

@@ -34,7 +34,9 @@ export default class ClusterDashboard extends Component<PropsType, StateType> {
     localStorage.setItem("SortType", this.state.sortType);
     // Reset namespace filter and close expanded chart on cluster change
     if (prevProps.currentCluster !== this.props.currentCluster) {
-      this.setState({ namespace: 'default', sortType: (localStorage.getItem("SortType") ? localStorage.getItem('SortType') : 'Newest'), currentChart: null });
+      this.setState({ namespace: 'default', sortType: (
+        localStorage.getItem("SortType") ? localStorage.getItem('SortType') : 'Newest'
+      ), currentChart: null });
     }
   }
 

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

@@ -59,7 +59,7 @@ export default class ChartList extends Component<PropsType, StateType> {
         } else if (this.props.sortType == "Oldest") {
           charts.sort((a: any, b: any) => (Date.parse(a.info.last_deployed) > Date.parse(b.info.last_deployed)) ? 1 : -1);
         } else if (this.props.sortType == "Alphabetical") {
-          charts.sort((a: any, b: any) => (a.name > b.name) ? 1: -1);
+          charts.sort((a: any, b: any) => (a.name > b.name) ? 1 : -1);
         }
         this.setState({ charts }, () => {
           this.setState({ loading: false, error: false });

+ 5 - 1
dashboard/src/main/home/sidebar/ClusterSection.tsx

@@ -53,9 +53,12 @@ export default class ClusterSection extends Component<PropsType, StateType> {
         // TODO: handle uninitialized kubeconfig
         if (res.data) {
           let clusters = res.data;
+          clusters.sort((a, b) => a.id - b.id);
           if (clusters.length > 0) {
             this.setState({ clusters });
-            setCurrentCluster(clusters[0]);
+            setCurrentCluster(clusters[(
+              localStorage.getItem('currentCluster') ? localStorage.getItem('currentCluster') : 0
+            )]);
           } else if (this.props.currentView !== 'provisioner') {
             this.setState({ clusters: [] });
             setCurrentCluster(null);
@@ -76,6 +79,7 @@ export default class ClusterSection extends Component<PropsType, StateType> {
 
       // Refresh clusters on project change 
       if (this.state.prevProjectId !== this.context.currentProject.id) {
+        localStorage.setItem('currentCluster', this.context.currentProject.id);
         this.updateClusters();
         this.setState({ prevProjectId: this.context.currentProject.id });
       } else if (this.props.forceRefreshClusters === true) {

+ 6 - 1
dashboard/src/main/home/sidebar/Drawer.tsx

@@ -22,6 +22,7 @@ export default class Drawer extends Component<PropsType, StateType> {
     let { currentCluster, setCurrentCluster } = this.context;
 
     if (clusters.length > 0 && currentCluster) {
+      clusters.sort((a, b) => a.id - b.id);
       return clusters.map((cluster: ClusterType, i: number) => {
         /*
         let active = this.context.activeProject &&
@@ -32,7 +33,11 @@ export default class Drawer extends Component<PropsType, StateType> {
           <ClusterOption
             key={i}
             active={cluster.name === currentCluster.name}
-            onClick={() => { setCurrentCluster(cluster); setCurrentView('cluster-dashboard') }}
+            onClick={() => {
+              localStorage.setItem('currentCluster', cluster.id);
+              setCurrentCluster(cluster);
+              setCurrentView('cluster-dashboard');
+            }}
           >
             <ClusterIcon><i className="material-icons">device_hub</i></ClusterIcon>
             <ClusterName>{cluster.name}</ClusterName>