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.
This commit is contained in:
Mauricio Siu
2025-06-30 01:25:50 -06:00
parent 819a310d48
commit c042c8c0c5
3 changed files with 292 additions and 162 deletions

View File

@@ -32,6 +32,7 @@ import {
findProjectById,
findServerById,
findUserById,
getComposeContainer,
loadServices,
randomizeComposeFile,
randomizeIsolatedDeploymentComposeFile,
@@ -241,6 +242,27 @@ export const composeRouter = createTRPCRouter({
}
return await loadServices(input.composeId, input.type);
}),
loadMountsByService: protectedProcedure
.input(
z.object({
composeId: z.string().min(1),
serviceName: z.string().min(1),
}),
)
.query(async ({ input, ctx }) => {
const compose = await findComposeById(input.composeId);
if (compose.project.organizationId !== ctx.session.activeOrganizationId) {
throw new TRPCError({
code: "UNAUTHORIZED",
message: "You are not authorized to load this compose",
});
}
const container = await getComposeContainer(compose, input.serviceName);
const mounts = container?.Mounts.filter(
(mount) => mount.Type === "volume" && mount.Source !== "",
);
return mounts;
}),
fetchSourceType: protectedProcedure
.input(apiFindCompose)
.mutation(async ({ input, ctx }) => {