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