mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-14 16:05:18 +00:00
[autofix.ci] apply automated fixes
This commit is contained in:
@@ -1,78 +1,81 @@
|
|||||||
import { Paintbrush } from "lucide-react";
|
import { Paintbrush } from "lucide-react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import {
|
import {
|
||||||
AlertDialog,
|
AlertDialog,
|
||||||
AlertDialogAction,
|
AlertDialogAction,
|
||||||
AlertDialogCancel,
|
AlertDialogCancel,
|
||||||
AlertDialogContent,
|
AlertDialogContent,
|
||||||
AlertDialogDescription,
|
AlertDialogDescription,
|
||||||
AlertDialogFooter,
|
AlertDialogFooter,
|
||||||
AlertDialogHeader,
|
AlertDialogHeader,
|
||||||
AlertDialogTitle,
|
AlertDialogTitle,
|
||||||
AlertDialogTrigger,
|
AlertDialogTrigger,
|
||||||
} from "@/components/ui/alert-dialog";
|
} from "@/components/ui/alert-dialog";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
id: string;
|
id: string;
|
||||||
type: "application" | "compose";
|
type: "application" | "compose";
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ClearDeployments = ({ id, type }: Props) => {
|
export const ClearDeployments = ({ id, type }: Props) => {
|
||||||
const utils = api.useUtils();
|
const utils = api.useUtils();
|
||||||
const { mutateAsync, isLoading } =
|
const { mutateAsync, isLoading } =
|
||||||
type === "application"
|
type === "application"
|
||||||
? api.application.clearDeployments.useMutation()
|
? api.application.clearDeployments.useMutation()
|
||||||
: api.compose.clearDeployments.useMutation();
|
: api.compose.clearDeployments.useMutation();
|
||||||
const { data: isCloud } = api.settings.isCloud.useQuery();
|
const { data: isCloud } = api.settings.isCloud.useQuery();
|
||||||
|
|
||||||
if (isCloud) {
|
if (isCloud) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AlertDialog>
|
<AlertDialog>
|
||||||
<AlertDialogTrigger asChild>
|
<AlertDialogTrigger asChild>
|
||||||
<Button variant="outline" className="w-fit" isLoading={isLoading}>
|
<Button variant="outline" className="w-fit" isLoading={isLoading}>
|
||||||
Clear deployments
|
Clear deployments
|
||||||
<Paintbrush className="size-4" />
|
<Paintbrush className="size-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</AlertDialogTrigger>
|
</AlertDialogTrigger>
|
||||||
<AlertDialogContent>
|
<AlertDialogContent>
|
||||||
<AlertDialogHeader>
|
<AlertDialogHeader>
|
||||||
<AlertDialogTitle>
|
<AlertDialogTitle>
|
||||||
Are you sure you want to clear old deployments?
|
Are you sure you want to clear old deployments?
|
||||||
</AlertDialogTitle>
|
</AlertDialogTitle>
|
||||||
<AlertDialogDescription>
|
<AlertDialogDescription>
|
||||||
This will delete all old deployment records and logs, keeping only the active deployment (the most recent successful one).
|
This will delete all old deployment records and logs, keeping only
|
||||||
</AlertDialogDescription>
|
the active deployment (the most recent successful one).
|
||||||
</AlertDialogHeader>
|
</AlertDialogDescription>
|
||||||
<AlertDialogFooter>
|
</AlertDialogHeader>
|
||||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
<AlertDialogFooter>
|
||||||
<AlertDialogAction
|
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||||
onClick={async () => {
|
<AlertDialogAction
|
||||||
await mutateAsync({
|
onClick={async () => {
|
||||||
applicationId: id || "",
|
await mutateAsync({
|
||||||
composeId: id || "",
|
applicationId: id || "",
|
||||||
})
|
composeId: id || "",
|
||||||
.then(async (result) => {
|
})
|
||||||
toast.success(`${result.deletedCount} old deployments cleared successfully`);
|
.then(async (result) => {
|
||||||
// Invalidate deployment queries to refresh the list
|
toast.success(
|
||||||
await utils.deployment.allByType.invalidate({
|
`${result.deletedCount} old deployments cleared successfully`,
|
||||||
id,
|
);
|
||||||
type,
|
// Invalidate deployment queries to refresh the list
|
||||||
});
|
await utils.deployment.allByType.invalidate({
|
||||||
})
|
id,
|
||||||
.catch((err) => {
|
type,
|
||||||
toast.error(err.message);
|
});
|
||||||
});
|
})
|
||||||
}}
|
.catch((err) => {
|
||||||
>
|
toast.error(err.message);
|
||||||
Confirm
|
});
|
||||||
</AlertDialogAction>
|
}}
|
||||||
</AlertDialogFooter>
|
>
|
||||||
</AlertDialogContent>
|
Confirm
|
||||||
</AlertDialog>
|
</AlertDialogAction>
|
||||||
);
|
</AlertDialogFooter>
|
||||||
|
</AlertDialogContent>
|
||||||
|
</AlertDialog>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -745,10 +745,13 @@ export const applicationRouter = createTRPCRouter({
|
|||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
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 {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: `${result.deletedCount} old deployments cleared successfully`,
|
message: `${result.deletedCount} old deployments cleared successfully`,
|
||||||
|
|||||||
@@ -263,7 +263,8 @@ export const composeRouter = createTRPCRouter({
|
|||||||
) {
|
) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "UNAUTHORIZED",
|
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);
|
const result = await clearOldDeploymentsByComposeId(input.composeId);
|
||||||
|
|||||||
Reference in New Issue
Block a user