mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-17 17:35:17 +00:00
fix(ui): track concurrent deployment deletes
This commit is contained in:
@@ -63,9 +63,9 @@ export const ShowDeployments = ({
|
|||||||
const [activeLog, setActiveLog] = useState<
|
const [activeLog, setActiveLog] = useState<
|
||||||
RouterOutputs["deployment"]["all"][number] | null
|
RouterOutputs["deployment"]["all"][number] | null
|
||||||
>(null);
|
>(null);
|
||||||
const [removingDeploymentId, setRemovingDeploymentId] = useState<
|
const [removingDeploymentIds, setRemovingDeploymentIds] = useState<
|
||||||
string | null
|
Set<string>
|
||||||
>(null);
|
>(new Set());
|
||||||
const { data: deployments, isPending: isLoadingDeployments } =
|
const { data: deployments, isPending: isLoadingDeployments } =
|
||||||
api.deployment.allByType.useQuery(
|
api.deployment.allByType.useQuery(
|
||||||
{
|
{
|
||||||
@@ -84,7 +84,7 @@ export const ShowDeployments = ({
|
|||||||
api.rollback.rollback.useMutation();
|
api.rollback.rollback.useMutation();
|
||||||
const { mutateAsync: killProcess, isPending: isKillingProcess } =
|
const { mutateAsync: killProcess, isPending: isKillingProcess } =
|
||||||
api.deployment.killProcess.useMutation();
|
api.deployment.killProcess.useMutation();
|
||||||
const { mutateAsync: removeDeployment, isPending: isRemovingDeployment } =
|
const { mutateAsync: removeDeployment } =
|
||||||
api.deployment.removeDeployment.useMutation();
|
api.deployment.removeDeployment.useMutation();
|
||||||
|
|
||||||
// Cancel deployment mutations
|
// Cancel deployment mutations
|
||||||
@@ -411,7 +411,11 @@ export const ShowDeployments = ({
|
|||||||
description="Are you sure you want to delete this deployment? This action cannot be undone."
|
description="Are you sure you want to delete this deployment? This action cannot be undone."
|
||||||
type="default"
|
type="default"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
setRemovingDeploymentId(deployment.deploymentId);
|
setRemovingDeploymentIds((deploymentIds) => {
|
||||||
|
const nextDeploymentIds = new Set(deploymentIds);
|
||||||
|
nextDeploymentIds.add(deployment.deploymentId);
|
||||||
|
return nextDeploymentIds;
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
await removeDeployment({
|
await removeDeployment({
|
||||||
deploymentId: deployment.deploymentId,
|
deploymentId: deployment.deploymentId,
|
||||||
@@ -420,17 +424,24 @@ export const ShowDeployments = ({
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error("Error deleting deployment");
|
toast.error("Error deleting deployment");
|
||||||
} finally {
|
} finally {
|
||||||
setRemovingDeploymentId(null);
|
setRemovingDeploymentIds((deploymentIds) => {
|
||||||
|
const nextDeploymentIds = new Set(
|
||||||
|
deploymentIds,
|
||||||
|
);
|
||||||
|
nextDeploymentIds.delete(
|
||||||
|
deployment.deploymentId,
|
||||||
|
);
|
||||||
|
return nextDeploymentIds;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
variant="destructive"
|
variant="destructive"
|
||||||
size="sm"
|
size="sm"
|
||||||
isLoading={
|
isLoading={removingDeploymentIds.has(
|
||||||
isRemovingDeployment &&
|
deployment.deploymentId,
|
||||||
removingDeploymentId === deployment.deploymentId
|
)}
|
||||||
}
|
|
||||||
>
|
>
|
||||||
Delete
|
Delete
|
||||||
<Trash2 className="size-4" />
|
<Trash2 className="size-4" />
|
||||||
|
|||||||
Reference in New Issue
Block a user