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.

Deduplicate drawer header badges

rcourtman2cca632a2d2f
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 5af4e8beeb..dd4e0289f2 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -409,6 +409,9 @@ The drawer header now stays focused on canonical identity and source/type
badges only, while workload/service drill-down links and Kubernetes platform
signals live with the summary shell, so the top strip does not compete with
the resource name, status, or primary identity line.
+That header badge row now also deduplicates identical visible labels, so
+agent-backed nodes do not repeat `Agent` when both the canonical resource type
+and a merged source resolve to the same badge text.
Inside that summary, the operational and supporting context rows stay inline
instead of sitting in a collapsed `Details` disclosure or nested bordered
cards, so the first read stays like one linear sheet rather than a stack of
diff --git a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
index 0f1e9a4d67..30f9600582 100644
--- a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
+++ b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
@@ -64,43 +64,14 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
<div class="text-[11px] text-muted truncate" title={drawer.headerIdentity()}>
{drawer.headerIdentity()}
</div>
- <div class="flex flex-wrap gap-1.5">
- <Show when={drawer.typeBadge()}>
+ <div class="flex flex-wrap gap-1.5" data-testid="resource-header-badges">
+ <For each={drawer.headerBadges()}>
{(badge) => (
- <span class={badge().classes} title={badge().title}>
- {badge().label}
+ <span class={badge.classes} title={badge.title}>
+ {badge.label}
</span>
)}
- </Show>
- <Show
- when={drawer.hasUnifiedSources()}
- fallback={
- <>
- <Show when={drawer.platformBadge()}>
- {(badge) => (
- <span class={badge().classes} title={badge().title}>
- {badge().label}
- </span>
- )}
- </Show>
- <Show when={drawer.sourceBadge()}>
- {(badge) => (
- <span class={badge().classes} title={badge().title}>
- {badge().label}
- </span>
- )}
- </Show>
- </>
- }
- >
- <For each={drawer.unifiedSourceBadges()}>
- {(badge) => (
- <span class={badge.classes} title={badge.title}>
- {badge.label}
- </span>
- )}
- </For>
- </Show>
+ </For>
</div>
</div>
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx
index d18b2e902d..206d3ed366 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx
+++ b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx
@@ -124,6 +124,9 @@ describe('ResourceDetailDrawer change history section', () => {
"from './ResourceDetailDrawerOverviewTab'",
);
expect(resourceDetailDrawerShellSource).toContain("from './ResourceDetailDrawerDebugTab'");
+ expect(resourceDetailDrawerShellSource).toContain('data-testid="resource-header-badges"');
+ expect(resourceDetailDrawerShellSource).toContain('drawer.headerBadges()');
+ expect(resourceDetailDrawerShellSource).not.toContain('drawer.unifiedSourceBadges()');
expect(resourceDetailDrawerShellSource).not.toContain('Change history');
expect(resourceDetailDrawerStateSource).toContain("from './useResourceDetailDrawerHistoryState'");
expect(resourceDetailDrawerStateSource).toContain("from './useResourceDetailDrawerDerivedState'");
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.identity-runtime.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.identity-runtime.test.tsx
index af09f2cd9e..c92e715cb5 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.identity-runtime.test.tsx
+++ b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.identity-runtime.test.tsx
@@ -1,5 +1,5 @@
import { describe, expect, it, vi } from 'vitest';
-import { fireEvent, render, waitFor } from '@solidjs/testing-library';
+import { fireEvent, render, waitFor, within } from '@solidjs/testing-library';
import type { Resource } from '@/types/resource';
import {
@@ -135,6 +135,9 @@ describe('ResourceDetailDrawer runtime and identity cards', () => {
expect(getByRole('link', { name: 'Open related workloads for host-1' })).toHaveTextContent(
'Workloads',
);
+ const headerBadges = getByTestId('resource-header-badges');
+ expect(within(headerBadges).getAllByText('Agent')).toHaveLength(1);
+ expect(within(headerBadges).getByText('PVE')).toBeInTheDocument();
});
it('keeps discovery as secondary overview context instead of a peer tab', async () => {
diff --git a/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerDerivedState.ts b/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerDerivedState.ts
index 814acf1821..45f0c8f2f2 100644
--- a/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerDerivedState.ts
+++ b/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerDerivedState.ts
@@ -4,6 +4,7 @@ import { requiresGovernedResourceDisplay } from '@/types/resource';
import { formatAbsoluteTime, formatRelativeTime } from '@/utils/format';
import { getAgentStatusIndicator } from '@/utils/status';
import {
+ dedupeResourceBadges,
getPlatformBadge,
getSourceBadge,
getTypeBadge,
@@ -79,6 +80,12 @@ export const useResourceDetailDrawerDerivedState = (
getUnifiedSourceBadges(platformData()?.sources ?? []),
);
const hasUnifiedSources = createMemo(() => unifiedSourceBadges().length > 0);
+ const headerBadges = createMemo(() =>
+ dedupeResourceBadges([
+ typeBadge(),
+ ...(hasUnifiedSources() ? unifiedSourceBadges() : [platformBadge(), sourceBadge()]),
+ ]),
+ );
const policyBadges = createMemo(() => getResourcePolicyBadges(resource.policy));
const policyRedactions = createMemo(() => getResourcePolicyRedactionLabels(resource.policy));
const governanceSummary = createMemo(() =>
@@ -487,6 +494,7 @@ export const useResourceDetailDrawerDerivedState = (
platformData,
unifiedSourceBadges,
hasUnifiedSources,
+ headerBadges,
policyBadges,
policyRedactions,
governanceSummary,
diff --git a/frontend-modern/src/utils/__tests__/resourceBadgePresentation.test.ts b/frontend-modern/src/utils/__tests__/resourceBadgePresentation.test.ts
index 7b60dae2e4..c87415ede0 100644
--- a/frontend-modern/src/utils/__tests__/resourceBadgePresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/resourceBadgePresentation.test.ts
@@ -1,5 +1,6 @@
import { describe, expect, it } from 'vitest';
import {
+ dedupeResourceBadges,
getPlatformBadge,
getSourceBadge,
getTypeBadge,
@@ -26,4 +27,13 @@ describe('resourceBadgePresentation', () => {
const badges = getUnifiedSourceBadges(['TrueNAS', 'PROXMOX', 'truenas']);
expect(badges.map((badge) => badge.label)).toEqual(['TrueNAS', 'PVE']);
});
+
+ it('deduplicates repeated header badge labels', () => {
+ const badges = dedupeResourceBadges([
+ getTypeBadge('agent'),
+ getPlatformBadge('proxmox-pve'),
+ getSourceBadge('agent'),
+ ]);
+ expect(badges.map((badge) => badge.label)).toEqual(['Agent', 'PVE']);
+ });
});
diff --git a/frontend-modern/src/utils/resourceBadgePresentation.ts b/frontend-modern/src/utils/resourceBadgePresentation.ts
index 0071a880d3..a43d4f2c4c 100644
--- a/frontend-modern/src/utils/resourceBadgePresentation.ts
+++ b/frontend-modern/src/utils/resourceBadgePresentation.ts
@@ -67,6 +67,19 @@ export function getUnifiedSourceBadges(sources?: string[] | null): ResourceBadge
});
}
+export function dedupeResourceBadges(
+ badges: Array<ResourceBadge | null | undefined>,
+): ResourceBadge[] {
+ const seen = new Set<string>();
+ return badges.filter((badge): badge is ResourceBadge => {
+ if (!badge) return false;
+ const normalizedLabel = badge.label.trim().toLowerCase();
+ if (!normalizedLabel || seen.has(normalizedLabel)) return false;
+ seen.add(normalizedLabel);
+ return true;
+ });
+}
+
export function getContainerRuntimeBadge(
platformType?: PlatformType,
platformData?: Record<string, unknown> | null,