Skip to content

Modern Docker Management, Designed for Everyone

feat: add row, bulk, and Update All actions to the updates page (#3398)

Kyle Mendell30189ac7e677
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index 5e32a7e4e..60c10a43c 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -43,6 +43,9 @@
"common_unknown": "Unknown",
"common_remove": "Remove",
"common_update": "Update",
+ "common_ignore": "Ignore",
+ "common_unignore": "Unignore",
+ "common_ignored": "Ignored",
"common_id": "ID",
"common_name": "Name",
"common_status": "Status",
@@ -703,6 +706,19 @@
"images_untagged": "Untagged",
"images_used_by": "Used By",
"updates": "Updates",
+ "updates_apply_success": "Applied {updated} update(s)",
+ "updates_apply_partial": "Applied {updated} update(s), {failed} failed",
+ "updates_apply_failed": "Failed to apply {failed} update(s)",
+ "updates_apply_all_failed": "Failed to apply updates",
+ "updates_update_all_confirm_message": "This applies every pending update on this host, including any not shown on the current page. If Arcane itself has an update, Arcane restarts to upgrade after the other updates finish. Do you want to continue?",
+ "updates_bulk_update": "Update ({count})",
+ "updates_bulk_update_confirm_title": "Update {count} Resource(s)",
+ "updates_bulk_update_confirm_message": "This pulls the latest images and applies the pending updates for {count} selected resource(s). Do you want to continue?",
+ "updates_bulk_update_success": "Updated {count} resource(s)",
+ "updates_bulk_update_partial": "Updated {success} of {total} resource(s), {failed} failed",
+ "updates_bulk_update_failed": "Failed to update the selected resources",
+ "updates_ignore_description": "Exclude this container from automatic updates",
+ "updates_update_confirm_message": "This pulls the latest images and applies the pending updates for \"{name}\". Do you want to continue?",
"tag": "Tag",
"images_tag_image": "Tag Image",
"images_tag_dialog_description": "Add a repository tag to this image.",
diff --git a/frontend/src/lib/components/arcane-table/arcane-table-toolbar.svelte b/frontend/src/lib/components/arcane-table/arcane-table-toolbar.svelte
index 0965b9843..9dcb0aa1a 100644
--- a/frontend/src/lib/components/arcane-table/arcane-table-toolbar.svelte
+++ b/frontend/src/lib/components/arcane-table/arcane-table-toolbar.svelte
@@ -45,7 +45,10 @@
imageNameFilterOptions?: string[];
} = $props();
- const isFiltered = $derived(table.state.columnFilters.length > 0 || !!table.state.globalFilter);
+ // With `withoutFilters` the column filters aren't user-controlled — the page bakes
+ // in its own scoping filter (e.g. /updates pins `updates`), which would otherwise
+ // light up Reset on first paint and let a click wipe the page's own scope.
+ const isFiltered = $derived(!!table.state.globalFilter || (!withoutFilters && table.state.columnFilters.length > 0));
const usageColumn = $derived(table.getAllColumns().some((col) => col.id === 'inUse') ? table.getColumn('inUse') : undefined);
const updatesColumn = $derived(
table.getAllColumns().some((col) => col.id === 'updates') ? table.getColumn('updates') : undefined
@@ -164,7 +167,7 @@
icon={ResetIcon}
customLabel={m.common_reset()}
onclick={() => {
- table.setColumnFilters([]);
+ if (!withoutFilters) table.setColumnFilters([]);
table.setGlobalFilter('');
}}
class="h-9 shrink-0"
diff --git a/frontend/src/lib/components/arcane-table/arcane-table.types.svelte.ts b/frontend/src/lib/components/arcane-table/arcane-table.types.svelte.ts
index a7adc58f4..4eea15bdf 100644
--- a/frontend/src/lib/components/arcane-table/arcane-table.types.svelte.ts
+++ b/frontend/src/lib/components/arcane-table/arcane-table.types.svelte.ts
@@ -145,7 +145,19 @@ export function buildMobileVisibility(fields: FieldSpec[], persisted?: string[])
export type BulkAction = {
id: string;
label: string;
- action: 'base' | 'start' | 'stop' | 'restart' | 'remove' | 'deploy' | 'redeploy' | 'up' | 'down' | 'prune' | 'archive';
+ action:
+ | 'base'
+ | 'start'
+ | 'stop'
+ | 'restart'
+ | 'remove'
+ | 'deploy'
+ | 'redeploy'
+ | 'up'
+ | 'down'
+ | 'prune'
+ | 'archive'
+ | 'update';
onClick: (ids: string[]) => void;
disabled?: boolean;
disabledReason?: string;
diff --git a/frontend/src/lib/types/automation.ts b/frontend/src/lib/types/automation.ts
index 8a72b61c7..efb9a8e42 100644
--- a/frontend/src/lib/types/automation.ts
+++ b/frontend/src/lib/types/automation.ts
@@ -3,11 +3,11 @@
export type AutoUpdateResourceType = 'image' | 'container' | 'project';
export interface AutoUpdateCheck {
- type?: 'containers' | 'projects' | 'all';
+ /** Scopes `resourceIds`. Matches the backend's `updater.Options.Type` (singular). */
+ type?: AutoUpdateResourceType;
resourceIds?: string[];
forceUpdate?: boolean;
dryRun?: boolean;
- resourceType?: AutoUpdateResourceType;
}
export interface AutoUpdateResult {
diff --git a/frontend/src/lib/utils/bulk-actions.ts b/frontend/src/lib/utils/bulk-actions.ts
index 2ebb9d8d9..ade192578 100644
--- a/frontend/src/lib/utils/bulk-actions.ts
+++ b/frontend/src/lib/utils/bulk-actions.ts
@@ -207,7 +207,10 @@ export function confirmAndRun<T>({
label: confirmLabel,
destructive,
action: async () => {
- handleApiResultWithCallbacks({
+ // Flip loading before awaiting `run`, not after: these back row
+ // spinners, and the request is the part worth showing progress for.
+ setLoading?.(true);
+ await handleApiResultWithCallbacks({
result: await tryCatch(run()),
message: failureMessage,
setLoadingState: setLoading ?? (() => {}),
diff --git a/frontend/src/lib/utils/container-auto-update.ts b/frontend/src/lib/utils/container-auto-update.ts
new file mode 100644
index 000000000..ee1fcb0d8
--- /dev/null
+++ b/frontend/src/lib/utils/container-auto-update.ts
@@ -0,0 +1,43 @@
+/**
+ * Auto-update exclusion helpers shared by the container detail page, the
+ * environment jobs tab and the updates table. The backend stores exclusions as
+ * a CSV of container *names* in `autoUpdateExcludedContainers`, and the Docker
+ * label `com.getarcaneapp.arcane.updater=false` overrides that setting.
+ *
+ * Keyed on labels + a resolved name rather than a container DTO: the detail
+ * page has `ContainerDetailsDto.name` while the tables have
+ * `ContainerSummaryDto.names[]`.
+ */
+
+const AUTO_UPDATE_LABEL = 'com.getarcaneapp.arcane.updater';
+const DISABLED_LABEL_VALUES = ['false', '0', 'no', 'off'];
+
+/** Strips the leading slashes Docker puts on container names. */
+export function normalizeContainerName(name: string): string {
+ return name.replace(/^\/+/, '');
+}
+
+/** True when the Docker label opts the container out of auto-updates. */
+export function isAutoUpdateLabelDisabled(labels?: Record<string, string>): boolean {
+ if (!labels) return false;
+ const value = Object.entries(labels).find(([key]) => key.toLowerCase() === AUTO_UPDATE_LABEL)?.[1];
+ return !!value && DISABLED_LABEL_VALUES.includes(value.trim().toLowerCase());
+}
+
+/** Parses an `autoUpdateExcludedContainers`-style CSV into normalized names. */
+export function parseExcludedContainerSet(csv?: string): Set<string> {
+ return new Set(
+ (csv || '')
+ .split(',')
+ .map((entry) => normalizeContainerName(entry.trim()))
+ .filter(Boolean)
+ );
+}
+
+/** True when the container is excluded from auto-updates, by label or by setting. */
+export function isAutoUpdateIgnored(name: string, labels: Record<string, string> | undefined, excludedCsv?: string): boolean {
+ if (isAutoUpdateLabelDisabled(labels)) return true;
+ const normalized = normalizeContainerName(name ?? '');
+ if (!normalized) return false;
+ return parseExcludedContainerSet(excludedCsv).has(normalized);
+}
diff --git a/frontend/src/lib/utils/update-actions.ts b/frontend/src/lib/utils/update-actions.ts
new file mode 100644
index 000000000..fee979842
--- /dev/null
+++ b/frontend/src/lib/utils/update-actions.ts
@@ -0,0 +1,128 @@
+import { toast } from 'svelte-sonner';
+import { openConfirmDialog } from '#lib/components/confirm-dialog';
+import { m } from '#lib/paraglide/messages';
+import BaseAPIService from '#lib/services/api-service';
+import { imageService } from '#lib/services/image-service';
+import { userService } from '#lib/services/user-service';
+import { environmentStore } from '#lib/stores/environment.store.svelte';
+import { activityToastOptions } from '#lib/utils/activity-toast';
+import type { AutoUpdateResourceType, AutoUpdateResult } from '#lib/types/automation';
+
+/**
+ * Helpers around the updater run endpoint (`POST /environments/{id}/updater/run`),
+ * so the row actions, the bulk actions and Update All all summarize an
+ * `AutoUpdateResult` the same way.
+ */
+
+/** Applies pending updates for a single resource via a scoped updater run. */
+export function applyScopedUpdate(type: Extract<AutoUpdateResourceType, 'container' | 'project'>, id: string) {
+ return imageService.runAutoUpdate({ type, resourceIds: [id] });
+}
+
+/**
+ * The updater reports per-resource failures in the body of a 200, so a resolved
+ * promise alone does not mean the update landed. Bulk runners tally by
+ * rejection, so surface those failures as a throw before they get counted as
+ * successes.
+ */
+export function throwOnUpdateFailure<T extends Pick<AutoUpdateResult, 'failed' | 'items'>>(result: T): T {
+ if ((result?.failed ?? 0) > 0) {
+ const firstError = result.items?.find((item) => item.status === 'failed')?.error;
+ throw new Error(firstError || m.updates_bulk_update_failed());
+ }
+ return result;
+}
+
+/** Emits a single toast describing an updater run's updated/failed/skipped tally. */
+export function summarizeUpdateResult(result: AutoUpdateResult) {
+ const options = activityToastOptions(result.activityId);
+ const updated = (result.updated ?? 0) + (result.restarted ?? 0);
+ const failed = result.failed ?? 0;
+
+ if (failed > 0 && updated > 0) {
+ toast.warning(m.updates_apply_partial({ updated, failed }), options);
+ } else if (failed > 0) {
+ toast.error(m.updates_apply_failed({ failed }), options);
+ } else if (updated > 0) {
+ toast.success(m.updates_apply_success({ updated }), options);
+ } else {
+ toast.info(m.image_update_up_to_date_title(), options);
+ }
+}
+
+type ConfirmAndApplyAllUpdatesOptions = {
+ setLoading?: (loading: boolean) => void;
+ onRefresh?: () => Promise<unknown> | unknown;
+};
+
+const MANAGER_ENVIRONMENT_ID = '0';
+const SELF_UPGRADE_PROBE_INTERVAL_MS = 2000;
+/** Backstop so a backend that never returns can't leave the flag armed all session. */
+const SELF_UPGRADE_MAX_WAIT_MS = 5 * 60 * 1000;
+
+/**
+ * Disarms the upgrade flag as soon as this backend answers an *authenticated*
+ * request again.
+ *
+ * A queued Arcane self-update fires last, so the restart's version-mismatch
+ * 401s land after the response — and the engine reports a self-update as an
+ * ordinary `updated` item, so the payload can't say whether one happened.
+ * Probing settles it: when nothing restarted, the first probe succeeds and the
+ * recovery window closes in about one request instead of masking an unrelated
+ * expired session for minutes. While the backend is down the probe throws, so
+ * the flag stays armed for exactly as long as it is needed.
+ *
+ * The probe must be authenticated. A public endpoint (`/app-version`) answers
+ * 200 the instant the new backend binds its port, which would disarm before
+ * any authenticated request could trigger recovery. `/auth/me` instead returns
+ * the version-mismatch 401 itself, and — because it is not in the API client's
+ * skip-auth paths — that 401 drives the refresh-and-reload while still armed.
+ */
+async function disarmWhenBackendResponds() {
+ const deadline = Date.now() + SELF_UPGRADE_MAX_WAIT_MS;
+ for (;;) {
+ try {
+ await userService.getCurrentUser();
+ break;
+ } catch {
+ if (Date.now() >= deadline) break;
+ await new Promise((resolve) => setTimeout(resolve, SELF_UPGRADE_PROBE_INTERVAL_MS));
+ }
+ }
+ BaseAPIService.setUpgradeInProgress(false);
+}
+
+/**
+ * Confirms, then applies every pending update on the host (an empty-body
+ * updater run — the same path the nightly auto-update job takes).
+ */
+export function confirmAndApplyAllUpdates({ setLoading, onRefresh }: ConfirmAndApplyAllUpdatesOptions) {
+ openConfirmDialog({
+ title: m.update_all(),
+ message: m.updates_update_all_confirm_message(),
+ confirm: {
+ label: m.update_all(),
+ destructive: false,
+ action: async () => {
+ setLoading?.(true);
+ // An unscoped run can pick up Arcane's own container and route it
+ // through self-upgrade, restarting this backend. Only the local
+ // manager hosts this frontend's API, so only it needs the flag that
+ // makes the restart a recoverable reconnect instead of a logout.
+ const envId = await environmentStore.getCurrentEnvironmentId();
+ const restartsThisBackend = envId === MANAGER_ENVIRONMENT_ID;
+ if (restartsThisBackend) BaseAPIService.setUpgradeInProgress(true);
+ try {
+ summarizeUpdateResult(await imageService.runAutoUpdate());
+ await onRefresh?.();
+ } catch (error) {
+ console.error('Update all failed:', error);
+ toast.error(m.updates_apply_all_failed());
+ } finally {
+ if (restartsThisBackend) void disarmWhenBackendResponds();
+ setLoading?.(false);
+ }
+ }
+ }
+ });
+}
diff --git a/frontend/src/routes/(app)/containers/[containerId]/+page.svelte b/frontend/src/routes/(app)/containers/[containerId]/+page.svelte
index f92cb9b80..430741dc9 100644
--- a/frontend/src/routes/(app)/containers/[containerId]/+page.svelte
+++ b/frontend/src/routes/(app)/containers/[containerId]/+page.svelte
@@ -48,6 +48,7 @@
import * as DropdownMenu from '#lib/components/ui/dropdown-menu/index.js';
import { ImagesIcon, PauseIcon, PlayIcon, ZapIcon } from '#lib/icons';
import { runContainerLifecycleAction } from '#lib/utils/container-actions';
+ import { isAutoUpdateIgnored, isAutoUpdateLabelDisabled } from '#lib/utils/container-auto-update';
import KillContainerDialog from '../components/kill-container-dialog.svelte';
import { useUrlTab } from '#lib/hooks/use-url-tab.svelte';
let { data } = $props();
@@ -57,27 +58,13 @@
let autoScrollLogs = $state(true);
let hasInitialStatsLoaded = $state(false);
- // Auto-update: detect whether the Docker label controls the state (not toggleable via UI)
- function isAutoUpdateLabelControlled(c: ContainerDetailsDto): boolean {
- if (!c?.labels) return false;
- const labelValue = Object.entries(c.labels).find(([k]) => k.toLowerCase() === 'com.getarcaneapp.arcane.updater')?.[1];
- return !!labelValue && ['false', '0', 'no', 'off'].includes(labelValue.trim().toLowerCase());
- }
-
- function isAutoUpdateEnabled(c: ContainerDetailsDto, settings: any): boolean {
- if (isAutoUpdateLabelControlled(c)) return false;
- const excluded = settings?.autoUpdateExcludedContainers ?? '';
- const containerName = c?.name?.replace(/^\/+/, '') ?? '';
- if (containerName && excluded) {
- const excludedList = excluded.split(',').map((s: string) => s.trim());
- if (excludedList.includes(containerName)) return false;
- }
- return true;
- }
-
- const autoUpdateLabelControlled = $derived(isAutoUpdateLabelControlled(container));
+ // Auto-update: the Docker label controls the state when set (not toggleable via UI)
+ const autoUpdateLabelControlled = $derived(isAutoUpdateLabelDisabled(container?.labels));
let autoUpdateOverride = $state<boolean | null>(null);
- const autoUpdateEnabled = $derived(autoUpdateOverride ?? isAutoUpdateEnabled(container, data?.settings));
+ const autoUpdateEnabled = $derived(
+ autoUpdateOverride ??
+ !isAutoUpdateIgnored(container?.name ?? '', container?.labels, data?.settings?.autoUpdateExcludedContainers)
+ );
const cleanContainerName = (name: string | undefined): string => {
if (!name) return m.common_not_found_title({ resource: m.containers() });
diff --git a/frontend/src/routes/(app)/environments/[id]/components/JobsTab.svelte b/frontend/src/routes/(app)/environments/[id]/components/JobsTab.svelte
index 8ede6d7e9..c5de09d41 100644
--- a/frontend/src/routes/(app)/environments/[id]/components/JobsTab.svelte
+++ b/frontend/src/routes/(app)/environments/[id]/components/JobsTab.svelte
@@ -16,6 +16,7 @@
import type { JobStatus, JobPrerequisite } from '#lib/types/settings';
import type { ContainerSummaryDto } from '#lib/types/docker';
import type { JobsTabProps } from './tab-props';
+ import { isAutoUpdateLabelDisabled, normalizeContainerName, parseExcludedContainerSet } from '#lib/utils/container-auto-update';
let { formInputs, environmentId }: JobsTabProps = $props();
@@ -56,16 +57,7 @@
let searchTerm = $state('');
let autoHealSearchTerm = $state('');
- function parseExcludedContainerSet(value: string | undefined) {
- return new SvelteSet(
- (value || '')
- .split(',')
- .map((s: string) => normalizeContainerName(s.trim()))
- .filter(Boolean)
- );
- }
-
- function toggleExcludedContainerValue(current: SvelteSet<string>, containerName: string): string {
+ function toggleExcludedContainerValue(current: ReadonlySet<string>, containerName: string): string {
const normalizedName = normalizeContainerName(containerName);
const newSet = new SvelteSet(current);
if (newSet.has(normalizedName)) {
@@ -173,23 +165,9 @@
return normalizeContainerName(rawName);
}
- function normalizeContainerName(name: string): string {
- return name.replace(/^\/+/, '');
- }
-
- function isContainerLabelExcluded(container: ContainerSummaryDto): boolean {
- const labels = container.labels || {};
- for (const [k, v] of Object.entries(labels)) {
- if (k.toLowerCase() === 'com.getarcaneapp.arcane.updater') {
- return ['false', '0', 'no', 'off'].includes(v.trim().toLowerCase());
- }
- }
- return false;
- }
-
function mapContainerToItem(container: ContainerSummaryDto) {
const name = getContainerName(container);
- const labelExcluded = isContainerLabelExcluded(container);
+ const labelExcluded = isAutoUpdateLabelDisabled(container.labels);
return {
value: name,
label: name,
diff --git a/frontend/src/routes/(app)/updates/+page.svelte b/frontend/src/routes/(app)/updates/+page.svelte
index 114d95066..4accbab56 100644
--- a/frontend/src/routes/(app)/updates/+page.svelte
+++ b/frontend/src/routes/(app)/updates/+page.svelte
@@ -12,6 +12,8 @@
import { imageService } from '#lib/services/image-service';
import { containerService, type ContainerListRequestOptions } from '#lib/services/container-service';
import { projectService } from '#lib/services/project-service';
+ import { settingsService } from '#lib/services/settings-service';
+ import { confirmAndApplyAllUpdates } from '#lib/utils/update-actions';
import type { ContainersPaginatedResponse } from '#lib/services/container-service';
import type { ImageUpdateInfoDto } from '#lib/types/docker';
import type { Paginated, SearchPaginationSortRequest } from '#lib/types/shared';
@@ -97,6 +99,15 @@
return Array.from(refs).sort();
});
+ const settingsQuery = createQuery(() => ({
+ queryKey: queryKeys.settings.byEnvironment(envId),
+ queryFn: () => settingsService.getSettingsForEnvironmentMerged(envId),
+ initialData: envId === data.envId ? data.settings : undefined,
+ refetchOnMount: false
+ }));
+
+ const excludedContainers = $derived(settingsQuery.data?.autoUpdateExcludedContainers ?? '');
+
const projectUpdateDetailsQuery = createQuery<Record<string, ImageUpdateInfoDto>>(() => ({
queryKey: ['updates', 'projects', 'details', envId, projectUpdatedImageRefs],
queryFn: () =>
@@ -160,6 +171,17 @@
}
}
+ // The run is synchronous server-side (bounded by the updater apply timeout),
+ // so the button holds its spinner while the Activity Center streams progress.
+ let isUpdatingAll = $state(false);
+
+ function updateAll() {
+ confirmAndApplyAllUpdates({
+ setLoading: (loading) => (isUpdatingAll = loading),
+ onRefresh: refresh
+ });
+ }
+
function handleTabChange(value: string) {
urlTab.select(value);
}
@@ -174,6 +196,15 @@
loading: isChecking,
disabled: isChecking
},
+ {
+ id: 'update-all',
+ action: 'update',
+ label: m.update_all(),
+ loadingLabel: m.common_action_updating(),
+ onclick: updateAll,
+ loading: isUpdatingAll,
+ disabled: isUpdatingAll || totalAffectedResources === 0
+ },
{
id: 'refresh',
action: 'restart',
@@ -216,7 +247,9 @@
{#key `${envId}-containers`}
<ContainerUpdatesTable
{containers}
+ {excludedContainers}
bind:requestOptions={containerRequestOptions}
+ onIgnoreChanged={() => settingsQuery.refetch()}
onRefreshData={async (options) => {
containerRequestOptions = ensureStandaloneContainerUpdatesFilter(options);
const next = await containerService.getContainersForEnvironment(envId, containerRequestOptions);
diff --git a/frontend/src/routes/(app)/updates/+page.ts b/frontend/src/routes/(app)/updates/+page.ts
index e4c8f7054..40c7225a3 100644
--- a/frontend/src/routes/(app)/updates/+page.ts
+++ b/frontend/src/routes/(app)/updates/+page.ts
@@ -1,5 +1,6 @@
import { containerService, type ContainerListRequestOptions } from '#lib/services/container-service';
import { projectService } from '#lib/services/project-service';
+import { settingsService } from '#lib/services/settings-service';
import { queryKeys } from '#lib/query/query-keys';
import type { SearchPaginationSortRequest } from '#lib/types/shared';
import { resolveInitialTableRequest } from '#lib/utils/tables';
@@ -28,8 +29,9 @@ export const load: PageLoad = async ({ parent }) => {
let containers;
let projects;
+ let settings;
try {
- [containers, projects] = await Promise.all([
+ [containers, projects, settings] = await Promise.all([
queryClient.fetchQuery({
queryKey: queryKeys.containers.list(envId, containerRequestOptions),
queryFn: () => containerService.getContainersForEnvironment(envId, containerRequestOptions)
@@ -37,6 +39,11 @@ export const load: PageLoad = async ({ parent }) => {
queryClient.fetchQuery({
queryKey: queryKeys.projects.list(envId, projectRequestOptions),
queryFn: () => projectService.getProjectsForEnvironment(envId, projectRequestOptions)
+ }),
+ // `autoUpdateExcludedContainers` drives the ignored state on container rows.
+ queryClient.fetchQuery({
+ queryKey: queryKeys.settings.byEnvironment(envId),
+ queryFn: () => settingsService.getSettingsForEnvironmentMerged(envId)
})
]);
} catch (err) {
@@ -47,6 +54,7 @@ export const load: PageLoad = async ({ parent }) => {
envId,
containers,
projects,
+ settings,
containerRequestOptions,
projectRequestOptions
};
diff --git a/frontend/src/routes/(app)/updates/container-updates-table.svelte b/frontend/src/routes/(app)/updates/container-updates-table.svelte
index 13953cd84..1734d232e 100644
--- a/frontend/src/routes/(app)/updates/container-updates-table.svelte
+++ b/frontend/src/routes/(app)/updates/container-updates-table.svelte
@@ -1,19 +1,33 @@
<script lang="ts">
import ArcaneTable from '#lib/components/arcane-table/arcane-table.svelte';
- import { ArcaneButton } from '#lib/components/arcane-button/index.js';
- import { UniversalMobileCard, type ColumnSpec, type MobileFieldVisibility } from '#lib/components/arcane-table';
+ import RowActionsMenu from '#lib/components/arcane-table/row-actions-menu.svelte';
+ import * as DropdownMenu from '#lib/components/ui/dropdown-menu/index.js';
+ import { Spinner } from '#lib/components/ui/spinner/index.js';
+ import {
+ UniversalMobileCard,
+ type BulkAction,
+ type ColumnSpec,
+ type MobileFieldVisibility
+ } from '#lib/components/arcane-table';
import DigestCell from '#lib/components/arcane-table/cells/digest-cell.svelte';
import CheckedAtCell from '#lib/components/arcane-table/cells/checked-at-cell.svelte';
+ import { Badge } from '#lib/components/ui/badge';
import { m } from '#lib/paraglide/messages';
import type { SearchPaginationSortRequest, Paginated } from '#lib/types/shared';
import type { ContainerSummaryDto } from '#lib/types/docker';
import type { ImageUpdateInfoDto } from '#lib/types/docker';
+ import { containerService } from '#lib/services/container-service';
import type { ContainersPaginatedResponse, ContainerListRequestOptions } from '#lib/services/container-service';
- import { ContainersIcon, UpdateIcon } from '#lib/icons';
+ import { ContainersIcon, UpdateIcon, EyeOffIcon, EyeOnIcon } from '#lib/icons';
import { getContainerDisplayName } from '../containers/container-table.helpers';
import IfPermitted from '#lib/components/if-permitted.svelte';
+ import { hasPermission } from '#lib/utils/auth';
import { confirmAndUpdateContainer } from '#lib/utils/container-actions';
+ import { isAutoUpdateIgnored, isAutoUpdateLabelDisabled } from '#lib/utils/container-auto-update';
+ import { bulkConfirmAndRun } from '#lib/utils/bulk-actions';
+ import { throwOnUpdateFailure } from '#lib/utils/update-actions';
import { formatImageUpdateCheckedAt, formatImageUpdateValue } from '#lib/utils/image-updates';
+ import { toast } from 'svelte-sonner';
type ContainerUpdateRow = {
id: string;
@@ -23,6 +37,8 @@
currentValue: string;
latestValue: string;
checkedAt: string;
+ ignored: boolean;
+ labelControlled: boolean;
updateInfo?: ImageUpdateInfoDto;
container: ContainerSummaryDto;
};
@@ -30,24 +46,38 @@
interface Props {
containers: ContainersPaginatedResponse;
requestOptions: SearchPaginationSortRequest;
+ /** `autoUpdateExcludedContainers` setting — a CSV of ignored container names. */
+ excludedContainers?: string;
onRefreshData: (options: ContainerListRequestOptions) => Promise<ContainersPaginatedResponse>;
+ onIgnoreChanged?: () => Promise<unknown> | unknown;
}
- let { containers = $bindable(), requestOptions = $bindable(), onRefreshData }: Props = $props();
+ let {
+ containers = $bindable(),
+ requestOptions = $bindable(),
+ excludedContainers,
+ onRefreshData,
+ onIgnoreChanged
+ }: Props = $props();
let selectedIds = $state<string[]>([]);
let mobileFieldVisibility = $state<MobileFieldVisibility>({});
let updatingContainerIds = $state<Record<string, boolean>>({});
+ let ignoringContainerIds = $state<Record<string, boolean>>({});
+ let bulkUpdating = $state(false);
function mapContainerRow(container: ContainerSummaryDto): ContainerUpdateRow {
+ const name = getContainerDisplayName(container);
return {
id: container.id,
containerId: container.id,
- name: getContainerDisplayName(container),
+ name,
imageRef: container.image,
currentValue: formatImageUpdateValue(container.updateInfo, 'current'),
latestValue: formatImageUpdateValue(container.updateInfo, 'latest'),
checkedAt: container.updateInfo?.checkTime ?? '',
+ ignored: isAutoUpdateIgnored(name, container.labels, excludedContainers),
+ labelControlled: isAutoUpdateLabelDisabled(container.labels),
updateInfo: container.updateInfo,
container
};
@@ -63,18 +93,20 @@
{ accessorKey: 'imageRef', title: m.common_image(), sortable: true, cell: ImageCell },
{ accessorKey: 'currentValue', title: m.common_current(), sortable: false, cell: DigestCol },
{ accessorKey: 'latestValue', title: m.image_update_latest_digest_label(), sortable: false, cell: DigestCol },
- { accessorKey: 'checkedAt', title: m.common_updated(), sortable: false, cell: CheckedAtCol },
- { id: 'actions', title: m.common_actions(), sortable: false, cell: ActionsCell }
+ { accessorKey: 'checkedAt', title: m.common_updated(), sortable: false, cell: CheckedAtCol }
] satisfies ColumnSpec<ContainerUpdateRow>[];
const mobileFields = [
{ id: 'imageRef', label: m.common_image(), defaultVisible: true },
{ id: 'currentValue', label: m.common_current(), defaultVisible: true },
{ id: 'latestValue', label: m.image_update_latest_digest_label(), defaultVisible: true },
- { id: 'checkedAt', label: m.common_updated(), defaultVisible: true },
- { id: 'actions', label: m.common_actions(), defaultVisible: true }
+ { id: 'checkedAt', label: m.common_updated(), defaultVisible: true }
];
+ async function refreshRows() {
+ containers = await onRefreshData(requestOptions as ContainerListRequestOptions);
+ }
+
async function handleUpdateContainer(container: ContainerSummaryDto) {
const containerName = getContainerDisplayName(container);
@@ -85,18 +117,78 @@
setLoading: (loading) => {
updatingContainerIds = { ...updatingContainerIds, [container.id]: loading };
},
- onRefresh: async () => {
- const next = await onRefreshData(requestOptions as ContainerListRequestOptions);
- containers = next;
- }
+ onRefresh: refreshRows
});
}
+
+ // Ignoring writes to the shared `autoUpdateExcludedContainers` setting, so the
+ // row stays listed (the list is driven by `updateInfo.hasUpdate`) and only its
+ // rendering changes once the settings query reports the new value back.
+ async function handleToggleIgnore(item: ContainerUpdateRow) {
+ const enable = item.ignored;
+ ignoringContainerIds = { ...ignoringContainerIds, [item.containerId]: true };
+ try {
+ await containerService.setAutoUpdate(item.containerId, enable);
+ toast.success(enable ? m.auto_update_enabled_toast() : m.auto_update_disabled_toast());
+ await onIgnoreChanged?.();
+ } catch (error) {
+ console.error('Auto-update toggle failed:', error);
+ toast.error(m.auto_update_failed());
+ } finally {
+ ignoringContainerIds = { ...ignoringContainerIds, [item.containerId]: false };
+ }
+ }
+
+ function handleBulkUpdate(ids: string[]) {
+ bulkConfirmAndRun({
+ ids,
+ title: m.updates_bulk_update_confirm_title({ count: ids.length }),
+ message: m.updates_bulk_update_confirm_message({ count: ids.length }),
+ confirmLabel: m.common_update(),
+ run: (id) => containerService.updateContainer(id).then(throwOnUpdateFailure),
+ messages: {
+ success: (count) => m.updates_bulk_update_success({ count }),
+ partial: (success, total, failed) => m.updates_bulk_update_partial({ success, total, failed }),
+ failure: () => m.updates_bulk_update_failed()
+ },
+ setLoading: (loading) => (bulkUpdating = loading),
+ onComplete: refreshRows,
+ clearSelection: () => (selectedIds = [])
+ });
+ }
+
+ const bulkActions = $derived<BulkAction[]>(
+ hasPermission('containers:autoupdate')
+ ? [
+ {
+ id: 'update',
+ label: m.updates_bulk_update({ count: selectedIds.length }),
+ action: 'update',
+ onClick: handleBulkUpdate,
+ loading: bulkUpdating,
+ disabled: bulkUpdating,
+ icon: UpdateIcon
+ }
+ ]
+ : []
+ );
</script>
{#snippet NameCell({ item }: { item: ContainerUpdateRow })}
- <a class="font-medium hover:underline" href={`/containers/${item.containerId}`}>
- {item.name}
- </a>
+ <div class="flex items-center gap-2">
+ <a class="font-medium hover:underline {item.ignored ? 'text-muted-foreground' : ''}" href={`/containers/${item.containerId}`}>
+ {item.name}
+ </a>
+ {#if item.ignored}
+ <Badge
+ variant="outline"
+ class="text-muted-foreground"
+ title={item.labelControlled ? m.auto_update_controlled_by_label() : undefined}
+ >
+ {m.common_ignored()}
+ </Badge>
+ {/if}
+ </div>
{/snippet}
{#snippet ImageCell({ item }: { item: ContainerUpdateRow })}
@@ -112,17 +204,36 @@
<CheckedAtCell {value} />
{/snippet}
-{#snippet ActionsCell({ item }: { item: ContainerUpdateRow })}
+{#snippet RowActions({ item }: { item: ContainerUpdateRow })}
<IfPermitted perm="containers:autoupdate">
- <ArcaneButton
- action="update"
- size="sm"
- customLabel={m.update_container()}
- onclick={() => handleUpdateContainer(item.container)}
- loading={!!updatingContainerIds[item.containerId]}
- disabled={!!updatingContainerIds[item.containerId]}
- icon={UpdateIcon}
- />
+ <RowActionsMenu>
+ <DropdownMenu.Item
+ onclick={() => handleUpdateContainer(item.container)}
+ disabled={!!updatingContainerIds[item.containerId]}
+ >
+ {#if updatingContainerIds[item.containerId]}
+ <Spinner class="size-4" />
+ {:else}
+ <UpdateIcon class="size-4" />
+ {/if}
+ {m.update_container()}
+ </DropdownMenu.Item>
+
+ <DropdownMenu.Item
+ onclick={() => handleToggleIgnore(item)}
+ disabled={item.labelControlled || !!ignoringContainerIds[item.containerId]}
+ title={item.labelControlled ? m.auto_update_controlled_by_label() : m.updates_ignore_description()}
+ >
+ {#if ignoringContainerIds[item.containerId]}
+ <Spinner class="size-4" />
+ {:else if item.ignored}
+ <EyeOnIcon class="size-4" />
+ {:else}
+ <EyeOffIcon class="size-4" />
+ {/if}
+ {item.ignored ? m.common_unignore() : m.common_ignore()}
+ </DropdownMenu.Item>
+ </RowActionsMenu>
</IfPermitted>
{/snippet}
@@ -135,6 +246,7 @@
})}
title={(item: ContainerUpdateRow) => item.name}
subtitle={(item: ContainerUpdateRow) => item.imageRef}
+ badges={[(item: ContainerUpdateRow) => (item.ignored ? { variant: 'gray' as const, text: m.common_ignored() } : null)]}
fields={[
{
label: m.common_current(),
@@ -147,12 +259,9 @@
{
label: m.common_updated(),
getValue: (item: ContainerUpdateRow) => formatImageUpdateCheckedAt(item.checkedAt)
- },
- {
- label: m.common_actions(),
- getValue: () => m.update_container()
}
]}
+ rowActions={RowActions}
onclick={(item: ContainerUpdateRow) => {
window.location.href = `/containers/${item.containerId}`;
}}
@@ -176,7 +285,8 @@
}}
{columns}
{mobileFields}
+ {bulkActions}
+ rowActions={RowActions}
mobileCard={ContainerUpdatesMobileCard}
withoutFilters
- selectionDisabled
/>
diff --git a/frontend/src/routes/(app)/updates/project-updates-table.svelte b/frontend/src/routes/(app)/updates/project-updates-table.svelte
index d2bc901f0..5e6549c53 100644
--- a/frontend/src/routes/(app)/updates/project-updates-table.svelte
+++ b/frontend/src/routes/(app)/updates/project-updates-table.svelte
@@ -1,13 +1,25 @@
<script lang="ts">
import ArcaneTable from '#lib/components/arcane-table/arcane-table.svelte';
- import { UniversalMobileCard, type ColumnSpec, type MobileFieldVisibility } from '#lib/components/arcane-table';
+ import RowActionsMenu from '#lib/components/arcane-table/row-actions-menu.svelte';
+ import * as DropdownMenu from '#lib/components/ui/dropdown-menu/index.js';
+ import { Spinner } from '#lib/components/ui/spinner/index.js';
+ import {
+ UniversalMobileCard,
+ type BulkAction,
+ type ColumnSpec,
+ type MobileFieldVisibility
+ } from '#lib/components/arcane-table';
import DigestCell from '#lib/components/arcane-table/cells/digest-cell.svelte';
import CheckedAtCell from '#lib/components/arcane-table/cells/checked-at-cell.svelte';
+ import IfPermitted from '#lib/components/if-permitted.svelte';
import { m } from '#lib/paraglide/messages';
import type { Paginated, SearchPaginationSortRequest } from '#lib/types/shared';
import type { Project } from '#lib/types/swarm';
import type { ImageUpdateInfoDto } from '#lib/types/docker';
- import { ProjectsIcon, ImagesIcon } from '#lib/icons';
+ import { ProjectsIcon, ImagesIcon, UpdateIcon } from '#lib/icons';
+ import { hasPermission } from '#lib/utils/auth';
+ import { bulkConfirmAndRun, confirmAndRun } from '#lib/utils/bulk-actions';
+ import { applyScopedUpdate, summarizeUpdateResult, throwOnUpdateFailure } from '#lib/utils/update-actions';
import { formatImageUpdateCheckedAt, formatImageUpdateValue } from '#lib/utils/image-updates';
type ProjectUpdateRow = {
@@ -32,6 +44,8 @@
let selectedIds = $state<string[]>([]);
let mobileFieldVisibility = $state<MobileFieldVisibility>({});
+ let updatingProjectIds = $state<Record<string, boolean>>({});
+ let bulkUpdating = $state(false);
function summarizeImageRefs(imageRefs: string[]): string {
if (imageRefs.length === 0) return '-';
@@ -95,6 +109,59 @@
{ id: 'latestValue', label: m.image_update_latest_digest_label(), defaultVisible: true },
{ id: 'checkedAt', label: m.common_updated(), defaultVisible: true }
];
+
+ // A scoped updater run only touches the services whose images actually
+ // changed, unlike a full project redeploy.
+ function handleUpdateProject(item: ProjectUpdateRow) {
+ confirmAndRun({
+ title: m.common_update(),
+ message: m.updates_update_confirm_message({ name: item.name }),
+ confirmLabel: m.common_update(),
+ setLoading: (loading) => {
+ updatingProjectIds = { ...updatingProjectIds, [item.projectId]: loading };
+ },
+ run: () => applyScopedUpdate('project', item.projectId),
+ failureMessage: m.updates_apply_all_failed(),
+ onSuccess: async (result) => {
+ summarizeUpdateResult(result);
+ await onRefreshData(requestOptions);
+ }
+ });
+ }
+
+ function handleBulkUpdate(ids: string[]) {
+ bulkConfirmAndRun({
+ ids,
+ title: m.updates_bulk_update_confirm_title({ count: ids.length }),
+ message: m.updates_bulk_update_confirm_message({ count: ids.length }),
+ confirmLabel: m.common_update(),
+ run: (id) => applyScopedUpdate('project', id).then(throwOnUpdateFailure),
+ messages: {
+ success: (count) => m.updates_bulk_update_success({ count }),
+ partial: (success, total, failed) => m.updates_bulk_update_partial({ success, total, failed }),
+ failure: () => m.updates_bulk_update_failed()
+ },
+ setLoading: (loading) => (bulkUpdating = loading),
+ onComplete: () => onRefreshData(requestOptions),
+ clearSelection: () => (selectedIds = [])
+ });
+ }
+
+ const bulkActions = $derived<BulkAction[]>(
+ hasPermission('image-updates:check')
+ ? [
+ {
+ id: 'update',
+ label: m.updates_bulk_update({ count: selectedIds.length }),
+ action: 'update',
+ onClick: handleBulkUpdate,
+ loading: bulkUpdating,
+ disabled: bulkUpdating,
+ icon: UpdateIcon
+ }
+ ]
+ : []
+ );
</script>
{#snippet NameCell({ item }: { item: ProjectUpdateRow })}
@@ -124,6 +191,21 @@
<CheckedAtCell {value} />
{/snippet}
+{#snippet RowActions({ item }: { item: ProjectUpdateRow })}
+ <IfPermitted perm="image-updates:check">
+ <RowActionsMenu>
+ <DropdownMenu.Item onclick={() => handleUpdateProject(item)} disabled={!!updatingProjectIds[item.projectId]}>
+ {#if updatingProjectIds[item.projectId]}
+ <Spinner class="size-4" />
+ {:else}
+ <UpdateIcon class="size-4" />
+ {/if}
+ {m.common_update()}
+ </DropdownMenu.Item>
+ </RowActionsMenu>
+ </IfPermitted>
+{/snippet}
+
{#snippet ProjectUpdatesMobileCard({ item }: { item: ProjectUpdateRow })}
<UniversalMobileCard
{item}
@@ -147,6 +229,7 @@
getValue: (item: ProjectUpdateRow) => formatImageUpdateCheckedAt(item.checkedAt)
}
]}
+ rowActions={RowActions}
onclick={(item: ProjectUpdateRow) => {
if (item.project.isDiscovered) return;
window.location.href = `/projects/${item.projectId}`;
@@ -170,7 +253,8 @@
}}
{columns}
{mobileFields}
+ {bulkActions}
+ rowActions={RowActions}
mobileCard={ProjectUpdatesMobileCard}
withoutFilters
- selectionDisabled
/>
diff --git a/tests/spec/updates.spec.ts b/tests/spec/updates.spec.ts
new file mode 100644
index 000000000..a4fd7929a
--- /dev/null
+++ b/tests/spec/updates.spec.ts
@@ -0,0 +1,124 @@
+import { test, expect, type Page } from '@playwright/test';
+
+const UPDATES_ROUTE = '/updates';
+
+const CONTAINERS = [
+ { id: 'update-row-a', name: 'updates-alpha', image: 'ghcr.io/example/alpha:1.0' },
+ { id: 'update-row-b', name: 'updates-beta', image: 'ghcr.io/example/beta:1.0' }
+];
+
+function containerWithUpdate(container: (typeof CONTAINERS)[number]) {
+ return {
+ id: container.id,
+ names: [`/${container.name}`],
+ image: container.image,
+ imageId: `sha256:${container.id}`,
+ command: 'sleep',
+ created: 1_700_000_000,
+ labels: {},
+ state: 'running',
+ status: 'Up 2 hours',
+ ports: [],
+ hostConfig: { networkMode: 'bridge' },
+ networkSettings: { networks: {} },
+ mounts: [],
+ updateInfo: {
+ hasUpdate: true,
+ updateType: 'digest',
+ currentVersion: '1.0',
+ latestVersion: '1.0',
+ currentDigest: 'sha256:aaa',
+ latestDigest: 'sha256:bbb',
+ checkTime: new Date().toISOString(),
+ responseTimeMs: 12
+ }
+ };
+}
+
+/** Serves the two update-pending containers so the tab always has selectable rows. */
+async function stubContainersWithUpdates(page: Page) {
+ await page.route(/\/api\/environments\/0\/containers(?:\?.*)?$/, async (route) => {
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({
+ success: true,
+ data: CONTAINERS.map(containerWithUpdate),
+ pagination: {
+ totalItems: CONTAINERS.length,
+ totalPages: 1,
+ currentPage: 1,
+ itemsPerPage: 100
+ }
+ })
+ });
+ });
+}
+
+test.describe('Updates Page Actions', () => {
+ test('applies updates to the selected container rows', async ({ page }) => {
+ await stubContainersWithUpdates(page);
+
+ const updated: string[] = [];
+ await page.route(/\/api\/environments\/0\/containers\/[^/]+\/update$/, async (route) => {
+ updated.push(new URL(route.request().url()).pathname.split('/').at(-2)!);
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({ success: true, data: { updated: 1, failed: 0, items: [] } })
+ });
+ });
+
+ await page.goto(UPDATES_ROUTE);
+ await page.waitForLoadState('load');
+
+ for (const container of CONTAINERS) {
+ await page
+ .getByRole('row')
+ .filter({ hasText: container.name })
+ .getByRole('checkbox', { name: 'Select row' })
+ .check();
+ }
+
+ await page.getByRole('button', { name: 'Update (2)', exact: true }).click();
+
+ const dialog = page.getByRole('dialog');
+ await expect(dialog).toBeVisible();
+ await dialog.getByRole('button', { name: 'Update', exact: true }).click();
+
+ await expect(page.getByText('Updated 2 resource(s)')).toBeVisible({ timeout: 15_000 });
+ expect(updated.sort()).toEqual(CONTAINERS.map((c) => c.id).sort());
+ });
+
+ test('Update All confirms before dispatching a host-wide updater run', async ({ page }) => {
+ await stubContainersWithUpdates(page);
+
+ let runs = 0;
+ await page.route(/\/api\/environments\/0\/updater\/run$/, async (route) => {
+ runs++;
+ await route.fulfill({
+ status: 200,
+ contentType: 'application/json',
+ body: JSON.stringify({
+ success: true,
+ data: { checked: 2, updated: 2, skipped: 0, failed: 0, items: [], duration: '2s' }
+ })
+ });
+ });
+
+ await page.goto(UPDATES_ROUTE);
+ await page.waitForLoadState('load');
+
+ await page.getByRole('button', { name: 'Update All', exact: true }).click();
+
+ const dialog = page.getByRole('dialog');
+ await expect(dialog).toBeVisible();
+ await expect(dialog.getByText(/every pending update on this host/i)).toBeVisible();
+ expect(runs).toBe(0);
+
+ await dialog.getByRole('button', { name: 'Update All', exact: true }).click();
+
+ await expect(page.getByText('Applied 2 update(s)')).toBeVisible({ timeout: 15_000 });
+ expect(runs).toBe(1);
+ });
+});