mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
chore: remove application delete volume
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
@@ -32,7 +31,6 @@ const deleteApplicationSchema = z.object({
|
||||
projectName: z.string().min(1, {
|
||||
message: "Application name is required",
|
||||
}),
|
||||
deleteVolumes: z.boolean(),
|
||||
});
|
||||
|
||||
type DeleteApplication = z.infer<typeof deleteApplicationSchema>;
|
||||
@@ -46,13 +44,12 @@ export const DeleteApplication = ({ applicationId }: Props) => {
|
||||
const { mutateAsync, isLoading } = api.application.delete.useMutation();
|
||||
const { data } = api.application.one.useQuery(
|
||||
{ applicationId },
|
||||
{ enabled: !!applicationId },
|
||||
{ enabled: !!applicationId }
|
||||
);
|
||||
const { push } = useRouter();
|
||||
const form = useForm<DeleteApplication>({
|
||||
defaultValues: {
|
||||
projectName: "",
|
||||
deleteVolumes: false,
|
||||
},
|
||||
resolver: zodResolver(deleteApplicationSchema),
|
||||
});
|
||||
@@ -62,7 +59,6 @@ export const DeleteApplication = ({ applicationId }: Props) => {
|
||||
if (formData.projectName === expectedName) {
|
||||
await mutateAsync({
|
||||
applicationId,
|
||||
deleteVolumes: formData.deleteVolumes,
|
||||
})
|
||||
.then((data) => {
|
||||
push(`/dashboard/project/${data?.projectId}`);
|
||||
@@ -116,7 +112,7 @@ export const DeleteApplication = ({ applicationId }: Props) => {
|
||||
onClick={() => {
|
||||
if (data?.name && data?.appName) {
|
||||
navigator.clipboard.writeText(
|
||||
`${data.name}/${data.appName}`,
|
||||
`${data.name}/${data.appName}`
|
||||
);
|
||||
toast.success("Copied to clipboard. Be careful!");
|
||||
}
|
||||
@@ -138,27 +134,6 @@ export const DeleteApplication = ({ applicationId }: Props) => {
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="deleteVolumes"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<div className="flex items-center">
|
||||
<FormControl>
|
||||
<Checkbox
|
||||
checked={field.value}
|
||||
onCheckedChange={field.onChange}
|
||||
/>
|
||||
</FormControl>
|
||||
|
||||
<FormLabel className="ml-2">
|
||||
Delete volumes associated with this compose
|
||||
</FormLabel>
|
||||
</div>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</form>
|
||||
</Form>
|
||||
</div>
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
import { db } from "@/server/db";
|
||||
import {
|
||||
apiCreateApplication,
|
||||
apiDeleteApplication,
|
||||
apiFindMonitoringStats,
|
||||
apiFindOneApplication,
|
||||
apiReloadApplication,
|
||||
@@ -103,7 +102,7 @@ export const applicationRouter = createTRPCRouter({
|
||||
await checkServiceAccess(
|
||||
ctx.user.authId,
|
||||
input.applicationId,
|
||||
"access",
|
||||
"access"
|
||||
);
|
||||
}
|
||||
const application = await findApplicationById(input.applicationId);
|
||||
@@ -143,13 +142,13 @@ export const applicationRouter = createTRPCRouter({
|
||||
}),
|
||||
|
||||
delete: protectedProcedure
|
||||
.input(apiDeleteApplication)
|
||||
.input(apiFindOneApplication)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
if (ctx.user.rol === "user") {
|
||||
await checkServiceAccess(
|
||||
ctx.user.authId,
|
||||
input.applicationId,
|
||||
"delete",
|
||||
"delete"
|
||||
);
|
||||
}
|
||||
const application = await findApplicationById(input.applicationId);
|
||||
@@ -174,16 +173,12 @@ export const applicationRouter = createTRPCRouter({
|
||||
async () =>
|
||||
await removeMonitoringDirectory(
|
||||
application.appName,
|
||||
application.serverId,
|
||||
application.serverId
|
||||
),
|
||||
async () =>
|
||||
await removeTraefikConfig(application.appName, application.serverId),
|
||||
async () =>
|
||||
await removeService(
|
||||
application?.appName,
|
||||
application.serverId,
|
||||
input.deleteVolumes,
|
||||
),
|
||||
await removeService(application?.appName, application.serverId),
|
||||
];
|
||||
|
||||
for (const operation of cleanupOperations) {
|
||||
@@ -266,7 +261,7 @@ export const applicationRouter = createTRPCRouter({
|
||||
{
|
||||
removeOnComplete: true,
|
||||
removeOnFail: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
}),
|
||||
saveEnvironment: protectedProcedure
|
||||
@@ -497,7 +492,7 @@ export const applicationRouter = createTRPCRouter({
|
||||
{
|
||||
removeOnComplete: true,
|
||||
removeOnFail: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
}),
|
||||
|
||||
@@ -529,7 +524,7 @@ export const applicationRouter = createTRPCRouter({
|
||||
if (application.serverId) {
|
||||
traefikConfig = await readRemoteConfig(
|
||||
application.serverId,
|
||||
application.appName,
|
||||
application.appName
|
||||
);
|
||||
} else {
|
||||
traefikConfig = readConfig(application.appName);
|
||||
@@ -586,7 +581,7 @@ export const applicationRouter = createTRPCRouter({
|
||||
{
|
||||
removeOnComplete: true,
|
||||
removeOnFail: true,
|
||||
},
|
||||
}
|
||||
);
|
||||
return true;
|
||||
}),
|
||||
@@ -606,7 +601,7 @@ export const applicationRouter = createTRPCRouter({
|
||||
await writeConfigRemote(
|
||||
application.serverId,
|
||||
application.appName,
|
||||
input.traefikConfig,
|
||||
input.traefikConfig
|
||||
);
|
||||
} else {
|
||||
writeConfig(application.appName, input.traefikConfig);
|
||||
|
||||
@@ -126,7 +126,7 @@ export const applications = pgTable("application", {
|
||||
.default("none"),
|
||||
previewLimit: integer("previewLimit").default(3),
|
||||
isPreviewDeploymentsActive: boolean("isPreviewDeploymentsActive").default(
|
||||
false,
|
||||
false
|
||||
),
|
||||
buildArgs: text("buildArgs"),
|
||||
memoryReservation: integer("memoryReservation"),
|
||||
@@ -170,7 +170,7 @@ export const applications = pgTable("application", {
|
||||
() => sshKeys.sshKeyId,
|
||||
{
|
||||
onDelete: "set null",
|
||||
},
|
||||
}
|
||||
),
|
||||
dockerfile: text("dockerfile"),
|
||||
dockerContextPath: text("dockerContextPath"),
|
||||
@@ -255,7 +255,7 @@ export const applicationsRelations = relations(
|
||||
references: [server.serverId],
|
||||
}),
|
||||
previewDeployments: many(previewDeployments),
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
const HealthCheckSwarmSchema = z
|
||||
@@ -341,7 +341,7 @@ const NetworkSwarmSchema = z.array(
|
||||
Aliases: z.array(z.string()).optional(),
|
||||
DriverOpts: z.object({}).optional(),
|
||||
})
|
||||
.strict(),
|
||||
.strict()
|
||||
);
|
||||
|
||||
const LabelsSwarmSchema = z.record(z.string());
|
||||
@@ -495,7 +495,7 @@ export const apiSaveGitProvider = createSchema
|
||||
.merge(
|
||||
createSchema.pick({
|
||||
customGitSSHKeyId: true,
|
||||
}),
|
||||
})
|
||||
);
|
||||
|
||||
export const apiSaveEnvironmentVariables = createSchema
|
||||
@@ -518,8 +518,3 @@ export const apiUpdateApplication = createSchema
|
||||
applicationId: z.string().min(1),
|
||||
})
|
||||
.omit({ serverId: true });
|
||||
|
||||
export const apiDeleteApplication = z.object({
|
||||
applicationId: z.string().min(1),
|
||||
deleteVolumes: z.boolean(),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user