Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
feat: confirm before bulk updating containers and projects (#4347)
Kyle Mendellf5672c9ed0d4
diff --git a/frontend/messages/en.json b/frontend/messages/en.jsonindex faf5ba658..472e45cc8 100644--- a/frontend/messages/en.json+++ b/frontend/messages/en.json@@ -617,7 +617,6 @@"containers_commit_success": "Created image {imageId}","containers_check_updates": "Update Containers","containers_check_updates_failed": "Failed to Check Containers for Updates",- "containers_check_updates_success": "Containers Updated Successfully.","containers_resource_sort_unsupported": "Sorting by CPU or memory usage needs a newer agent for this environment. Update the agent to sort by live resource usage.","containers_resource_refresh_failed": "Automatic refresh failed: {message}","update_container": "Update Container",@@ -1410,6 +1409,7 @@"compose_total": "Total Projects","compose_create_project": "Create Project","compose_update_projects": "Update Projects",+ "compose_update_projects_confirm_message": "This checks every image for updates and redeploys each project with a pending update on this environment. Do you want to continue?","compose_update_success": "Compose Projects Updated Successfully.","compose_start_failed": "Failed to start project","compose_start_success": "Project started successfully.",diff --git a/frontend/src/lib/query/query-keys.ts b/frontend/src/lib/query/query-keys.tsindex 7e48c1a2b..8a69034fa 100644--- a/frontend/src/lib/query/query-keys.ts+++ b/frontend/src/lib/query/query-keys.ts@@ -115,7 +115,6 @@ export const queryKeys = {all: ['containers'] as const,list: (environmentId: string, options: SearchPaginationSortRequest) =>['containers', environmentId, stableSerialize(options)] as const,- checkUpdates: (environmentId: string) => ['containers', 'check-updates', environmentId] as const,create: (environmentId: string) => ['containers', 'create', environmentId] as const,statusCounts: (environmentId: string) => ['containers', 'status-counts', environmentId] as const,detail: (environmentId: string, containerId: string) => ['container', environmentId, containerId] as const,diff --git a/frontend/src/routes/(app)/containers/+page.svelte b/frontend/src/routes/(app)/containers/+page.svelteindex b86cdfddb..b47828aa0 100644--- a/frontend/src/routes/(app)/containers/+page.svelte+++ b/frontend/src/routes/(app)/containers/+page.svelte@@ -1,21 +1,17 @@<script lang="ts">import { goto } from '$app/navigation';- import { createMutation } from '@tanstack/svelte-query';import { untrack } from 'svelte';- import { toast } from 'svelte-sonner';import { BoxIcon } from '#lib/icons/index.js';import { ResourcePageLayout, type ActionButton, type StatCardConfig } from '#lib/layouts/index.js';import { m } from '#lib/paraglide/messages.js';- import { queryKeys } from '#lib/query/query-keys.js';import { containerService } from '#lib/services/container-service.js';import type { ContainerListRequestOptions } from '#lib/services/container-service.js';- import { imageService } from '#lib/services/image-service.js';import { environmentStore } from '#lib/stores/environment.store.svelte.js';import type { ContainerStatusCounts } from '#lib/types/docker.js';import type { SearchPaginationSortRequest } from '#lib/types/shared.js';- import { activityToastOptions, extractActivityId } from '#lib/utils/activity-toast.js';import { hasPermission } from '#lib/utils/auth.js';+ import { confirmAndApplyAllUpdates } from '#lib/utils/update-actions.js';import ContainerEnvironmentSync from './components/container-environment-sync.svelte';import ContainerTable from './components/container-table.svelte';@@ -31,6 +27,7 @@let refreshGeneration = 0;let groupByProject = $state(false);let hasSeenEnvironmentSync = $state(false);+ let isApplyingUpdates = $state(false);const resourcesReady = $derived(displayedEnvId === envId);const countsFallback: ContainerStatusCounts = {@@ -66,24 +63,6 @@}}- const checkUpdatesMutation = createMutation(() => ({- mutationKey: queryKeys.containers.checkUpdates(envId),- mutationFn: async () => {- const requestedEnvId = envId;- const result = await imageService.runAutoUpdate(undefined, requestedEnvId);- return { requestedEnvId, result };- },- onSuccess: async ({ requestedEnvId, result }) => {- toast.success(m.containers_check_updates_success(), activityToastOptions(extractActivityId(result)));- if (requestedEnvId === envId) {- await refreshContainers(buildRequestOptions(), requestedEnvId);- }- },- onError: () => {- toast.error(m.containers_check_updates_failed());- }- }));-function handleEnvironmentChange() {if (!hasSeenEnvironmentSync) {hasSeenEnvironmentSync = true;@@ -111,10 +90,6 @@return refreshContainers(buildRequestOptions(nextOptions), envId);}- async function handleCheckForUpdates() {- await checkUpdatesMutation.mutateAsync();- }-async function refresh() {await refreshContainers();}@@ -141,9 +116,13 @@id: 'check-updates',action: 'update',label: m.containers_check_updates(),- onclick: handleCheckForUpdates,- loading: checkUpdatesMutation.isPending,- disabled: !resourcesReady || checkUpdatesMutation.isPending+ onclick: () =>+ confirmAndApplyAllUpdates({+ setLoading: (loading) => (isApplyingUpdates = loading),+ onRefresh: () => refreshContainers()+ }),+ loading: isApplyingUpdates,+ disabled: !resourcesReady || isApplyingUpdates}: null,{diff --git a/frontend/src/routes/(app)/projects/+page.svelte b/frontend/src/routes/(app)/projects/+page.svelteindex b1c4b725e..07253a4b6 100644--- a/frontend/src/routes/(app)/projects/+page.svelte+++ b/frontend/src/routes/(app)/projects/+page.svelte@@ -5,6 +5,7 @@import { untrack } from 'svelte';import { toast } from 'svelte-sonner';+ import { openConfirmDialog } from '#lib/components/confirm-dialog/index.js';import { EmptyState } from '#lib/components/states/index.js';import { useEnvironmentRefresh } from '#lib/hooks/use-environment-refresh.svelte.js';import { BoxIcon, ProjectsIcon, StartIcon, StopIcon } from '#lib/icons/index.js';@@ -166,8 +167,16 @@const archivedCompose = $derived(projectStatusCounts.archivedProjects);const isRefreshBlocked = $derived(isManualRefreshing || projectsQuery.isFetching || projectStatusCountsQuery.isFetching);- async function handleCheckForUpdates() {- await checkUpdatesMutation.mutateAsync(envId);+ function handleCheckForUpdates() {+ openConfirmDialog({+ title: m.compose_update_projects(),+ message: m.compose_update_projects_confirm_message(),+ confirm: {+ label: m.compose_update_projects(),+ destructive: false,+ action: () => checkUpdatesMutation.mutate(envId)+ }+ });}async function refreshCompose() {diff --git a/tests/spec/projects.spec.ts b/tests/spec/projects.spec.tsindex 6ed4d4b6b..ede871851 100644--- a/tests/spec/projects.spec.ts+++ b/tests/spec/projects.spec.ts@@ -421,6 +421,12 @@ test.describe('Projects Page', () => {await clickProjectsPageUpdateAction(page);+ // The check only starts once the confirmation dialog is accepted+ const dialog = page.getByRole('dialog');+ await expect(dialog).toBeVisible();+ expect(checkAllRequests).toBe(0);+ await dialog.getByRole('button', { name: 'Update Projects', exact: true }).click();+await expect.poll(() => checkAllRequests).toBe(1);expect(updaterRunRequests).toBe(0);});