فهرست منبع

set namespace query param when directly navigating to env-groups

jusrhee 5 سال پیش
والد
کامیت
5241aff17b

+ 3 - 3
dashboard/src/main/home/Home.tsx

@@ -137,7 +137,7 @@ class Home extends Component<PropsType, StateType> {
                   foundProject = project;
                 }
               });
-              setCurrentProject(foundProject || res.data[0], () => 
+              setCurrentProject(foundProject || res.data[0], () =>
                 this.initializeView()
               );
             }
@@ -292,7 +292,7 @@ class Home extends Component<PropsType, StateType> {
           <PageNotFound />
         </DashboardWrapper>
       );
-    } 
+    }
     return (
       <DashboardWrapper>
         <ClusterDashboard
@@ -365,7 +365,7 @@ class Home extends Component<PropsType, StateType> {
           if (res.data.length > 0) {
             setCurrentProject(res.data[0]);
           } else {
-            setCurrentProject(null, () => 
+            setCurrentProject(null, () =>
               pushFiltered(this.props, "/new-project", ["project_id"])
             );
           }

+ 21 - 14
dashboard/src/main/home/cluster-dashboard/ClusterDashboard.tsx

@@ -65,23 +65,28 @@ class ClusterDashboard extends Component<PropsType, StateType> {
   componentDidUpdate(prevProps: PropsType) {
     // 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,
-      }, () =>
-        pushQueryParams(this.props, { namespace: "default" })
+      this.setState(
+        {
+          namespace: "default",
+          sortType: localStorage.getItem("SortType")
+            ? localStorage.getItem("SortType")
+            : "Newest",
+          currentChart: null,
+        },
+        () => pushQueryParams(this.props, { namespace: "default" })
       );
     }
 
     if (prevProps.currentView !== this.props.currentView) {
-      this.setState({
-        sortType: "Newest",
-        currentChart: null,
-      }, () =>
-        pushQueryParams(this.props, { namespace: this.state.namespace || "ALL" })
+      this.setState(
+        {
+          sortType: "Newest",
+          currentChart: null,
+        },
+        () =>
+          pushQueryParams(this.props, {
+            namespace: this.state.namespace || "ALL",
+          })
       );
     }
   }
@@ -120,7 +125,9 @@ class ClusterDashboard extends Component<PropsType, StateType> {
             <NamespaceSelector
               setNamespace={(namespace) =>
                 this.setState({ namespace }, () =>
-                  pushQueryParams(this.props, { namespace: this.state.namespace || "ALL" })
+                  pushQueryParams(this.props, {
+                    namespace: this.state.namespace || "ALL",
+                  })
                 )
               }
               namespace={this.state.namespace}

+ 1 - 1
dashboard/src/main/home/cluster-dashboard/NamespaceSelector.tsx

@@ -39,7 +39,7 @@ export default class NamespaceSelector extends Component<PropsType, StateType> {
           let namespaceOptions: { label: string; value: string }[] = [
             { label: "All", value: "" },
           ];
-          
+
           // Set namespace from URL if specified
           let queryString = window.location.search;
           let urlParams = new URLSearchParams(queryString);

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

@@ -217,7 +217,8 @@ export default class ChartList extends Component<PropsType, StateType> {
   };
 
   componentDidMount() {
-    (this.props.namespace || this.props.namespace === "") && this.updateCharts(this.getControllers);
+    (this.props.namespace || this.props.namespace === "") &&
+      this.updateCharts(this.getControllers);
     this.setControllerWebsockets([
       "deployment",
       "statefulset",
@@ -242,7 +243,8 @@ export default class ChartList extends Component<PropsType, StateType> {
       prevProps.sortType !== this.props.sortType ||
       prevProps.currentView !== this.props.currentView
     ) {
-      (this.props.namespace || this.props.namespace === "") && this.updateCharts(this.getControllers);
+      (this.props.namespace || this.props.namespace === "") &&
+        this.updateCharts(this.getControllers);
     }
   }
 

+ 5 - 3
dashboard/src/main/home/cluster-dashboard/env-groups/EnvGroupDashboard.tsx

@@ -32,7 +32,7 @@ class EnvGroupDashboard extends Component<PropsType, StateType> {
   state = {
     expand: false,
     update: [] as any[],
-    namespace: "default",
+    namespace: null as string,
     expandedEnvGroup: null as any,
     createEnvMode: false,
     sortType: localStorage.getItem("SortType")
@@ -75,9 +75,11 @@ class EnvGroupDashboard extends Component<PropsType, StateType> {
                 sortType={this.state.sortType}
               />
               <NamespaceSelector
-                setNamespace={(namespace) => 
+                setNamespace={(namespace) =>
                   this.setState({ namespace }, () =>
-                    pushQueryParams(this.props, { namespace: this.state.namespace || "ALL" })
+                    pushQueryParams(this.props, {
+                      namespace: this.state.namespace || "ALL",
+                    })
                   )
                 }
                 namespace={this.state.namespace}

+ 2 - 1
dashboard/src/main/home/cluster-dashboard/env-groups/EnvGroupList.tsx

@@ -89,7 +89,8 @@ export default class EnvGroupList extends Component<PropsType, StateType> {
       prevProps.namespace !== this.props.namespace ||
       prevProps.sortType !== this.props.sortType
     ) {
-      (this.props.namespace || this.props.namespace === "") && this.updateEnvGroups();
+      (this.props.namespace || this.props.namespace === "") &&
+        this.updateEnvGroups();
     }
   }
 

+ 1 - 3
dashboard/src/main/home/provisioner/DOFormSection.tsx

@@ -152,9 +152,7 @@ export default class DOFormSection extends Component<PropsType, StateType> {
           }
         );
         setProjects(res_1.data);
-        setCurrentProject(proj, () =>
-          callback && callback(proj.id)
-        );
+        setCurrentProject(proj, () => callback && callback(proj.id));
       })
       .catch(this.catchError);
   };

+ 1 - 3
dashboard/src/main/home/provisioner/GCPFormSection.tsx

@@ -185,9 +185,7 @@ class GCPFormSection extends Component<PropsType, StateType> {
           )
           .then((res) => {
             setProjects(res.data);
-            setCurrentProject(proj, () => 
-              callback && callback()
-            );
+            setCurrentProject(proj, () => callback && callback());
           })
           .catch(this.catchError);
       })

+ 1 - 1
dashboard/src/main/home/sidebar/ProjectSection.tsx

@@ -53,7 +53,7 @@ class ProjectSection extends Component<PropsType, StateType> {
           selected={project.name === this.props.currentProject.name}
           onClick={() => {
             this.setState({ expanded: false });
-            setCurrentProject(project, () => 
+            setCurrentProject(project, () =>
               pushFiltered(this.props, "/dashboard", ["project_id"])
             );
           }}