Просмотр исходного кода

Merge pull request #466 from porter-dev/beta.3.doks-redirect

Call update clusters from provisioner properly
abelanger5 5 лет назад
Родитель
Сommit
56d5fcab7d

+ 6 - 1
dashboard/src/main/home/Home.tsx

@@ -294,7 +294,12 @@ class Home extends Component<PropsType, StateType> {
       } else if (currentView === "dashboard") {
         return (
           <DashboardWrapper>
-            <Dashboard projectId={this.context.currentProject?.id} />
+            <Dashboard 
+              projectId={this.context.currentProject?.id} 
+              setRefreshClusters={(x: boolean) =>
+                this.setState({ forceRefreshClusters: x })
+              }
+            />
           </DashboardWrapper>
         );
       } else if (currentView === "integrations") {

+ 2 - 1
dashboard/src/main/home/dashboard/Dashboard.tsx

@@ -16,6 +16,7 @@ import { setSearchParam } from "shared/routing";
 
 type PropsType = RouteComponentProps & {
   projectId: number | null;
+  setRefreshClusters: (x: boolean) => void;
 };
 
 const tabOptions = [
@@ -71,7 +72,7 @@ class Dashboard extends Component<PropsType, StateType> {
 
   renderTabContents = () => {
     if (this.currentTab() === "provisioner") {
-      return <Provisioner />;
+      return <Provisioner setRefreshClusters={this.props.setRefreshClusters}/>;
     } else {
       return (
         <>

+ 4 - 18
dashboard/src/main/home/provisioner/Provisioner.tsx

@@ -12,7 +12,9 @@ import { RouteComponentProps, withRouter } from "react-router";
 import { stringify } from "qs";
 import { forEach } from "lodash";
 
-type PropsType = RouteComponentProps & {};
+type PropsType = RouteComponentProps & {
+  setRefreshClusters: (x: boolean) => void;
+};
 
 type StateType = {
   error: boolean;
@@ -53,35 +55,19 @@ class Provisioner extends Component<PropsType, StateType> {
     // Check that an infra that was previously in a non-created state, and
     // which was a cluster, is now in a created state. If so, propagate update
     // so that cluster can be refreshed.
-    console.log("called component did update", prevProps, prevState)
-
     let prevInfraStates: Record<number, string> = {};
 
     prevState.infras.forEach((infra, i) => {
       prevInfraStates[infra.id] = infra.status;
     });
 
-    console.log("got previous infra states", prevInfraStates)
-
     this.state.infras.forEach((infra, i) => {
-      console.log("testing current infra", infra, prevInfraStates[infra.id], infra.status == "created", prevInfraStates[infra.id] != "created")
-
       if (
         prevInfraStates[infra.id] &&
         infra.status == "created" &&
         prevInfraStates[infra.id] != "created"
       ) {
-        console.log("triggered get clusters")
-
-        api
-          .getClusters("<token>", {}, { id: this.context.currentProject.id })
-          .then(res => {
-            console.log("got the clusters", res.data)
-            this.context.setCurrentCluster(res.data[0]);
-          })
-          .catch(err => {
-            this.context.setCurrentError(err);
-          });
+        this.props.setRefreshClusters(true)
       }
     });
   }