|
|
@@ -9,6 +9,8 @@ import Loading from "components/Loading";
|
|
|
import InfraStatuses from "./InfraStatuses";
|
|
|
import ProvisionerLogs from "./ProvisionerLogs";
|
|
|
import { RouteComponentProps, withRouter } from "react-router";
|
|
|
+import { stringify } from "qs";
|
|
|
+import { forEach } from "lodash";
|
|
|
|
|
|
type PropsType = RouteComponentProps & {};
|
|
|
|
|
|
@@ -47,6 +49,30 @@ class Provisioner extends Component<PropsType, StateType> {
|
|
|
this.updateInfras()
|
|
|
}
|
|
|
|
|
|
+ componentDidUpdate(prevProps : PropsType, prevState : 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.
|
|
|
+ let prevInfraStates : Record<number, string> = {}
|
|
|
+
|
|
|
+ prevState.infras.forEach((infra, i) => {
|
|
|
+ prevInfraStates[infra.id] = infra.status
|
|
|
+ })
|
|
|
+
|
|
|
+ this.state.infras.forEach((infra, i) => {
|
|
|
+ if (prevInfraStates[infra.id] && infra.status == "created" && prevInfraStates[infra.id] != "created") {
|
|
|
+ api
|
|
|
+ .getClusters("<token>", {}, { id: this.context.currentProject.id })
|
|
|
+ .then(res => {
|
|
|
+ this.context.setCurrentCluster(res.data[0])
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ this.context.setCurrentError(err)
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
refresh = () => {
|
|
|
this.updateInfras()
|
|
|
}
|
|
|
@@ -104,6 +130,7 @@ class Provisioner extends Component<PropsType, StateType> {
|
|
|
<ProvisionerLogs
|
|
|
key={this.state.selectedInfra?.id}
|
|
|
selectedInfra={this.state.selectedInfra}
|
|
|
+ updateInfras={this.updateInfras}
|
|
|
/>
|
|
|
</StyledProvisioner>
|
|
|
);
|