mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-08 07:25:22 +02:00
feat(docker): implement container removal functionality
- Added RemoveContainerDialog component for user confirmation before removing a Docker container. - Integrated the dialog into the container management UI. - Implemented server-side logic for container removal, including permission checks and error handling. - Updated API router to include the new removeContainer mutation.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
containerRemove,
|
||||
containerRestart,
|
||||
findServerById,
|
||||
getConfig,
|
||||
@@ -52,6 +53,32 @@ export const dockerRouter = createTRPCRouter({
|
||||
return result;
|
||||
}),
|
||||
|
||||
removeContainer: withPermission("docker", "read")
|
||||
.input(
|
||||
z.object({
|
||||
containerId: z
|
||||
.string()
|
||||
.min(1)
|
||||
.regex(containerIdRegex, "Invalid container id."),
|
||||
serverId: z.string().optional(),
|
||||
}),
|
||||
)
|
||||
.mutation(async ({ input, ctx }) => {
|
||||
if (input.serverId) {
|
||||
const server = await findServerById(input.serverId);
|
||||
if (server.organizationId !== ctx.session?.activeOrganizationId) {
|
||||
throw new TRPCError({ code: "UNAUTHORIZED" });
|
||||
}
|
||||
}
|
||||
await containerRemove(input.containerId, input.serverId);
|
||||
await audit(ctx, {
|
||||
action: "delete",
|
||||
resourceType: "docker",
|
||||
resourceId: input.containerId,
|
||||
resourceName: input.containerId,
|
||||
});
|
||||
}),
|
||||
|
||||
getConfig: withPermission("docker", "read")
|
||||
.input(
|
||||
z.object({
|
||||
|
||||
Reference in New Issue
Block a user