feat: submit delete deployment request

doesn't appear to work when the deployment is current?
This commit is contained in:
Eric Lewis 2024-03-29 15:31:49 -04:00 committed by Nabarun
parent 8210512eea
commit 328da7fdc8
2 changed files with 33 additions and 2 deletions

View File

@ -720,9 +720,17 @@ export class Service {
} }
async deleteDeployment (deploymentId: string): Promise<boolean> { async deleteDeployment (deploymentId: string): Promise<boolean> {
const result = await this.registry.createApplicationDeploymentRemovalRequest({ deploymentId }); 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 (result !== undefined || result !== null);
} }
return false;
}
async addDomain ( async addDomain (
projectId: string, projectId: string,

View File

@ -9,6 +9,7 @@ import {
RefreshIcon, RefreshIcon,
RocketIcon, RocketIcon,
UndoIcon, UndoIcon,
CrossCircleIcon,
} from 'components/shared/CustomIcon'; } from 'components/shared/CustomIcon';
import { import {
Menu, 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 ( return (
<> <>
<div className={cn('max-w-[32px]', className)} {...props}> <div className={cn('max-w-[32px]', className)} {...props}>
@ -147,6 +158,18 @@ export const DeploymentMenu = ({
> >
<UndoIcon /> Rollback to this version <UndoIcon /> Rollback to this version
</MenuItem> </MenuItem>
<MenuItem
className="hover:bg-base-bg-emphasized flex items-center gap-3"
onClick={() => deleteDeployment()}
disabled={
deployment.isCurrent ||
deployment.environment !== Environment.Production ||
!Boolean(currentDeployment)
}
placeholder={''}
>
<CrossCircleIcon /> Delete deployment
</MenuItem>
</MenuList> </MenuList>
</Menu> </Menu>
</div> </div>