Skip to content

Commit 270ebd6

Browse files
autofix-ci[bot]mcfdez
authored andcommitted
[autofix.ci] apply automated fixes
1 parent 8c8a3c4 commit 270ebd6

File tree

4 files changed

+80
-73
lines changed

4 files changed

+80
-73
lines changed
Lines changed: 67 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,81 @@
11
import { Paintbrush } from "lucide-react";
22
import { toast } from "sonner";
33
import {
4-
AlertDialog,
5-
AlertDialogAction,
6-
AlertDialogCancel,
7-
AlertDialogContent,
8-
AlertDialogDescription,
9-
AlertDialogFooter,
10-
AlertDialogHeader,
11-
AlertDialogTitle,
12-
AlertDialogTrigger,
4+
AlertDialog,
5+
AlertDialogAction,
6+
AlertDialogCancel,
7+
AlertDialogContent,
8+
AlertDialogDescription,
9+
AlertDialogFooter,
10+
AlertDialogHeader,
11+
AlertDialogTitle,
12+
AlertDialogTrigger,
1313
} from "@/components/ui/alert-dialog";
1414
import { Button } from "@/components/ui/button";
1515
import { api } from "@/utils/api";
1616

1717
interface Props {
18-
id: string;
19-
type: "application" | "compose";
18+
id: string;
19+
type: "application" | "compose";
2020
}
2121

2222
export const ClearDeployments = ({ id, type }: Props) => {
23-
const utils = api.useUtils();
24-
const { mutateAsync, isLoading } =
25-
type === "application"
26-
? api.application.clearDeployments.useMutation()
27-
: api.compose.clearDeployments.useMutation();
28-
const { data: isCloud } = api.settings.isCloud.useQuery();
23+
const utils = api.useUtils();
24+
const { mutateAsync, isLoading } =
25+
type === "application"
26+
? api.application.clearDeployments.useMutation()
27+
: api.compose.clearDeployments.useMutation();
28+
const { data: isCloud } = api.settings.isCloud.useQuery();
2929

30-
if (isCloud) {
31-
return null;
32-
}
30+
if (isCloud) {
31+
return null;
32+
}
3333

34-
return (
35-
<AlertDialog>
36-
<AlertDialogTrigger asChild>
37-
<Button variant="outline" className="w-fit" isLoading={isLoading}>
38-
Clear deployments
39-
<Paintbrush className="size-4" />
40-
</Button>
41-
</AlertDialogTrigger>
42-
<AlertDialogContent>
43-
<AlertDialogHeader>
44-
<AlertDialogTitle>
45-
Are you sure you want to clear old deployments?
46-
</AlertDialogTitle>
47-
<AlertDialogDescription>
48-
This will delete all old deployment records and logs, keeping only the active deployment (the most recent successful one).
49-
</AlertDialogDescription>
50-
</AlertDialogHeader>
51-
<AlertDialogFooter>
52-
<AlertDialogCancel>Cancel</AlertDialogCancel>
53-
<AlertDialogAction
54-
onClick={async () => {
55-
await mutateAsync({
56-
applicationId: id || "",
57-
composeId: id || "",
58-
})
59-
.then(async (result) => {
60-
toast.success(`${result.deletedCount} old deployments cleared successfully`);
61-
// Invalidate deployment queries to refresh the list
62-
await utils.deployment.allByType.invalidate({
63-
id,
64-
type,
65-
});
66-
})
67-
.catch((err) => {
68-
toast.error(err.message);
69-
});
70-
}}
71-
>
72-
Confirm
73-
</AlertDialogAction>
74-
</AlertDialogFooter>
75-
</AlertDialogContent>
76-
</AlertDialog>
77-
);
34+
return (
35+
<AlertDialog>
36+
<AlertDialogTrigger asChild>
37+
<Button variant="outline" className="w-fit" isLoading={isLoading}>
38+
Clear deployments
39+
<Paintbrush className="size-4" />
40+
</Button>
41+
</AlertDialogTrigger>
42+
<AlertDialogContent>
43+
<AlertDialogHeader>
44+
<AlertDialogTitle>
45+
Are you sure you want to clear old deployments?
46+
</AlertDialogTitle>
47+
<AlertDialogDescription>
48+
This will delete all old deployment records and logs, keeping only
49+
the active deployment (the most recent successful one).
50+
</AlertDialogDescription>
51+
</AlertDialogHeader>
52+
<AlertDialogFooter>
53+
<AlertDialogCancel>Cancel</AlertDialogCancel>
54+
<AlertDialogAction
55+
onClick={async () => {
56+
await mutateAsync({
57+
applicationId: id || "",
58+
composeId: id || "",
59+
})
60+
.then(async (result) => {
61+
toast.success(
62+
`${result.deletedCount} old deployments cleared successfully`,
63+
);
64+
// Invalidate deployment queries to refresh the list
65+
await utils.deployment.allByType.invalidate({
66+
id,
67+
type,
68+
});
69+
})
70+
.catch((err) => {
71+
toast.error(err.message);
72+
});
73+
}}
74+
>
75+
Confirm
76+
</AlertDialogAction>
77+
</AlertDialogFooter>
78+
</AlertDialogContent>
79+
</AlertDialog>
80+
);
7881
};

