From 1d1a39272bcacdf7960a80994b033207d7245d89 Mon Sep 17 00:00:00 2001 From: sdess09 <37374498+sdess09@users.noreply.github.com> Date: Tue, 19 Sep 2023 11:54:21 -0400 Subject: [PATCH] Update Cluster Deletion (#3596) --- .../src/components/ProvisionerSettings.tsx | 2 +- .../dashboard/ClusterSettings.tsx | 2 +- .../main/home/modals/UpdateClusterModal.tsx | 42 ++++++++++++------- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/dashboard/src/components/ProvisionerSettings.tsx b/dashboard/src/components/ProvisionerSettings.tsx index d520e2c608..367581df25 100644 --- a/dashboard/src/components/ProvisionerSettings.tsx +++ b/dashboard/src/components/ProvisionerSettings.tsx @@ -984,7 +984,7 @@ const ProvisionerSettings: React.FC = (props) => { = (props) => { ); - if (!currentCluster?.infra_id || !currentCluster?.service) { + if (!currentCluster?.infra_id && !currentProject?.capi_provisioner_enabled || !currentCluster?.service) { helperText = ( Remove this cluster from Porter. Since this cluster was not provisioned diff --git a/dashboard/src/main/home/modals/UpdateClusterModal.tsx b/dashboard/src/main/home/modals/UpdateClusterModal.tsx index dd97db5cf5..f527e2632d 100644 --- a/dashboard/src/main/home/modals/UpdateClusterModal.tsx +++ b/dashboard/src/main/home/modals/UpdateClusterModal.tsx @@ -52,7 +52,7 @@ class UpdateClusterModal extends Component { cluster_id: currentCluster.id, } ) - .then((_) => { + .then(async (_) => { if (!currentCluster?.infra_id) { // TODO: make this more declarative from the Home component this.props.setRefreshClusters(true); @@ -61,24 +61,34 @@ class UpdateClusterModal extends Component { pushFiltered(this.props, "/dashboard", ["project_id"], { tab: "overview", }); + + + // Handle destroying infra we've provisioned + api + .destroyInfra( + "", + {}, + { + project_id: currentProject.id, + infra_id: currentCluster.infra_id, + } + ) + .then(() => + console.log("destroyed provisioned infra:", currentCluster.infra_id) + ) + .catch(console.log); + + if (currentProject.simplified_view_enabled) { + await api.saveOnboardingState( + "", + { current_step: "connect_source" }, + { project_id: currentProject.id } + ); + window.location.reload(); + } return; } - // Handle destroying infra we've provisioned - api - .destroyInfra( - "", - {}, - { - project_id: currentProject.id, - infra_id: currentCluster.infra_id, - } - ) - .then(() => - console.log("destroyed provisioned infra:", currentCluster.infra_id) - ) - .catch(console.log); - this.props.setRefreshClusters(true); this.setState({ status: "successful", showDeleteOverlay: false }); this.context.setCurrentModal(null, null);