mirror of
https://github.com/andwati/dokploy.git
synced 2026-10-18 03:02:56 +00:00
Merge pull request #4947 from azizbecha/fix/4945-deployment-delete-loading
fix(ui): scope deployment delete loading
(cherry picked from commit 2be9e1e3df)
This commit is contained in:
committed by
Mauricio Siu
parent
2f89981597
commit
e88d13f67b
@@ -63,6 +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 [removingDeploymentIds, setRemovingDeploymentIds] = useState<
|
||||||
|
Set<string>
|
||||||
|
>(new Set());
|
||||||
const { data: deployments, isPending: isLoadingDeployments } =
|
const { data: deployments, isPending: isLoadingDeployments } =
|
||||||
api.deployment.allByType.useQuery(
|
api.deployment.allByType.useQuery(
|
||||||
{
|
{
|
||||||
@@ -81,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
|
||||||
@@ -408,6 +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 () => {
|
||||||
|
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,
|
||||||
@@ -415,13 +423,25 @@ export const ShowDeployments = ({
|
|||||||
toast.success("Deployment deleted successfully");
|
toast.success("Deployment deleted successfully");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
toast.error("Error deleting deployment");
|
toast.error("Error deleting deployment");
|
||||||
|
} finally {
|
||||||
|
setRemovingDeploymentIds((deploymentIds) => {
|
||||||
|
const nextDeploymentIds = new Set(
|
||||||
|
deploymentIds,
|
||||||
|
);
|
||||||
|
nextDeploymentIds.delete(
|
||||||
|
deployment.deploymentId,
|
||||||
|
);
|
||||||
|
return nextDeploymentIds;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
variant="destructive"
|
variant="destructive"
|
||||||
size="sm"
|
size="sm"
|
||||||
isLoading={isRemovingDeployment}
|
isLoading={removingDeploymentIds.has(
|
||||||
|
deployment.deploymentId,
|
||||||
|
)}
|
||||||
>
|
>
|
||||||
Delete
|
Delete
|
||||||
<Trash2 className="size-4" />
|
<Trash2 className="size-4" />
|
||||||
|
|||||||
Reference in New Issue
Block a user