Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: show project-scoped versions instead of image digests (#4127)
Kyle Mendellddead64b8b96
diff --git a/frontend/src/lib/utils/image-updates.ts b/frontend/src/lib/utils/image-updates.tsindex ba544d43c..d822230b9 100644--- a/frontend/src/lib/utils/image-updates.ts+++ b/frontend/src/lib/utils/image-updates.ts@@ -4,13 +4,15 @@ import { formatDateTimeShort } from '#lib/utils/formatting.js';export function formatImageUpdateValue(updateInfo: ImageUpdateInfoDto | undefined, mode: 'current' | 'latest') {if (!updateInfo) return '-';- const digest = mode === 'current' ? updateInfo.currentDigest : updateInfo.latestDigest;- if (digest?.trim()) return digest.trim();+ const version = (mode === 'current' ? updateInfo.currentVersion : updateInfo.latestVersion)?.trim() ?? '';+ const digest = (mode === 'current' ? updateInfo.currentDigest : updateInfo.latestDigest)?.trim() ?? '';- const version = mode === 'current' ? updateInfo.currentVersion : updateInfo.latestVersion;- if (version?.trim()) return version.trim();-- return '-';+ // A tag update is about the version that moved: the digest of the configured+ // tag can be unchanged, so showing it would hide the actual change.+ if (updateInfo.updateType === 'tag') {+ return version || digest || '-';+ }+ return digest || version || '-';}export function formatImageUpdateCheckedAt(value: string) {diff --git a/frontend/src/routes/(app)/updates/+page.svelte b/frontend/src/routes/(app)/updates/+page.svelteindex d5c7434de..3a2011bda 100644--- a/frontend/src/routes/(app)/updates/+page.svelte+++ b/frontend/src/routes/(app)/updates/+page.svelte@@ -15,7 +15,6 @@import { settingsService } from '#lib/services/settings-service.js';import { confirmAndApplyAllUpdates } from '#lib/utils/update-actions.js';import type { ContainersPaginatedResponse } from '#lib/services/container-service.js';- import type { ImageUpdateInfoDto } from '#lib/types/docker.js';import type { Paginated, SearchPaginationSortRequest } from '#lib/types/shared.js';import type { Project } from '#lib/types/swarm.js';import { ContainersIcon, ProjectsIcon, UpdateIcon } from '#lib/icons/index.js';@@ -91,16 +90,6 @@(envId === data.envId ? initialProjects : emptyProjects));- const projectUpdatedImageRefs = $derived.by(() => {- const refs = new Set<string>();- for (const project of projects.data ?? []) {- for (const imageRef of project.updateInfo?.updatedImageRefs ?? []) {- refs.add(imageRef);- }- }- return Array.from(refs).sort();- });-const settingsQuery = createQuery(() => ({queryKey: queryKeys.settings.byEnvironment(envId),queryFn: () => settingsService.getSettingsForEnvironmentMerged(envId),@@ -110,25 +99,12 @@const excludedContainers = $derived(settingsQuery.data?.autoUpdateExcludedContainers ?? '');- const projectUpdateDetailsQuery = createQuery<Record<string, ImageUpdateInfoDto>>(() => {- const environmentId = envId;- const imageRefs = projectUpdatedImageRefs;- return {- queryKey: ['updates', 'projects', 'details', environmentId, imageRefs],- queryFn: () => imageService.getUpdateInfoByRefs(imageRefs),- enabled: imageRefs.length > 0- };- });-const checkUpdatesMutation = createMutation(() => ({mutationKey: ['updates', 'check-all', envId],mutationFn: () => imageService.checkAllImages(),onSuccess: async () => {toast.success(m.images_update_check_completed());await Promise.all([containersQuery.refetch(), projectsQuery.refetch()]);- if (projectUpdatedImageRefs.length > 0) {- await projectUpdateDetailsQuery.refetch();- }},onError: () => {toast.error(m.images_update_check_failed());@@ -169,9 +145,6 @@containerSnapshot = null;projectSnapshot = null;await Promise.all([containersQuery.refetch(), projectsQuery.refetch()]);- if (projectUpdatedImageRefs.length > 0) {- await projectUpdateDetailsQuery.refetch();- }}// The run is synchronous server-side (bounded by the updater apply timeout),@@ -268,7 +241,6 @@<ProjectUpdatesTable{projects}bind:requestOptions={projectRequestOptions}- updateInfoByRef={projectUpdateDetailsQuery.data}onRefreshData={async (options) => {projectRequestOptions = ensureUpdatesFilter(options);projectSnapshot = {diff --git a/frontend/src/routes/(app)/updates/container-updates-table.svelte b/frontend/src/routes/(app)/updates/container-updates-table.svelteindex b9d76ade8..c2ff7a947 100644--- a/frontend/src/routes/(app)/updates/container-updates-table.svelte+++ b/frontend/src/routes/(app)/updates/container-updates-table.svelte@@ -94,14 +94,14 @@{ accessorKey: 'name', title: m.common_name(), sortable: true, cell: NameCell },{ accessorKey: 'imageRef', title: m.common_image(), sortable: true, cell: ImageCell },{ accessorKey: 'currentValue', title: m.common_current(), sortable: false, cellComponent: DigestCell },- { accessorKey: 'latestValue', title: m.image_update_latest_digest_label(), sortable: false, cellComponent: DigestCell },+ { accessorKey: 'latestValue', title: m.image_update_latest_label(), sortable: false, cellComponent: DigestCell },{ accessorKey: 'checkedAt', title: m.common_updated(), sortable: false, cellComponent: CheckedAtCell }] 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: 'latestValue', label: m.image_update_latest_label(), defaultVisible: true },{ id: 'checkedAt', label: m.common_updated(), defaultVisible: true }];@@ -254,7 +254,7 @@getValue: (item: ContainerUpdateRow) => item.currentValue},{- label: m.image_update_latest_digest_label(),+ label: m.image_update_latest_label(),getValue: (item: ContainerUpdateRow) => item.latestValue},{diff --git a/frontend/src/routes/(app)/updates/project-updates-table.svelte b/frontend/src/routes/(app)/updates/project-updates-table.svelteindex 60e7f572f..2cea72817 100644--- a/frontend/src/routes/(app)/updates/project-updates-table.svelte+++ b/frontend/src/routes/(app)/updates/project-updates-table.svelte@@ -15,7 +15,6 @@import { m } from '#lib/paraglide/messages.js';import type { Paginated, SearchPaginationSortRequest } from '#lib/types/shared.js';import type { Project } from '#lib/types/swarm.js';- import type { ImageUpdateInfoDto } from '#lib/types/docker.js';import { ProjectsIcon, ImagesIcon, UpdateIcon } from '#lib/icons/index.js';import { hasPermission } from '#lib/utils/auth.js';import { bulkConfirmAndRun, confirmAndRun } from '#lib/utils/bulk-actions.js';@@ -36,56 +35,55 @@interface Props {projects: Paginated<Project>;requestOptions: SearchPaginationSortRequest;- updateInfoByRef?: Record<string, ImageUpdateInfoDto>;onRefreshData: (options: SearchPaginationSortRequest) => Promise<void>;}- let { projects = $bindable(), requestOptions = $bindable(), updateInfoByRef = {}, onRefreshData }: Props = $props();+ let { projects = $bindable(), requestOptions = $bindable(), onRefreshData }: Props = $props();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 '-';- if (imageRefs.length === 1) return imageRefs[0] ?? '-';- return `${imageRefs[0] ?? ''} +${imageRefs.length - 1} more`;- }-- function resolveProjectValue(project: Project, mode: 'current' | 'latest') {- const updatedRefs = project.updateInfo?.updatedImageRefs ?? [];- if (updatedRefs.length === 0) return '-';- if (updatedRefs.length > 1) {- return m.images_has_updates();+ function mapProjectRow(project: Project): ProjectUpdateRow {+ const updateInfo = project.updateInfo;+ const updatedRefs = updateInfo?.updatedImageRefs ?? [];+ const summaryRefs = updatedRefs.length > 0 ? updatedRefs : (updateInfo?.imageRefs ?? []);+ const firstRef = summaryRefs[0] ?? '';++ let imageSummary = '-';+ if (summaryRefs.length === 1) {+ imageSummary = firstRef;+ } else if (summaryRefs.length > 1) {+ imageSummary = `${firstRef} +${summaryRefs.length - 1} more`;}- const firstRef = updatedRefs[0];- const info = firstRef ? updateInfoByRef[firstRef] : undefined;- if (!info) return '-';-- return formatImageUpdateValue(info, mode);- }-- function resolveCheckedAt(project: Project) {- const updatedRefs = project.updateInfo?.updatedImageRefs ?? [];- if (updatedRefs.length === 1) {- const firstRef = updatedRefs[0];- return (firstRef ? updateInfoByRef[firstRef]?.checkTime : undefined) ?? project.updateInfo?.lastCheckedAt ?? '';+ // The list response already carries the per-reference result that raised the+ // notification, with the project's update policy applied, so the row must read+ // that record rather than the image-level check for the same reference.+ const info = updatedRefs.length === 1 ? updateInfo?.updateInfoByRef?.[firstRef] : undefined;+ // The backend blanks the target when services sharing a reference disagree, so+ // fall back to the multi-update summary instead of picking one arbitrarily.+ const hasSingleTarget = !!info && (!!info.latestVersion?.trim() || !!info.latestDigest?.trim());++ let currentValue = '-';+ let latestValue = '-';+ if (updatedRefs.length > 1 || (info && !hasSingleTarget)) {+ currentValue = m.images_has_updates();+ latestValue = m.images_has_updates();+ } else if (info) {+ currentValue = formatImageUpdateValue(info, 'current');+ latestValue = formatImageUpdateValue(info, 'latest');}- return project.updateInfo?.lastCheckedAt ?? '';- }- function mapProjectRow(project: Project): ProjectUpdateRow {- const updatedRefs = project.updateInfo?.updatedImageRefs ?? project.updateInfo?.imageRefs ?? [];return {id: project.id,projectId: project.id,name: project.name,- imageSummary: summarizeImageRefs(updatedRefs),- currentValue: resolveProjectValue(project, 'current'),- latestValue: resolveProjectValue(project, 'latest'),- checkedAt: resolveCheckedAt(project),+ imageSummary,+ currentValue,+ latestValue,+ checkedAt: info?.checkTime || updateInfo?.lastCheckedAt || '',project};}@@ -99,14 +97,14 @@{ accessorKey: 'name', title: m.common_name(), sortable: true, cell: NameCell },{ accessorKey: 'imageSummary', title: m.common_image(), sortable: false, cell: ImageCell },{ accessorKey: 'currentValue', title: m.common_current(), sortable: false, cellComponent: DigestCell },- { accessorKey: 'latestValue', title: m.image_update_latest_digest_label(), sortable: false, cellComponent: DigestCell },+ { accessorKey: 'latestValue', title: m.image_update_latest_label(), sortable: false, cellComponent: DigestCell },{ accessorKey: 'checkedAt', title: m.common_updated(), sortable: false, cellComponent: CheckedAtCell }] satisfies ColumnSpec<ProjectUpdateRow>[];const mobileFields = [{ id: 'imageSummary', 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: 'latestValue', label: m.image_update_latest_label(), defaultVisible: true },{ id: 'checkedAt', label: m.common_updated(), defaultVisible: true }];@@ -213,7 +211,7 @@getValue: (item: ProjectUpdateRow) => item.currentValue},{- label: m.image_update_latest_digest_label(),+ label: m.image_update_latest_label(),getValue: (item: ProjectUpdateRow) => item.latestValue},{diff --git a/tests/spec/updates.spec.ts b/tests/spec/updates.spec.tsindex ba4828933..d346d2453 100644--- a/tests/spec/updates.spec.ts+++ b/tests/spec/updates.spec.ts@@ -43,6 +43,64 @@ function containerWithUpdate(container: (typeof CONTAINERS)[number]) {};}+const TAG_UPDATE_PROJECT = {+ id: 'update-project-tag',+ name: 'updates-tag-project',+ imageRef: 'public.ecr.aws/docker/library/redis:7'+};++/** Serves one project whose tag moved to a new version while the tag's digest stayed the same. */+async function stubProjectWithTagUpdate(page: Page) {+ const checkTime = new Date().toISOString();+ await page.route(/\/api\/environments\/0\/projects(?:\?.*)?$/, async (route) => {+ await route.fulfill({+ status: 200,+ contentType: 'application/json',+ body: JSON.stringify({+ success: true,+ data: [+ {+ id: TAG_UPDATE_PROJECT.id,+ name: TAG_UPDATE_PROJECT.name,+ path: `/projects/${TAG_UPDATE_PROJECT.name}`,+ status: 'running',+ runningCount: '1',+ serviceCount: '1',+ createdAt: checkTime,+ updatedAt: checkTime,+ updateInfo: {+ status: 'has_update',+ hasUpdate: true,+ imageCount: 1,+ checkedImageCount: 1,+ imagesWithUpdates: 1,+ imagesNotPulled: 0,+ errorCount: 0,+ imageRefs: [TAG_UPDATE_PROJECT.imageRef],+ updatedImageRefs: [TAG_UPDATE_PROJECT.imageRef],+ updateInfoByRef: {+ [TAG_UPDATE_PROJECT.imageRef]: {+ hasUpdate: true,+ updateType: 'tag',+ currentVersion: '7.2.4',+ latestVersion: '7.4.1',+ currentDigest: 'sha256:same-digest',+ latestDigest: 'sha256:same-digest',+ checkTime,+ responseTimeMs: 12,+ error: ''+ }+ },+ lastCheckedAt: checkTime+ }+ }+ ],+ pagination: { totalItems: 1, totalPages: 1, currentPage: 1, itemsPerPage: 20 }+ })+ });+ });+}+/** 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) => {@@ -63,6 +121,23 @@ async function stubContainersWithUpdates(page: Page) {});}+test.describe('Updates Page Project Rows', () => {+ test('shows the versions behind a tag update even when the digest is unchanged', async ({+ page+ }) => {+ await stubContainersWithUpdates(page);+ await stubProjectWithTagUpdate(page);++ await page.goto(`${UPDATES_ROUTE}?tab=projects`);+ await page.waitForLoadState('load');++ const row = page.getByRole('row').filter({ hasText: TAG_UPDATE_PROJECT.name });+ await expect(row.getByText('7.2.4', { exact: true })).toBeVisible();+ await expect(row.getByText('7.4.1', { exact: true })).toBeVisible();+ await expect(row.getByText('sha256:same-digest')).toHaveCount(0);+ });+});+test.describe('Updates Page Actions', () => {test('applies updates to the selected container rows', async ({ page }) => {await stubContainersWithUpdates(page);