Skip to content

Commit 6e79270

Browse files
committed
fix(ui): track concurrent deployment deletes
1 parent 268ec1f commit 6e79270

1 file changed

Lines changed: 21 additions & 10 deletions

File tree

‎apps/dokploy/components/dashboard/application/deployments/show-deployments.tsx‎

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ export const ShowDeployments = ({
6363
const [activeLog, setActiveLog] = useState<
6464
RouterOutputs["deployment"]["all"][number] | null
6565
>(null);
66-
const [removingDeploymentId, setRemovingDeploymentId] = useState<
67-
string | null
68-
>(null);
66+
const [removingDeploymentIds, setRemovingDeploymentIds] = useState<
67+
Set<string>
68+
>(new Set());
6969
const { data: deployments, isPending: isLoadingDeployments } =
7070
api.deployment.allByType.useQuery(
7171
{
@@ -84,7 +84,7 @@ export const ShowDeployments = ({
8484
api.rollback.rollback.useMutation();
8585
const { mutateAsync: killProcess, isPending: isKillingProcess } =
8686
api.deployment.killProcess.useMutation();
87-
const { mutateAsync: removeDeployment, isPending: isRemovingDeployment } =
87+
const { mutateAsync: removeDeployment } =
8888
api.deployment.removeDeployment.useMutation();
8989

9090
// Cancel deployment mutations
@@ -411,7 +411,11 @@ export const ShowDeployments = ({
411411
description="Are you sure you want to delete this deployment? This action cannot be undone."
412412
type="default"
413413
onClick={async () => {
414-
setRemovingDeploymentId(deployment.deploymentId);
414+
setRemovingDeploymentIds((deploymentIds) => {
415+
const nextDeploymentIds = new Set(deploymentIds);
416+
nextDeploymentIds.add(deployment.deploymentId);
417+
return nextDeploymentIds;
418+
});
415419
try {
416420
await removeDeployment({
417421
deploymentId: deployment.deploymentId,
@@ -420,17 +424,24 @@ export const ShowDeployments = ({
420424
} catch (error) {
421425
toast.error("Error deleting deployment");
422426
} finally {
423-
setRemovingDeploymentId(null);
427+
setRemovingDeploymentIds((deploymentIds) => {
428+
const nextDeploymentIds = new Set(
429+
deploymentIds,
430+
);
431+
nextDeploymentIds.delete(
432+
deployment.deploymentId,
433+
);
434+
return nextDeploymentIds;
435+
});
424436
}
425437
}}
426438
>
427439
<Button
428440
variant="destructive"
429441
size="sm"
430-
isLoading={
431-
isRemovingDeployment &&
432-
removingDeploymentId === deployment.deploymentId
433-
}
442+
isLoading={removingDeploymentIds.has(
443+
deployment.deploymentId,
444+
)}
434445
>
435446
Delete
436447
<Trash2 className="size-4" />

0 commit comments

Comments
 (0)