From 328da7fdc8a361c23bd6905897be8d41bb81af9e Mon Sep 17 00:00:00 2001 From: Eric Lewis Date: Fri, 29 Mar 2024 15:31:49 -0400 Subject: [PATCH] feat: submit delete deployment request doesn't appear to work when the deployment is current? --- packages/backend/src/service.ts | 12 ++++++++-- .../project/deployments/DeploymentMenu.tsx | 23 +++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index 64223f27..0067ef5e 100644 --- a/packages/backend/src/service.ts +++ b/packages/backend/src/service.ts @@ -720,8 +720,16 @@ export class Service { } async deleteDeployment (deploymentId: string): Promise { - const result = await this.registry.createApplicationDeploymentRemovalRequest({ deploymentId }); - return (result !== undefined || result !== null); + const deployment = await this.db.getDeployment({ + where: { + id: deploymentId + } + }); + if (deployment && deployment.applicationDeploymentRecordId) { + const result = await this.registry.createApplicationDeploymentRemovalRequest({ deploymentId: deployment.applicationDeploymentRecordId }); + return (result !== undefined || result !== null); + } + return false; } async addDomain ( diff --git a/packages/frontend/src/components/projects/project/deployments/DeploymentMenu.tsx b/packages/frontend/src/components/projects/project/deployments/DeploymentMenu.tsx index c2b62fd1..7e6fdd7d 100644 --- a/packages/frontend/src/components/projects/project/deployments/DeploymentMenu.tsx +++ b/packages/frontend/src/components/projects/project/deployments/DeploymentMenu.tsx @@ -9,6 +9,7 @@ import { RefreshIcon, RocketIcon, UndoIcon, + CrossCircleIcon, } from 'components/shared/CustomIcon'; import { Menu, @@ -79,6 +80,16 @@ export const DeploymentMenu = ({ } }; + const deleteDeployment = async () => { + const isDeleted = await client.deleteDeployment(deployment.id); + if (isDeleted) { + await onUpdate(); + toast.success('Deleted deployment'); + } else { + toast.error('Unable to delete deployment'); + } + }; + return ( <>
@@ -147,6 +158,18 @@ export const DeploymentMenu = ({ > Rollback to this version + deleteDeployment()} + disabled={ + deployment.isCurrent || + deployment.environment !== Environment.Production || + !Boolean(currentDeployment) + } + placeholder={''} + > + Delete deployment +