mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-07 04:22:16 +00:00
refactor(deployments): streamline deployment clearing process and remove cloud check
- Removed the cloud check from the ClearDeployments component, simplifying the logic. - Updated the clearOldDeployments function to accept appName and serverId, enhancing its flexibility. - Adjusted the return values in the application and compose routers to return a boolean instead of a detailed message, improving consistency.
This commit is contained in:
@@ -25,11 +25,6 @@ export const ClearDeployments = ({ id, type }: Props) => {
|
||||
type === "application"
|
||||
? api.application.clearDeployments.useMutation()
|
||||
: api.compose.clearDeployments.useMutation();
|
||||
const { data: isCloud } = api.settings.isCloud.useQuery();
|
||||
|
||||
if (isCloud) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<AlertDialog>
|
||||
@@ -57,14 +52,11 @@ export const ClearDeployments = ({ id, type }: Props) => {
|
||||
applicationId: id || "",
|
||||
composeId: id || "",
|
||||
})
|
||||
.then(async (result) => {
|
||||
toast.success(
|
||||
`${result.deletedCount} old deployments cleared successfully`,
|
||||
);
|
||||
// Invalidate deployment queries to refresh the list
|
||||
.then(async () => {
|
||||
toast.success("Old deployments cleared successfully");
|
||||
await utils.deployment.allByType.invalidate({
|
||||
id,
|
||||
type,
|
||||
type: type as "application" | "compose",
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
|
||||
@@ -761,12 +761,8 @@ export const applicationRouter = createTRPCRouter({
|
||||
"You are not authorized to clear deployments for this application",
|
||||
});
|
||||
}
|
||||
const result = await clearOldDeployments(input.applicationId);
|
||||
return {
|
||||
success: true,
|
||||
message: `${result.deletedCount} old deployments cleared successfully`,
|
||||
deletedCount: result.deletedCount,
|
||||
};
|
||||
await clearOldDeployments(application.appName, application.serverId);
|
||||
return true;
|
||||
}),
|
||||
killBuild: protectedProcedure
|
||||
.input(apiFindOneApplication)
|
||||
|
||||
@@ -278,12 +278,8 @@ export const composeRouter = createTRPCRouter({
|
||||
"You are not authorized to clear deployments for this compose",
|
||||
});
|
||||
}
|
||||
const result = await clearOldDeployments(input.composeId, "compose");
|
||||
return {
|
||||
success: true,
|
||||
message: `${result.deletedCount} old deployments cleared successfully`,
|
||||
deletedCount: result.deletedCount,
|
||||
};
|
||||
await clearOldDeployments(compose.appName, compose.serverId);
|
||||
return true;
|
||||
}),
|
||||
killBuild: protectedProcedure
|
||||
.input(apiFindCompose)
|
||||
|
||||
Reference in New Issue
Block a user