From 95dd9ddeb61f767e1b8b50f1a9c61bd2eb41355b Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Mon, 8 Dec 2025 02:30:23 +0000 Subject: [PATCH] [autofix.ci] apply automated fixes --- .../deployments/clear-deployments.tsx | 131 +++++++++--------- .../dokploy/server/api/routers/application.ts | 7 +- apps/dokploy/server/api/routers/compose.ts | 3 +- packages/server/src/services/deployment.ts | 12 +- 4 files changed, 80 insertions(+), 73 deletions(-) diff --git a/apps/dokploy/components/dashboard/application/deployments/clear-deployments.tsx b/apps/dokploy/components/dashboard/application/deployments/clear-deployments.tsx index d0f695ddb..70f9d2554 100644 --- a/apps/dokploy/components/dashboard/application/deployments/clear-deployments.tsx +++ b/apps/dokploy/components/dashboard/application/deployments/clear-deployments.tsx @@ -1,78 +1,81 @@ import { Paintbrush } from "lucide-react"; import { toast } from "sonner"; import { - AlertDialog, - AlertDialogAction, - AlertDialogCancel, - AlertDialogContent, - AlertDialogDescription, - AlertDialogFooter, - AlertDialogHeader, - AlertDialogTitle, - AlertDialogTrigger, + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, } from "@/components/ui/alert-dialog"; import { Button } from "@/components/ui/button"; import { api } from "@/utils/api"; interface Props { - id: string; - type: "application" | "compose"; + id: string; + type: "application" | "compose"; } export const ClearDeployments = ({ id, type }: Props) => { - const utils = api.useUtils(); - const { mutateAsync, isLoading } = - type === "application" - ? api.application.clearDeployments.useMutation() - : api.compose.clearDeployments.useMutation(); - const { data: isCloud } = api.settings.isCloud.useQuery(); + const utils = api.useUtils(); + const { mutateAsync, isLoading } = + type === "application" + ? api.application.clearDeployments.useMutation() + : api.compose.clearDeployments.useMutation(); + const { data: isCloud } = api.settings.isCloud.useQuery(); - if (isCloud) { - return null; - } + if (isCloud) { + return null; + } - return ( - - - - - - - - Are you sure you want to clear old deployments? - - - This will delete all old deployment records and logs, keeping only the active deployment (the most recent successful one). - - - - Cancel - { - await mutateAsync({ - applicationId: id || "", - composeId: id || "", - }) - .then(async (result) => { - toast.success(`${result.deletedCount} old deployments cleared successfully`); - // Invalidate deployment queries to refresh the list - await utils.deployment.allByType.invalidate({ - id, - type, - }); - }) - .catch((err) => { - toast.error(err.message); - }); - }} - > - Confirm - - - - - ); + return ( + + + + + + + + Are you sure you want to clear old deployments? + + + This will delete all old deployment records and logs, keeping only + the active deployment (the most recent successful one). + + + + Cancel + { + await mutateAsync({ + applicationId: id || "", + composeId: id || "", + }) + .then(async (result) => { + toast.success( + `${result.deletedCount} old deployments cleared successfully`, + ); + // Invalidate deployment queries to refresh the list + await utils.deployment.allByType.invalidate({ + id, + type, + }); + }) + .catch((err) => { + toast.error(err.message); + }); + }} + > + Confirm + + + + + ); }; diff --git a/apps/dokploy/server/api/routers/application.ts b/apps/dokploy/server/api/routers/application.ts index 71d5dadb3..1cd659644 100644 --- a/apps/dokploy/server/api/routers/application.ts +++ b/apps/dokploy/server/api/routers/application.ts @@ -745,10 +745,13 @@ export const applicationRouter = createTRPCRouter({ ) { throw new TRPCError({ code: "UNAUTHORIZED", - message: "You are not authorized to clear deployments for this application", + message: + "You are not authorized to clear deployments for this application", }); } - const result = await clearOldDeploymentsByApplicationId(input.applicationId); + const result = await clearOldDeploymentsByApplicationId( + input.applicationId, + ); return { success: true, message: `${result.deletedCount} old deployments cleared successfully`, diff --git a/apps/dokploy/server/api/routers/compose.ts b/apps/dokploy/server/api/routers/compose.ts index 2b548e1f0..7e5ccf52e 100644 --- a/apps/dokploy/server/api/routers/compose.ts +++ b/apps/dokploy/server/api/routers/compose.ts @@ -263,7 +263,8 @@ export const composeRouter = createTRPCRouter({ ) { throw new TRPCError({ code: "UNAUTHORIZED", - message: "You are not authorized to clear deployments for this compose", + message: + "You are not authorized to clear deployments for this compose", }); } const result = await clearOldDeploymentsByComposeId(input.composeId); diff --git a/packages/server/src/services/deployment.ts b/packages/server/src/services/deployment.ts index 1ba477cf0..279a089aa 100644 --- a/packages/server/src/services/deployment.ts +++ b/packages/server/src/services/deployment.ts @@ -849,7 +849,7 @@ export const clearOldDeploymentsByApplicationId = async ( // If there's an active deployment, keep it and remove all others // If there's no active deployment, keep the most recent one and remove the rest let deploymentsToKeep: string[] = []; - + if (activeDeployment) { deploymentsToKeep.push(activeDeployment.deploymentId); } else if (deploymentsList.length > 0) { @@ -866,7 +866,7 @@ export const clearOldDeploymentsByApplicationId = async ( if (deployment.rollbackId) { await removeRollbackById(deployment.rollbackId); } - + // Remove log file if it exists const logPath = deployment.logPath; if (logPath && logPath !== "." && existsSync(logPath)) { @@ -876,7 +876,7 @@ export const clearOldDeploymentsByApplicationId = async ( console.error(`Error removing log file ${logPath}:`, error); } } - + // Delete deployment from database await removeDeployment(deployment.deploymentId); } @@ -902,7 +902,7 @@ export const clearOldDeploymentsByComposeId = async (composeId: string) => { // If there's an active deployment, keep it and remove all others // If there's no active deployment, keep the most recent one and remove the rest let deploymentsToKeep: string[] = []; - + if (activeDeployment) { deploymentsToKeep.push(activeDeployment.deploymentId); } else if (deploymentsList.length > 0) { @@ -919,7 +919,7 @@ export const clearOldDeploymentsByComposeId = async (composeId: string) => { if (deployment.rollbackId) { await removeRollbackById(deployment.rollbackId); } - + // Remove log file if it exists const logPath = deployment.logPath; if (logPath && logPath !== "." && existsSync(logPath)) { @@ -929,7 +929,7 @@ export const clearOldDeploymentsByComposeId = async (composeId: string) => { console.error(`Error removing log file ${logPath}:`, error); } } - + // Delete deployment from database await removeDeployment(deployment.deploymentId); }