feat: add volume selection functionality to volume backup form

- Introduced a new query to fetch named mounts by application ID, enhancing the volume backup form.
- Updated the form to allow users to select a volume from a dropdown, improving user experience.
- Retained the option for manual input of volume names, ensuring flexibility in volume selection.
This commit is contained in:
Mauricio Siu
2025-06-29 23:24:44 -06:00
parent 12860a0736
commit 819a310d48
2 changed files with 74 additions and 16 deletions

View File

@@ -3,6 +3,7 @@ import {
apiFindOneMount,
apiRemoveMount,
apiUpdateMount,
mounts,
} from "@/server/db/schema";
import {
createMount,
@@ -11,6 +12,9 @@ import {
updateMount,
} from "@dokploy/server";
import { createTRPCRouter, protectedProcedure } from "../trpc";
import { z } from "zod";
import { and, eq } from "drizzle-orm";
import { db } from "@dokploy/server/db";
export const mountRouter = createTRPCRouter({
create: protectedProcedure
@@ -33,4 +37,14 @@ export const mountRouter = createTRPCRouter({
.mutation(async ({ input }) => {
return await updateMount(input.mountId, input);
}),
allNamedByApplicationId: protectedProcedure
.input(z.object({ applicationId: z.string().min(1) }))
.query(async ({ input }) => {
return await db.query.mounts.findMany({
where: and(
eq(mounts.applicationId, input.applicationId),
eq(mounts.type, "volume"),
),
});
}),
});