apps/dokploy/server/api/routers/application.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -745,10 +745,13 @@ export const applicationRouter = createTRPCRouter({
745745
) {
746746
throw new TRPCError({
747747
code: "UNAUTHORIZED",
748-
message: "You are not authorized to clear deployments for this application",
748+
message:
749+
"You are not authorized to clear deployments for this application",
749750
});
750751
}
751-
const result = await clearOldDeploymentsByApplicationId(input.applicationId);
752+
const result = await clearOldDeploymentsByApplicationId(
753+
input.applicationId,
754+
);
752755
return {
753756
success: true,
754757
message: `${result.deletedCount} old deployments cleared successfully`,

apps/dokploy/server/api/routers/compose.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ export const composeRouter = createTRPCRouter({
263263
) {
264264
throw new TRPCError({
265265
code: "UNAUTHORIZED",
266-
message: "You are not authorized to clear deployments for this compose",
266+
message:
267+
"You are not authorized to clear deployments for this compose",
267268
});
268269
}
269270
const result = await clearOldDeploymentsByComposeId(input.composeId);

packages/server/src/services/deployment.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ export const clearOldDeploymentsByApplicationId = async (
849849
// If there's an active deployment, keep it and remove all others
850850
// If there's no active deployment, keep the most recent one and remove the rest
851851
let deploymentsToKeep: string[] = [];
852-
852+
853853
if (activeDeployment) {
854854
deploymentsToKeep.push(activeDeployment.deploymentId);
855855
} else if (deploymentsList.length > 0) {
@@ -866,7 +866,7 @@ export const clearOldDeploymentsByApplicationId = async (
866866
if (deployment.rollbackId) {
867867
await removeRollbackById(deployment.rollbackId);
868868
}
869-
869+
870870
// Remove log file if it exists
871871
const logPath = deployment.logPath;
872872
if (logPath && logPath !== "." && existsSync(logPath)) {
@@ -876,7 +876,7 @@ export const clearOldDeploymentsByApplicationId = async (
876876
console.error(`Error removing log file ${logPath}:`, error);
877877
}
878878
}
879-
879+
880880
// Delete deployment from database
881881
await removeDeployment(deployment.deploymentId);
882882
}
@@ -902,7 +902,7 @@ export const clearOldDeploymentsByComposeId = async (composeId: string) => {
902902
// If there's an active deployment, keep it and remove all others
903903
// If there's no active deployment, keep the most recent one and remove the rest
904904
let deploymentsToKeep: string[] = [];
905-
905+
906906
if (activeDeployment) {
907907
deploymentsToKeep.push(activeDeployment.deploymentId);
908908
} else if (deploymentsList.length > 0) {
@@ -919,7 +919,7 @@ export const clearOldDeploymentsByComposeId = async (composeId: string) => {
919919
if (deployment.rollbackId) {
920920
await removeRollbackById(deployment.rollbackId);
921921
}
922-
922+
923923
// Remove log file if it exists
924924
const logPath = deployment.logPath;
925925
if (logPath && logPath !== "." && existsSync(logPath)) {
@@ -929,7 +929,7 @@ export const clearOldDeploymentsByComposeId = async (composeId: string) => {
929929
console.error(`Error removing log file ${logPath}:`, error);
930930
}
931931
}
932-
932+
933933
// Delete deployment from database
934934
await removeDeployment(deployment.deploymentId);
935935
}

0 commit comments

Comments
 (0)