From 819a310d484e43a4dc487f9d8f5684ece4380fb5 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 29 Jun 2025 23:24:44 -0600 Subject: [PATCH] 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. --- .../volume-backups/handle-volume-backups.tsx | 76 +++++++++++++++---- apps/dokploy/server/api/routers/mount.ts | 14 ++++ 2 files changed, 74 insertions(+), 16 deletions(-) diff --git a/apps/dokploy/components/dashboard/application/volume-backups/handle-volume-backups.tsx b/apps/dokploy/components/dashboard/application/volume-backups/handle-volume-backups.tsx index dbd7c2a1e..04a027cb8 100644 --- a/apps/dokploy/components/dashboard/application/volume-backups/handle-volume-backups.tsx +++ b/apps/dokploy/components/dashboard/application/volume-backups/handle-volume-backups.tsx @@ -132,6 +132,11 @@ export const HandleVolumeBackups = ({ { enabled: !!volumeBackupId }, ); + const { data: mounts } = api.mounts.allNamedByApplicationId.useQuery( + { applicationId: id || "" }, + { enabled: !!id }, + ); + const { data: services, isFetching: isLoadingServices, @@ -479,22 +484,61 @@ export const HandleVolumeBackups = ({ )} /> - ( - - Volume Name - - - - - The name of the Docker volume to backup - - - - )} - /> + {serviceTypeForm === "application" && ( + <> + ( + + Volumes + + + Choose the volume to backup, if you dont see the volume + here, you can type the volume name manually + + + + )} + /> + + ( + + Volume Name + + + + + The name of the Docker volume to backup + + + + )} + /> + + )} { 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"), + ), + }); + }), });