Skip to content

Modern Docker Management, Designed for Everyone

feat: allow bulk updates for selected containers (#3971)

Mike Wajda0365c6861d50
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index 34b53a823..6854451af 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -637,6 +637,13 @@
"containers_bulk_restart_partial": "Restarted {success} of {total} container(s). {failed} failed.",
"containers_bulk_remove_success": "Successfully removed {count} container(s)",
"containers_bulk_remove_partial": "Removed {success} of {total} container(s). {failed} failed.",
+ "containers_bulk_update": "Update ({count})",
+ "containers_bulk_update_confirm_title": "Update {count} Container(s)",
+ "containers_bulk_update_confirm_message": "Are you sure you want to update {count} container(s)?",
+ "containers_bulk_update_filtered_confirm_message": "Only {filteredCount} out of {totalCount} containers are eligible for updates. Are you sure you want to update {filteredCount} container(s)?",
+ "containers_bulk_update_success": "Successfully updated {count} container(s)",
+ "containers_bulk_update_partial": "Updated {success} of {total} container(s). {failed} failed.",
+ "containers_bulk_update_failed": "Failed to update containers",
"containers_group_by_project": "Group by Project",
"containers_nav_metrics": "Metrics",
"storage": "Storage",
diff --git a/frontend/src/routes/(app)/containers/container-table.actions.ts b/frontend/src/routes/(app)/containers/container-table.actions.ts
index 5eab565e6..9a81e9a20 100644
--- a/frontend/src/routes/(app)/containers/container-table.actions.ts
+++ b/frontend/src/routes/(app)/containers/container-table.actions.ts
@@ -15,12 +15,14 @@ import {
import type { TableActionConfig, TableBulkActionConfig } from '#lib/utils/table-action-types.js';
import { toast } from 'svelte-sonner';
import { getContainerDisplayName, type ActionStatus } from './container-table.helpers';
+import { throwOnUpdateFailure } from '#lib/utils/update-actions.ts';
type BulkLoadingState = {
start: boolean;
stop: boolean;
restart: boolean;
remove: boolean;
+ update: boolean;
};
type ActionDeps = {
@@ -211,6 +213,34 @@ export function createContainerActions({
});
}
+ function handleBulkUpdate(validIds: string[], allIds: string[]) {
+ const totalCount = allIds.length;
+ const filteredCount = validIds.length;
+ const message =
+ validIds?.length < allIds?.length
+ ? m.containers_bulk_update_filtered_confirm_message({ filteredCount, totalCount })
+ : m.containers_bulk_update_confirm_message({ count: filteredCount });
+
+ bulkConfirmAndRun({
+ ids: validIds,
+ title: m.containers_bulk_update_confirm_title({ count: filteredCount }),
+ message,
+ confirmLabel: m.common_update(),
+ destructive: false,
+ run: (id) => containerService.updateContainer(id).then(throwOnUpdateFailure),
+ messages: {
+ success: (count) => m.containers_bulk_update_success({ count }),
+ partial: (success, total, failed) => m.containers_bulk_update_partial({ success, total, failed }),
+ failure: () => m.containers_bulk_update_failed()
+ },
+ setLoading: (loading) => {
+ isBulkLoading['update'] = loading;
+ },
+ onComplete: () => reloadContainers(),
+ clearSelection: () => setSelectedIds([])
+ });
+ }
+
function handleBulkRemove(ids: string[]) {
bulkConfirmAndRun({
ids,
@@ -245,6 +275,7 @@ export function createContainerActions({
handleBulkStart,
handleBulkStop,
handleBulkRestart,
- handleBulkRemove
+ handleBulkRemove,
+ handleBulkUpdate
};
}
diff --git a/frontend/src/routes/(app)/containers/container-table.svelte b/frontend/src/routes/(app)/containers/container-table.svelte
index e04f72e1c..4c792b539 100644
--- a/frontend/src/routes/(app)/containers/container-table.svelte
+++ b/frontend/src/routes/(app)/containers/container-table.svelte
@@ -91,7 +91,8 @@
start: false,
stop: false,
restart: false,
- remove: false
+ remove: false,
+ update: false
});
const statsManager = new ContainerStatsManager();
@@ -147,7 +148,8 @@
handleBulkStart,
handleBulkStop,
handleBulkRestart,
- handleBulkRemove
+ handleBulkRemove,
+ handleBulkUpdate
} = createContainerActions({
setContainers: (next) => {
containers = next;
@@ -163,7 +165,9 @@
const isAnyLoading = $derived(hasAnyLoadingState(actionStatus, isBulkLoading));
let mobileFieldVisibility = $state<Record<string, boolean>>({});
- let tablePreferences = $state<{ persistCustomSettings(settings: Record<string, unknown>): void }>();
+ let tablePreferences = $state<{
+ persistCustomSettings(settings: Record<string, unknown>): void;
+ }>();
let customSettings = $state<Record<string, unknown>>({});
let showInternal = $derived.by(() => {
return (customSettings['showInternalContainers'] as boolean) ?? false;
@@ -220,6 +224,23 @@
goto(`/projects/new?fromContainers=${convertibleIds.join(',')}&fromEnv=${encodeURIComponent(currentEnvId)}`);
}
+ function filterUpdatableContainerIds() {
+ return selectedIds?.filter((id) => {
+ const container = containers.data?.find((c) => c.id === id);
+ return container?.updateInfo?.hasUpdate;
+ });
+ }
+
+ function handleSelectedBulkUpdate(ids: string[]) {
+ const validUpdateIds = filterUpdatableContainerIds();
+
+ if (!validUpdateIds?.length) {
+ return;
+ }
+
+ handleBulkUpdate(validUpdateIds, ids);
+ }
+
// The dialog is mounted only while a row is targeted, so it gets fresh state on
// every open; clearing the target unmounts it.
let killTarget = $state<ContainerSummaryDto | null>(null);
@@ -278,9 +299,25 @@
const columns = $derived([
{ accessorKey: 'id', title: m.common_id(), cell: IdCell, hidden: true },
- { accessorKey: 'names', id: 'name', title: m.common_name(), sortable: !groupByProject, cell: NameCell },
- { accessorKey: 'image', title: m.common_image(), sortable: !groupByProject, cell: ImageCell },
- { accessorKey: 'state', title: m.common_state(), sortable: !groupByProject, cell: StateCell },
+ {
+ accessorKey: 'names',
+ id: 'name',
+ title: m.common_name(),
+ sortable: !groupByProject,
+ cell: NameCell
+ },
+ {
+ accessorKey: 'image',
+ title: m.common_image(),
+ sortable: !groupByProject,
+ cell: ImageCell
+ },
+ {
+ accessorKey: 'state',
+ title: m.common_state(),
+ sortable: !groupByProject,
+ cell: StateCell
+ },
{
id: 'updates',
accessorFn: (row) => {
@@ -308,10 +345,31 @@
cell: MemoryCell
},
{ accessorKey: 'status', title: m.common_status() },
- { accessorKey: 'networkSettings', id: 'ipAddress', title: m.containers_ip_address(), sortable: false, cell: IPAddressCell },
- { accessorKey: 'ports', title: m.common_ports(), sortable: !groupByProject, cell: PortsCell },
- { accessorKey: 'created', title: m.common_created(), sortable: !groupByProject, cell: CreatedCell },
- { id: 'label', accessorFn: (row) => Object.keys(row.labels ?? {}).length, title: m.common_labels(), hidden: true }
+ {
+ accessorKey: 'networkSettings',
+ id: 'ipAddress',
+ title: m.containers_ip_address(),
+ sortable: false,
+ cell: IPAddressCell
+ },
+ {
+ accessorKey: 'ports',
+ title: m.common_ports(),
+ sortable: !groupByProject,
+ cell: PortsCell
+ },
+ {
+ accessorKey: 'created',
+ title: m.common_created(),
+ sortable: !groupByProject,
+ cell: CreatedCell
+ },
+ {
+ id: 'label',
+ accessorFn: (row) => Object.keys(row.labels ?? {}).length,
+ title: m.common_labels(),
+ hidden: true
+ }
] satisfies ColumnSpec<ContainerSummaryDto>[]);
const mobileFields = [
@@ -322,7 +380,11 @@
{ id: 'memoryUsage', label: m.memory_usage(), defaultVisible: false },
{ id: 'status', label: m.common_status(), defaultVisible: true },
{ id: 'image', label: m.common_image(), defaultVisible: true },
- { id: 'ipAddress', label: m.containers_ip_address(), defaultVisible: false },
+ {
+ id: 'ipAddress',
+ label: m.containers_ip_address(),
+ defaultVisible: false
+ },
{ id: 'ports', label: m.common_ports(), defaultVisible: true },
{ id: 'created', label: m.common_created(), defaultVisible: true }
];
@@ -332,7 +394,9 @@
? [
{
id: 'start',
- label: m.containers_bulk_start({ count: selectedIds?.length ?? 0 }),
+ label: m.containers_bulk_start({
+ count: selectedIds?.length ?? 0
+ }),
action: 'start' as const,
onClick: handleBulkStart,
loading: isBulkLoading.start,
@@ -341,11 +405,28 @@
}
]
: []),
+ ...(canUpdateContainers && filterUpdatableContainerIds()?.length > 0
+ ? [
+ {
+ id: 'update',
+ label: m.containers_bulk_update({
+ count: filterUpdatableContainerIds()?.length ?? 0
+ }),
+ action: 'update' as const,
+ onClick: handleSelectedBulkUpdate,
+ loading: isBulkLoading.update,
+ disabled: !resourcesCurrent || isAnyLoading,
+ icon: UpdateIcon
+ }
+ ]
+ : []),
...(canStopContainers
? [
{
id: 'stop',
- label: m.containers_bulk_stop({ count: selectedIds?.length ?? 0 }),
+ label: m.containers_bulk_stop({
+ count: selectedIds?.length ?? 0
+ }),
action: 'stop' as const,
onClick: handleBulkStop,
loading: isBulkLoading.stop,
@@ -358,7 +439,9 @@
? [
{
id: 'restart',
- label: m.containers_bulk_restart({ count: selectedIds?.length ?? 0 }),
+ label: m.containers_bulk_restart({
+ count: selectedIds?.length ?? 0
+ }),
action: 'restart' as const,
onClick: handleBulkRestart,
loading: isBulkLoading.restart,
@@ -371,7 +454,9 @@
? [
{
id: 'remove',
- label: m.containers_bulk_remove({ count: selectedIds?.length ?? 0 }),
+ label: m.containers_bulk_remove({
+ count: selectedIds?.length ?? 0
+ }),
action: 'remove' as const,
onClick: handleBulkRemove,
loading: isBulkLoading.remove,
@@ -384,7 +469,9 @@
? [
{
id: 'convert',
- label: m.containers_bulk_convert({ count: selectedIds?.length ?? 0 }),
+ label: m.containers_bulk_convert({
+ count: selectedIds?.length ?? 0
+ }),
action: 'base' as const,
onClick: handleBulkConvert,
disabled: !resourcesCurrent || isAnyLoading,