Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Canonicalize workload type badges

rcourtman74def6b9ad6d
diff --git a/frontend-modern/scripts/canonical-platform-audit.mjs b/frontend-modern/scripts/canonical-platform-audit.mjs
index b9cf12cf90..35631fd53e 100644
--- a/frontend-modern/scripts/canonical-platform-audit.mjs
+++ b/frontend-modern/scripts/canonical-platform-audit.mjs
@@ -485,6 +485,19 @@ const HELPER_RULES = [
message:
'Do not import canonical workload-type presentation from the badge component. Use @/utils/workloadTypePresentation for non-rendering logic.',
},
+ {
+ rule: 'canonical-type/no-local-workload-type-badge-component',
+ regex: /\b(?:export\s+)?(?:const|function)\s+WorkloadTypeBadge\b/g,
+ message:
+ 'Do not define workload type badge components locally. Use @/components/shared/WorkloadTypeBadge so VM/LXC/container/host styling cannot drift across pages.',
+ allowFiles: new Set(['src/components/shared/WorkloadTypeBadge.tsx']),
+ },
+ {
+ rule: 'canonical-type/no-local-proxmox-backup-workload-badge-tones',
+ regex: /props\.type\s*===\s*['"](?:host|vm|ct)['"][\s\S]{0,260}(?:bg-|text-)/g,
+ message:
+ 'Do not branch Proxmox backup workload badge colors locally. Map PBS-native backup types to the shared workload type badge presentation instead.',
+ },
{
rule: 'canonical-type/no-imports-from-resource-badge-component',
regex:
diff --git a/frontend-modern/src/components/Workloads/GuestRow.tsx b/frontend-modern/src/components/Workloads/GuestRow.tsx
index 508d1fe001..837dc36c61 100644
--- a/frontend-modern/src/components/Workloads/GuestRow.tsx
+++ b/frontend-modern/src/components/Workloads/GuestRow.tsx
@@ -14,6 +14,7 @@ import {
import { StatusDot } from '@/components/shared/StatusDot';
import { TagBadges } from '@/components/shared/TagBadges';
+import { WorkloadTypeBadge } from '@/components/shared/WorkloadTypeBadge';
import { resolveWorkloadType } from '@/utils/workloads';
import { EnhancedCPUBar } from '@/components/Workloads/EnhancedCPUBar';
import { MetricMiniSparkline } from '@/components/Workloads/MetricMiniSparkline';
@@ -259,12 +260,11 @@ export function GuestRow(props: GuestRowProps) {
<Show when={isColVisible('type')}>
<td class="px-1.5 sm:px-2 py-0.5 align-middle">
<div class="flex justify-center">
- <span
- class={`inline-flex items-center px-1 py-0.5 text-[10px] font-medium rounded whitespace-nowrap ${typeInfo().className}`}
+ <WorkloadTypeBadge
+ type={workloadType()}
+ label={typeInfo().label}
title={typeInfo().title}
- >
- {typeInfo().label}
- </span>
+ />
</div>
</td>
</Show>
diff --git a/frontend-modern/src/components/shared/WorkloadTypeBadge.tsx b/frontend-modern/src/components/shared/WorkloadTypeBadge.tsx
new file mode 100644
index 0000000000..7fa81fde0e
--- /dev/null
+++ b/frontend-modern/src/components/shared/WorkloadTypeBadge.tsx
@@ -0,0 +1,33 @@
+import { createMemo, type Component } from 'solid-js';
+import type { WorkloadType } from '@/types/workloads';
+import { getWorkloadTypeBadge } from '@/components/shared/workloadTypeBadges';
+
+export const WORKLOAD_TYPE_BADGE_CLASS =
+ 'inline-flex items-center rounded px-1 py-0.5 text-[10px] font-medium whitespace-nowrap';
+
+export interface WorkloadTypeBadgeProps {
+ type: string | WorkloadType | null | undefined;
+ label?: string;
+ title?: string;
+ class?: string;
+}
+
+export const WorkloadTypeBadge: Component<WorkloadTypeBadgeProps> = (props) => {
+ const badge = createMemo(() =>
+ getWorkloadTypeBadge(props.type, {
+ label: props.label,
+ title: props.title,
+ }),
+ );
+
+ return (
+ <span
+ class={`${WORKLOAD_TYPE_BADGE_CLASS} ${badge().className} ${props.class ?? ''}`.trim()}
+ title={badge().title}
+ >
+ {badge().label}
+ </span>
+ );
+};
+
+export default WorkloadTypeBadge;
diff --git a/frontend-modern/src/components/shared/__tests__/WorkloadTypeBadge.test.tsx b/frontend-modern/src/components/shared/__tests__/WorkloadTypeBadge.test.tsx
new file mode 100644
index 0000000000..b238a76668
--- /dev/null
+++ b/frontend-modern/src/components/shared/__tests__/WorkloadTypeBadge.test.tsx
@@ -0,0 +1,32 @@
+import { afterEach, describe, expect, it } from 'vitest';
+import { cleanup, render, screen } from '@solidjs/testing-library';
+import { WorkloadTypeBadge } from '@/components/shared/WorkloadTypeBadge';
+import { getWorkloadTypeBadge } from '@/components/shared/workloadTypeBadges';
+
+afterEach(cleanup);
+
+describe('WorkloadTypeBadge', () => {
+ it('renders through the canonical workload type badge presentation', () => {
+ render(() => <WorkloadTypeBadge type="system-container" />);
+
+ const badge = screen.getByText('LXC');
+ const presentation = getWorkloadTypeBadge('system-container');
+
+ expect(badge).toHaveAttribute('title', presentation.title);
+ for (const className of presentation.className.split(' ')) {
+ expect(badge).toHaveClass(className);
+ }
+ });
+
+ it('allows context-specific labels without changing the canonical tone', () => {
+ render(() => <WorkloadTypeBadge type="agent" label="Host" title="Host backup" />);
+
+ const badge = screen.getByText('Host');
+ const presentation = getWorkloadTypeBadge('agent');
+
+ expect(badge).toHaveAttribute('title', 'Host backup');
+ for (const className of presentation.className.split(' ')) {
+ expect(badge).toHaveClass(className);
+ }
+ });
+});
diff --git a/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
index 79d8331ad7..6022786c0c 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxBackupsTable.tsx
@@ -112,7 +112,7 @@ export const ProxmoxBackupsTable: Component<{
};
// Type scope normalizes vm/qemu and ct/lxc to a canonical token before
- // comparing, since the recovery model uses vm/ct/host.
+ // comparing, since the recovery model keeps PBS-native ct internally.
const typeFilter = (): string => (typeof searchParams.type === 'string' ? searchParams.type : '');
const setTypeFilter = (value: string): void => setSearchParams({ type: value || null });
const canonicalGuestType = (raw: string | undefined): string => {
@@ -129,7 +129,7 @@ export const ProxmoxBackupsTable: Component<{
const typeFilterOptions: FilterSelectOption[] = [
{ value: '', label: 'All types' },
{ value: 'vm', label: 'VMs' },
- { value: 'ct', label: 'Containers' },
+ { value: 'ct', label: 'LXCs' },
{ value: 'host', label: 'Hosts' },
];
@@ -138,7 +138,7 @@ export const ProxmoxBackupsTable: Component<{
const [expandedCoverageRows, setExpandedCoverageRows] = createSignal<ReadonlySet<string>>(
new Set<string>(),
);
- // Orphaned backups (VM/CT records whose guest no longer exists in inventory)
+ // Orphaned backups (VM/LXC records whose guest no longer exists in inventory)
// are collapsed by default so the main table is active backup targets, not a
// pile of nameless dead records sorted to the top.
const [showOrphaned, setShowOrphaned] = createSignal(false);
@@ -269,7 +269,7 @@ export const ProxmoxBackupsTable: Component<{
});
// The main table is the user's active backup targets: live inventory guests
- // plus first-class host backups. Orphaned VM/CT backup records are partitioned
+ // plus first-class host backups. Orphaned VM/LXC backup records are partitioned
// out into their own collapsed section so they don't dominate the top of the
// list with nameless rows.
const liveCoverageRows = createMemo(() =>
diff --git a/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx
index 0fafac8467..27529497cb 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxCoverageTable.tsx
@@ -31,8 +31,8 @@ import type { CoverageSortKey } from './proxmoxBackupsTableModel';
import {
ArtifactSourceBadge,
ArtifactStateBadge,
+ ProxmoxBackupWorkloadTypeBadge,
SortableHead,
- WorkloadTypeBadge,
artifactStateLabel,
} from './proxmoxBackupsTableShared';
@@ -245,7 +245,7 @@ export function ProxmoxCoverageTable(props: {
<TableCell
class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
>
- <WorkloadTypeBadge
+ <ProxmoxBackupWorkloadTypeBadge
type={row.workload.type}
label={row.workload.typeLabel}
/>
diff --git a/frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx b/frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx
index 7fa474506c..497ac6c5ae 100644
--- a/frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx
+++ b/frontend-modern/src/features/proxmox/ProxmoxRecoverableTable.tsx
@@ -29,9 +29,9 @@ import type { RecoverableSortKey } from './proxmoxBackupsTableModel';
import {
ArtifactSourceBadge,
ArtifactStateBadge,
+ ProxmoxBackupWorkloadTypeBadge,
RowMetricBar,
SortableHead,
- WorkloadTypeBadge,
artifactStateLabel,
} from './proxmoxBackupsTableShared';
@@ -91,7 +91,10 @@ export function ProxmoxRecoverableTable(props: {
</div>
</TableCell>
<TableCell class={`${getPlatformTableCellClassForKind('text')} text-base-content`}>
- <WorkloadTypeBadge type={artifact.workload.type} label={artifact.workload.typeLabel} />
+ <ProxmoxBackupWorkloadTypeBadge
+ type={artifact.workload.type}
+ label={artifact.workload.typeLabel}
+ />
</TableCell>
<TableCell
class={`${getPlatformTableCellClassForKind('text')} text-muted font-mono text-[11px] tabular-nums`}
diff --git a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
index f8d5e3d621..1f0e83a4b6 100644
--- a/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
+++ b/frontend-modern/src/features/proxmox/__tests__/ProxmoxBackupsTable.test.tsx
@@ -143,6 +143,7 @@ describe('ProxmoxBackupsTable', () => {
expect(screen.getByRole('columnheader', { name: /location/i })).toBeInTheDocument();
expect(screen.getByRole('columnheader', { name: /source/i })).toBeInTheDocument();
expect(screen.getByRole('columnheader', { name: /type/i })).toBeInTheDocument();
+ expect(screen.getAllByText('LXC').length).toBeGreaterThan(0);
expect(screen.getAllByText('PBS').length).toBeGreaterThan(0);
expect(screen.getByText('main / minipc')).toBeInTheDocument();
expect(
diff --git a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.test.ts b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.test.ts
index 02db1b8f36..65a7a1cff8 100644
--- a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.test.ts
+++ b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupRecoveryModel.test.ts
@@ -97,7 +97,7 @@ describe('proxmoxBackupRecoveryModel', () => {
expect(model.recoverableArtifacts).toHaveLength(3);
const row = model.coverageRows[0];
- expect(row.workload.label).toBe('pbs-docker (CT 112)');
+ expect(row.workload.label).toBe('pbs-docker (LXC 112)');
expect(row.pbsCount).toBe(1);
expect(row.archiveCount).toBe(1);
expect(row.snapshotCount).toBe(1);
@@ -168,9 +168,9 @@ describe('proxmoxBackupRecoveryModel', () => {
expect(live?.isOrphaned).toBe(false);
expect(live?.workload.name).toBe('pbs-docker');
expect(orphan?.isOrphaned).toBe(true);
- // Orphans have no live guest to name them; label falls back to "CT <vmid>".
+ // Orphans have no live guest to name them; label falls back to "LXC <vmid>".
expect(orphan?.workload.name).toBeUndefined();
- expect(orphan?.workload.label).toBe('CT 999');
+ expect(orphan?.workload.label).toBe('LXC 999');
});
it('keeps host backups in coverage without counting zero-id aggregate artifacts as guests', () => {
@@ -213,7 +213,7 @@ describe('proxmoxBackupRecoveryModel', () => {
expect(model.coverageRows[0].pbsCount).toBe(1);
expect(model.coverageRows[0].archiveCount).toBe(1);
expect(model.recoverableArtifacts.map((artifact) => artifact.workload.label)).toEqual(
- expect.arrayContaining(['CT backup', 'Host mail-gateway']),
+ expect.arrayContaining(['LXC backup', 'Host mail-gateway']),
);
});
diff --git a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupsTableModel.test.ts b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupsTableModel.test.ts
index b29b1ffa44..1b78a5a89e 100644
--- a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupsTableModel.test.ts
+++ b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupsTableModel.test.ts
@@ -39,13 +39,13 @@ describe('proxmoxBackupsTableModel', () => {
describe('label helpers', () => {
it('formats guest labels by type', () => {
- expect(guestLabel('ct', 101)).toBe('CT 101');
+ expect(guestLabel('ct', 101)).toBe('LXC 101');
expect(guestLabel('vm', 202)).toBe('VM 202');
expect(guestLabel(undefined, 303)).toBe('Guest 303');
});
it('formats PBS workload labels including host backups', () => {
- expect(pbsWorkloadLabel(pbs({ backupType: 'ct', vmid: '101' }))).toBe('CT 101');
+ expect(pbsWorkloadLabel(pbs({ backupType: 'ct', vmid: '101' }))).toBe('LXC 101');
expect(pbsWorkloadLabel(pbs({ backupType: 'vm', vmid: '202' }))).toBe('VM 202');
expect(pbsWorkloadLabel(pbs({ backupType: 'host', vmid: '' }))).toBe('Host');
expect(pbsWorkloadLabel(pbs({ backupType: 'host', vmid: '9' }))).toBe('Host 9');
diff --git a/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupsTableShared.test.tsx b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupsTableShared.test.tsx
new file mode 100644
index 0000000000..d17a1e2e48
--- /dev/null
+++ b/frontend-modern/src/features/proxmox/__tests__/proxmoxBackupsTableShared.test.tsx
@@ -0,0 +1,41 @@
+import { afterEach, describe, expect, it } from 'vitest';
+import { cleanup, render, screen } from '@solidjs/testing-library';
+import { WorkloadTypeBadge } from '@/components/shared/WorkloadTypeBadge';
+import proxmoxBackupsTableSharedSource from '../proxmoxBackupsTableShared.tsx?raw';
+import { ProxmoxBackupWorkloadTypeBadge } from '../proxmoxBackupsTableShared';
+
+afterEach(cleanup);
+
+describe('proxmoxBackupsTableShared', () => {
+ it('maps PBS ct rows onto the same LXC badge used by the workload overview', () => {
+ render(() => (
+ <>
+ <WorkloadTypeBadge type="system-container" />
+ <ProxmoxBackupWorkloadTypeBadge type="ct" label="LXC" />
+ </>
+ ));
+
+ const [overviewBadge, backupBadge] = screen.getAllByText('LXC');
+ expect(backupBadge.className).toBe(overviewBadge.className);
+ });
+
+ it('keeps host backup labels on the shared host/agent tone instead of local backup colors', () => {
+ render(() => (
+ <>
+ <WorkloadTypeBadge type="agent" label="Host" title="Host backup" />
+ <ProxmoxBackupWorkloadTypeBadge type="host" label="Host" />
+ </>
+ ));
+
+ const [sharedBadge, backupBadge] = screen.getAllByText('Host');
+ expect(backupBadge.className).toBe(sharedBadge.className);
+ expect(backupBadge).toHaveAttribute('title', 'Host backup');
+ });
+
+ it('does not carry local VM/LXC/Host badge color branches', () => {
+ expect(proxmoxBackupsTableSharedSource).toContain('SharedWorkloadTypeBadge');
+ expect(proxmoxBackupsTableSharedSource).not.toContain('bg-indigo');
+ expect(proxmoxBackupsTableSharedSource).not.toContain('bg-teal');
+ expect(proxmoxBackupsTableSharedSource).not.toContain('bg-slate');
+ });
+});
diff --git a/frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts b/frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts
index 41b3318e38..07bebb5f86 100644
--- a/frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts
+++ b/frontend-modern/src/features/proxmox/proxmoxBackupRecoveryModel.ts
@@ -63,7 +63,7 @@ export interface WorkloadCoverageRow {
snapshotCount: number;
posture: WorkloadRecoveryPosture;
postureRank: number;
- // True only when a VM/CT row exists because a backup/task referenced a VMID
+ // True only when a VM/LXC row exists because a backup/task referenced a VMID
// with no matching live inventory guest. Host backups can also carry a
// `backup:` key, but they are first-class backup targets, not orphaned guests.
isOrphaned: boolean;
@@ -129,7 +129,7 @@ function backupTypeLabel(type: string | undefined): WorkloadReference['type'] {
function typeLabel(type: WorkloadReference['type']): string {
if (type === 'vm') return 'VM';
- if (type === 'ct') return 'CT';
+ if (type === 'ct') return 'LXC';
if (type === 'host') return 'Host';
return 'Guest';
}
diff --git a/frontend-modern/src/features/proxmox/proxmoxBackupsTableModel.ts b/frontend-modern/src/features/proxmox/proxmoxBackupsTableModel.ts
index 3aed07177a..8ef5ab74d3 100644
--- a/frontend-modern/src/features/proxmox/proxmoxBackupsTableModel.ts
+++ b/frontend-modern/src/features/proxmox/proxmoxBackupsTableModel.ts
@@ -1,5 +1,6 @@
import type { GuestSnapshot, PBSBackup } from '@/types/api';
import type { StatusIndicatorVariant } from '@/utils/status';
+import { getWorkloadTypePresentation } from '@/utils/workloadTypePresentation';
// Pure model logic for ProxmoxBackupsTable: tab identifiers, per-tab sort-key
// types and their default directions, sort comparators, and workload/label/
@@ -69,14 +70,19 @@ export function classifyTaskStatus(status: string): {
export function guestLabel(type: string | undefined, vmid: number): string {
const t = (type ?? '').toLowerCase();
- const kind = t === 'ct' ? 'CT' : t === 'vm' ? 'VM' : t.toUpperCase() || 'Guest';
+ const kind =
+ t === 'ct'
+ ? getWorkloadTypePresentation('system-container').label
+ : t === 'vm'
+ ? getWorkloadTypePresentation('vm').label
+ : t.toUpperCase() || 'Guest';
return `${kind} ${vmid}`;
}
export function pbsWorkloadLabel(backup: PBSBackup): string {
const t = (backup.backupType ?? '').toLowerCase();
- if (t === 'ct') return `CT ${backup.vmid}`;
- if (t === 'vm') return `VM ${backup.vmid}`;
+ if (t === 'ct') return `${getWorkloadTypePresentation('system-container').label} ${backup.vmid}`;
+ if (t === 'vm') return `${getWorkloadTypePresentation('vm').label} ${backup.vmid}`;
if (t === 'host') return backup.vmid ? `Host ${backup.vmid}` : 'Host';
const kind = backup.backupType?.trim().toUpperCase() || 'Backup';
return backup.vmid ? `${kind} ${backup.vmid}` : kind;
diff --git a/frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx b/frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx
index defce6bbef..9eb6137908 100644
--- a/frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx
+++ b/frontend-modern/src/features/proxmox/proxmoxBackupsTableShared.tsx
@@ -5,6 +5,7 @@ import ArrowUpDownIcon from 'lucide-solid/icons/arrow-up-down';
import { type FilterOption } from '@/components/shared/FilterButtonGroup';
import { ProgressBar } from '@/components/shared/ProgressBar';
import { TableHead } from '@/components/shared/Table';
+import { WorkloadTypeBadge as SharedWorkloadTypeBadge } from '@/components/shared/WorkloadTypeBadge';
import type { RecoverableArtifact, WorkloadReference } from './proxmoxBackupRecoveryModel';
import type {
@@ -175,28 +176,29 @@ export function ArtifactSourceBadge(props: { artifact: RecoverableArtifact }) {
);
}
-export function WorkloadTypeBadge(props: {
+const proxmoxBackupWorkloadBadgeType = (
+ type: WorkloadReference['type'],
+): string | null | undefined => {
+ if (type === 'ct') return 'system-container';
+ if (type === 'host') return 'agent';
+ return type === 'unknown' ? undefined : type;
+};
+
+const proxmoxBackupWorkloadBadgeTitle = (type: WorkloadReference['type']): string | undefined => {
+ if (type === 'host') return 'Host backup';
+ return undefined;
+};
+
+export function ProxmoxBackupWorkloadTypeBadge(props: {
type: WorkloadReference['type'];
label: string;
}) {
- const badgeClass = () => {
- if (props.type === 'host') {
- return 'bg-slate-100 text-slate-700 dark:bg-slate-800 dark:text-slate-200';
- }
- if (props.type === 'vm') {
- return 'bg-indigo-100 text-indigo-700 dark:bg-indigo-900/40 dark:text-indigo-200';
- }
- if (props.type === 'ct') {
- return 'bg-teal-100 text-teal-700 dark:bg-teal-900/40 dark:text-teal-200';
- }
- return 'bg-surface-alt text-muted';
- };
return (
- <span
- class={`inline-flex items-center rounded-sm px-1.5 py-0.5 text-[10px] font-semibold ${badgeClass()}`}
- >
- {props.label}
- </span>
+ <SharedWorkloadTypeBadge
+ type={proxmoxBackupWorkloadBadgeType(props.type)}
+ label={props.label}
+ title={proxmoxBackupWorkloadBadgeTitle(props.type)}
+ />
);
}
diff --git a/frontend-modern/src/utils/__tests__/resourceTypePresentation.test.ts b/frontend-modern/src/utils/__tests__/resourceTypePresentation.test.ts
index a843659951..aef061871d 100644
--- a/frontend-modern/src/utils/__tests__/resourceTypePresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/resourceTypePresentation.test.ts
@@ -3,6 +3,7 @@ import {
getResourceTypeLabel,
getResourceTypePresentation,
} from '@/utils/resourceTypePresentation';
+import { getWorkloadTypePresentation } from '@/utils/workloadTypePresentation';
describe('resourceTypePresentation', () => {
it('returns canonical labels for unified resource types', () => {
@@ -44,4 +45,19 @@ describe('resourceTypePresentation', () => {
label: 'Container',
});
});
+
+ it('uses the canonical workload type palette for resource types that also appear in workload tables', () => {
+ for (const [resourceType, workloadType] of [
+ ['vm', 'vm'],
+ ['system-container', 'system-container'],
+ ['oci-container', 'system-container'],
+ ['app-container', 'app-container'],
+ ['pod', 'pod'],
+ ['agent', 'agent'],
+ ] as const) {
+ expect(getResourceTypePresentation(resourceType)?.badgeClasses).toBe(
+ getWorkloadTypePresentation(workloadType).className,
+ );
+ }
+ });
});
diff --git a/frontend-modern/src/utils/resourceTypePresentation.ts b/frontend-modern/src/utils/resourceTypePresentation.ts
index 28c28a911c..d63c752711 100644
--- a/frontend-modern/src/utils/resourceTypePresentation.ts
+++ b/frontend-modern/src/utils/resourceTypePresentation.ts
@@ -1,5 +1,6 @@
import type { ResourceType } from '@/types/resource';
import { canonicalizeFrontendResourceType } from '@/utils/resourceTypeCompat';
+import { getWorkloadTypePresentation } from '@/utils/workloadTypePresentation';
export interface ResourceTypePresentation {
label: string;
@@ -8,12 +9,19 @@ export interface ResourceTypePresentation {
const DEFAULT_BADGE_CLASSES = 'bg-surface-alt text-base-content';
+const workloadTypeResourcePresentation = (
+ workloadType: Parameters<typeof getWorkloadTypePresentation>[0],
+): ResourceTypePresentation => {
+ const presentation = getWorkloadTypePresentation(workloadType);
+ return {
+ label: presentation.label,
+ badgeClasses: presentation.className,
+ };
+};
+
const RESOURCE_TYPE_PRESENTATION: Partial<Record<ResourceType | string, ResourceTypePresentation>> =
{
- agent: {
- label: 'Agent',
- badgeClasses: 'bg-blue-500 text-blue-300',
- },
+ agent: workloadTypeResourcePresentation('agent'),
'docker-host': {
label: 'Container Runtime',
badgeClasses: DEFAULT_BADGE_CLASSES,
@@ -26,26 +34,11 @@ const RESOURCE_TYPE_PRESENTATION: Partial<Record<ResourceType | string, Resource
label: 'K8s Node',
badgeClasses: DEFAULT_BADGE_CLASSES,
},
- vm: {
- label: 'VM',
- badgeClasses: DEFAULT_BADGE_CLASSES,
- },
- 'system-container': {
- label: 'Container',
- badgeClasses: 'bg-blue-500 text-blue-300',
- },
- 'oci-container': {
- label: 'Container',
- badgeClasses: 'bg-blue-500 text-blue-300',
- },
- 'app-container': {
- label: 'App Container',
- badgeClasses: 'bg-blue-500 text-blue-300',
- },
- pod: {
- label: 'Pod',
- badgeClasses: DEFAULT_BADGE_CLASSES,
- },
+ vm: workloadTypeResourcePresentation('vm'),
+ 'system-container': workloadTypeResourcePresentation('system-container'),
+ 'oci-container': workloadTypeResourcePresentation('system-container'),
+ 'app-container': workloadTypeResourcePresentation('app-container'),
+ pod: workloadTypeResourcePresentation('pod'),
jail: {
label: 'Jail',
badgeClasses: DEFAULT_BADGE_CLASSES,