diff --git a/packages/backend/src/service.ts b/packages/backend/src/service.ts index 64223f2..0067ef5 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 c2b62fd..7e6fdd7 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 +