From c042c8c0c5834bbfc2404334214f56876e2b85f1 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Mon, 30 Jun 2025 01:25:50 -0600 Subject: [PATCH] feat: implement service-based volume selection for backups - Added a new query to load mounts by service name, enhancing the volume backup form's functionality. - Updated the form to allow users to select a service and corresponding volume from a dropdown, improving user experience. - Retained the option for manual input of volume names, ensuring flexibility in volume selection. - Refactored the component to streamline the handling of service and volume selections. --- .../volume-backups/handle-volume-backups.tsx | 370 ++++++++++-------- apps/dokploy/server/api/routers/compose.ts | 22 ++ .../server/src/utils/volume-backups/utils.ts | 62 +++ 3 files changed, 292 insertions(+), 162 deletions(-) create mode 100644 packages/server/src/utils/volume-backups/utils.ts 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 04a027cb8..f0f00bd26 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 @@ -154,6 +154,18 @@ export const HandleVolumeBackups = ({ }, ); + const serviceName = form.watch("serviceName"); + + const { data: mountsByService } = api.compose.loadMountsByService.useQuery( + { + composeId: id || "", + serviceName, + }, + { + enabled: !!id && volumeBackupType === "compose" && !!serviceName, + }, + ); + useEffect(() => { if (volumeBackupId && volumeBackup) { form.reset({ @@ -261,117 +273,6 @@ export const HandleVolumeBackups = ({