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.

Route drawer operational state through model owner

rcourtman785c6b174192
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 3e9cda206e..162838229b 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -173,6 +173,10 @@ derivation that feeds the drawer discovery surface,
`resourceDetailDrawerOperationalModel.ts` owns the pure source-health,
platform-signal, related-link, and host-detail overview derivations that feed
the current-state and host-details surfaces,
+and `useResourceDetailDrawerDerivedState.ts` now composes those operational
+overview derivations through that canonical model owner instead of rebuilding
+Kubernetes capability badges, source health, related links, and host-detail
+coverage inline,
`resourceDetailDrawerServiceModel.ts` owns the pure Docker/PBS/PMG service
summary and breakdown derivations that feed the overview service-details
surface,
@@ -416,6 +420,9 @@ The summary shell's `Quick links` row now only promotes runtime-scoped
workloads drill-down routes, so ordinary host drawers do not surface a generic
host-wide `Workloads` jump that reads like default navigation chrome instead of
resource-specific operational context.
+That same `Current state` card now only shows `Mode` when the resource carries
+an actual canonical source mode, so ordinary hosts do not surface an empty or
+meaningless mode row when no source-type contract is present.
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/ResourceDetailDrawerOverviewTab.tsx b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx
index 89a7f1df27..a13263d4b4 100644
--- a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx
+++ b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx
@@ -85,6 +85,7 @@ export const ResourceDetailDrawerOverviewTab: Component<ResourceDetailDrawerOver
) => {
const { resource, drawer } = props;
const showPlatformId = shouldShowResourcePlatformId(resource);
+ const modeLabel = formatSourceType(resource.sourceType);
return (
<div class="space-y-3">
@@ -129,12 +130,12 @@ export const ResourceDetailDrawerOverviewTab: Component<ResourceDetailDrawerOver
</span>
</div>
</Show>
- <div class="flex items-center justify-between gap-2">
- <span class="text-muted">Mode</span>
- <span class="font-medium text-base-content">
- {formatSourceType(resource.sourceType)}
- </span>
- </div>
+ <Show when={modeLabel}>
+ <div class="flex items-center justify-between gap-2">
+ <span class="text-muted">Mode</span>
+ <span class="font-medium text-base-content">{modeLabel}</span>
+ </div>
+ </Show>
<Show when={(resource.alerts?.length || 0) > 0}>
<div class="flex items-center justify-between gap-2">
<span class="text-muted">Alerts</span>
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 206d3ed366..e07589ce15 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx
+++ b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.history.test.tsx
@@ -8,6 +8,7 @@ import resourceDetailDrawerOverviewSource from '@/components/Infrastructure/Reso
import resourceDetailDrawerHistoryStateSource from '@/components/Infrastructure/useResourceDetailDrawerHistoryState.ts?raw';
import resourceDetailDrawerDerivedStateSource from '@/components/Infrastructure/useResourceDetailDrawerDerivedState.ts?raw';
import resourceDetailDrawerDiscoveryModelSource from '@/components/Infrastructure/resourceDetailDiscoveryModel.ts?raw';
+import resourceDetailDrawerOperationalModelSource from '@/components/Infrastructure/resourceDetailDrawerOperationalModel.ts?raw';
import resourceDetailDrawerServiceModelSource from '@/components/Infrastructure/resourceDetailDrawerServiceModel.ts?raw';
import resourceDetailDrawerDockerActionsStateSource from '@/components/Infrastructure/useResourceDetailDrawerDockerActionsState.ts?raw';
import resourceDetailDrawerStateSource from '@/components/Infrastructure/useResourceDetailDrawerState.ts?raw';
@@ -142,10 +143,25 @@ describe('ResourceDetailDrawer change history section', () => {
expect(resourceDetailDrawerDerivedStateSource).toContain(
"from '@/components/Infrastructure/resourceDetailDiscoveryModel'",
);
+ expect(resourceDetailDrawerDerivedStateSource).toContain(
+ "from './resourceDetailDrawerOperationalModel'",
+ );
expect(resourceDetailDrawerDerivedStateSource).toContain(
"from './resourceDetailDrawerServiceModel'",
);
expect(resourceDetailDrawerDiscoveryModelSource).toContain('export const toDiscoveryConfig');
+ expect(resourceDetailDrawerDerivedStateSource).not.toContain('buildWorkloadsHref');
+ expect(resourceDetailDrawerDerivedStateSource).not.toContain('buildServiceDetailLinks');
+ expect(resourceDetailDrawerDerivedStateSource).not.toContain('const supportedBadge =');
+ expect(resourceDetailDrawerDerivedStateSource).not.toContain(
+ 'const links: Array<{ href: string;',
+ );
+ expect(resourceDetailDrawerOperationalModelSource).toContain(
+ 'export const buildKubernetesCapabilityBadges',
+ );
+ expect(resourceDetailDrawerOperationalModelSource).toContain('export const buildSourceSummary');
+ expect(resourceDetailDrawerOperationalModelSource).toContain('export const buildHostDetailCards');
+ expect(resourceDetailDrawerOperationalModelSource).toContain('export const buildRelatedLinks');
expect(resourceDetailDrawerServiceModelSource).toContain('export const getServiceDetailsSummary');
expect(resourceDetailDrawerServiceModelSource).toContain(
'export const buildPbsVisibleJobBreakdown',
@@ -159,6 +175,10 @@ describe('ResourceDetailDrawer change history section', () => {
expect(resourceDetailDrawerOverviewSource).not.toContain('MonitoringAPI.');
expect(resourceDetailDrawerOverviewSource).toContain('drawer.queueDockerUpdateCheck');
expect(resourceDetailDrawerOverviewSource).toContain('drawer.queueDockerUpdateAll');
+ expect(resourceDetailDrawerOverviewSource).toContain(
+ 'const modeLabel = formatSourceType(resource.sourceType);',
+ );
+ expect(resourceDetailDrawerOverviewSource).toContain('<Show when={modeLabel}>');
expect(resourceDetailDrawerDockerActionsStateSource).toContain('MonitoringAPI.checkDockerUpdates');
expect(resourceDetailDrawerDockerActionsStateSource).toContain(
'MonitoringAPI.updateAllDockerContainers',
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 2758396914..27d02c7a27 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
@@ -128,7 +128,6 @@ describe('ResourceDetailDrawer runtime and identity cards', () => {
expect(getByText('Mode')).toBeInTheDocument();
expect(getByText('Hybrid')).toBeInTheDocument();
expect(() => getByText('Platform ID')).toThrow();
- expect(() => getByText('Quick links')).toThrow();
expect(getByTestId('resource-current-state-section').querySelector('.border-dashed')).toBeNull();
expect(queryByRole('button', { name: 'Show details' })).toBeNull();
expect(() => getByText('Runtime')).toThrow();
@@ -260,6 +259,22 @@ describe('ResourceDetailDrawer runtime and identity cards', () => {
expect(queryByText('Show details')).toBeNull();
});
+ it('hides the mode row when a resource has no canonical source mode', () => {
+ const resource = baseResource({
+ sourceType: null as unknown as Resource['sourceType'],
+ platformType: null as unknown as Resource['platformType'],
+ platformData: {
+ sources: [],
+ },
+ });
+
+ const { getByText, queryByText } = render(() => <ResourceDetailDrawer resource={resource} />);
+
+ expect(getByText('Current state')).toBeInTheDocument();
+ expect(queryByText('Mode')).toBeNull();
+ expect(queryByText('Unknown')).toBeNull();
+ });
+
it('shows identity aliases and fallback message when identity metadata is sparse', () => {
const resource = baseResource({
id: 'pmg-main',
diff --git a/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerDerivedState.ts b/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerDerivedState.ts
index 45f0c8f2f2..487eb47f0f 100644
--- a/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerDerivedState.ts
+++ b/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerDerivedState.ts
@@ -10,8 +10,6 @@ import {
getTypeBadge,
getUnifiedSourceBadges,
} from '@/utils/resourceBadgePresentation';
-import { buildWorkloadsHref } from '@/components/Infrastructure/workloadsLink';
-import { buildServiceDetailLinks } from '@/components/Infrastructure/serviceDetailLinks';
import {
getPrimaryResourceIdentity,
getPrimaryResourceIdentityRows,
@@ -48,6 +46,14 @@ import {
getPmgQueueBacklog,
getServiceDetailsSummary,
} from './resourceDetailDrawerServiceModel';
+import {
+ buildHostDetailCards,
+ buildHostDetailSummary,
+ buildKubernetesCapabilityBadges,
+ buildRelatedLinks,
+ buildSourceSummary,
+ hasRuntimeOperationalContext as buildHasRuntimeOperationalContext,
+} from './resourceDetailDrawerOperationalModel';
type DrawerTab = 'overview' | 'mail' | 'namespaces' | 'deployments' | 'swarm' | 'debug';
@@ -105,62 +111,9 @@ export const useResourceDetailDrawerDerivedState = (
const kubernetesMeta = createMemo(
() => resource.kubernetes ?? (platformData()?.kubernetes as KubernetesPlatformData | undefined),
);
- const kubernetesCapabilityBadges = createMemo(() => {
- const capabilities = kubernetesMeta()?.metricCapabilities;
- if (!capabilities) return [] as Array<{ label: string; classes: string; title: string }>;
-
- const supportedBadge =
- 'inline-flex items-center rounded px-2 py-0.5 text-[10px] font-medium whitespace-nowrap bg-cyan-100 text-cyan-700 dark:bg-cyan-900 dark:text-cyan-400';
- const unsupportedBadge =
- 'inline-flex items-center rounded px-2 py-0.5 text-[10px] font-medium whitespace-nowrap bg-surface-alt text-muted';
- const badges: { label: string; classes: string; title: string }[] = [];
-
- if (capabilities.nodeCpuMemory) {
- badges.push({
- label: 'K8s Node CPU/Memory',
- classes: supportedBadge,
- title: 'Node CPU and memory metrics are available.',
- });
- }
- if (capabilities.nodeTelemetry) {
- badges.push({
- label: 'Node Telemetry (Agent)',
- classes: supportedBadge,
- title: 'Linked Pulse agent provides node uptime, temperature, disk, network, and disk I/O.',
- });
- }
- if (capabilities.podCpuMemory) {
- badges.push({
- label: 'Pod CPU/Memory',
- classes: supportedBadge,
- title: 'Pod CPU and memory metrics are available.',
- });
- }
- if (capabilities.podNetwork) {
- badges.push({
- label: 'Pod Network',
- classes: supportedBadge,
- title: 'Pod network throughput is available.',
- });
- }
- if (capabilities.podEphemeralDisk) {
- badges.push({
- label: 'Pod Ephemeral Disk',
- classes: supportedBadge,
- title: 'Pod ephemeral storage usage is available.',
- });
- }
- if (!capabilities.podDiskIo) {
- badges.push({
- label: 'Pod Disk I/O Unsupported',
- classes: unsupportedBadge,
- title:
- 'Pod disk read/write throughput is not collected by the Kubernetes integration path today.',
- });
- }
-
- return badges;
- });
+ const kubernetesCapabilityBadges = createMemo(() =>
+ buildKubernetesCapabilityBadges(kubernetesMeta()?.metricCapabilities),
+ );
const proxmoxNode = createMemo(() => toNodeFromProxmox(resource));
const agentInfo = createMemo(() => toAgentFromResource(resource, agentMeta()));
@@ -258,59 +211,7 @@ export const useResourceDetailDrawerDerivedState = (
const sourceStatus = createMemo<NonNullable<PlatformData['sourceStatus']>>(
() => platformData()?.sourceStatus ?? {},
);
- const sourceHealthSummary = createMemo(() => {
- const entries = Object.entries(sourceStatus());
- if (entries.length === 0) return null;
-
- let healthy = 0;
- let warning = 0;
- let unhealthy = 0;
- const parts: string[] = [];
-
- for (const [source, status] of entries) {
- const normalized = (status?.status || '').trim().toLowerCase();
- parts.push(`${source}:${normalized || 'unknown'}`);
- if (['online', 'running', 'healthy', 'connected', 'ok'].includes(normalized)) {
- healthy += 1;
- } else if (['degraded', 'warning', 'stale'].includes(normalized)) {
- warning += 1;
- } else {
- unhealthy += 1;
- }
- }
-
- const total = entries.length;
- if (unhealthy > 0) {
- return {
- label: `${unhealthy}/${total} unhealthy`,
- className: 'text-red-600 dark:text-red-400',
- title: parts.join(' • '),
- };
- }
- if (warning > 0) {
- return {
- label: `${warning}/${total} degraded`,
- className: 'text-amber-600 dark:text-amber-400',
- title: parts.join(' • '),
- };
- }
- return {
- label: `${healthy}/${total} healthy`,
- className: 'text-emerald-600 dark:text-emerald-400',
- title: parts.join(' • '),
- };
- });
- const sourceSummary = createMemo(() => {
- const health = sourceHealthSummary();
- if (health) return health;
- const sources = mergedSources();
- if (sources.length === 0) return null;
- return {
- label: sources.length === 1 ? sources[0].toUpperCase() : `${sources.length} sources`,
- className: 'text-base-content',
- title: sources.join(' • '),
- };
- });
+ const sourceSummary = createMemo(() => buildSourceSummary(mergedSources(), sourceStatus()));
const identityAliasValues = createMemo(() => getResourceIdentityAliases(resource));
const identityIpValues = createMemo(() => resource.identity?.ips ?? []);
@@ -346,38 +247,18 @@ export const useResourceDetailDrawerDerivedState = (
return config.hostname ? `${discoveryMode} via ${config.hostname}` : discoveryMode;
});
- const hostDetailCards = createMemo(() => {
- const cards: string[] = [];
-
- if (proxmoxNode()) {
- cards.push('system', 'hardware', 'storage');
- }
-
- const agent = agentInfo();
- if (agent) {
- cards.push('system', 'hardware');
- if ((agent.networkInterfaces?.length ?? 0) > 0) cards.push('network');
- if ((agent.disks?.length ?? 0) > 0) cards.push('disks');
- if ((agentMeta()?.raid?.length ?? 0) > 0) cards.push('raid');
- if (temperatureRows().length > 0) cards.push('temperatures');
- }
-
- return cards;
- });
+ const hostDetailCards = createMemo(() =>
+ buildHostDetailCards({
+ hasProxmoxNode: Boolean(proxmoxNode()),
+ hasAgentDetails: Boolean(agentInfo()),
+ networkInterfaceCount: agentInfo()?.networkInterfaces?.length ?? 0,
+ diskCount: agentInfo()?.disks?.length ?? 0,
+ raidCount: agentMeta()?.raid?.length ?? 0,
+ temperatureRowCount: temperatureRows().length,
+ }),
+ );
const hasHostDetails = createMemo(() => hostDetailCards().length > 0);
- const hostDetailSummary = createMemo(() => {
- const labels = Array.from(new Set(hostDetailCards()));
- if (labels.length === 0) return null;
-
- const categories =
- labels.length === 1
- ? labels[0]
- : labels.length === 2
- ? `${labels[0]} and ${labels[1]}`
- : `${labels.slice(0, -1).join(', ')}, and ${labels[labels.length - 1]}`;
-
- return `${hostDetailCards().length} detail card${hostDetailCards().length === 1 ? '' : 's'} covering ${categories}.`;
- });
+ const hostDetailSummary = createMemo(() => buildHostDetailSummary(hostDetailCards()));
const hasServiceDetails = createMemo(
() => resource.type === 'docker-host' || Boolean(pbsData()) || Boolean(pmgData()),
);
@@ -390,30 +271,10 @@ export const useResourceDetailDrawerDerivedState = (
});
});
- const workloadsHref = createMemo(() => buildWorkloadsHref(resource));
const headerIdentity = createMemo(() => getPrimaryResourceIdentity(resource));
- const relatedLinks = createMemo(() => {
- const links: Array<{ href: string; label: string; compactLabel: string; ariaLabel: string }> =
- [];
- const workloads = workloadsHref();
- if (workloads) {
- links.push({
- href: workloads,
- label: 'Open in Workloads',
- compactLabel: 'Workloads',
- ariaLabel: `Open related workloads for ${displayName()}`,
- });
- }
- links.push(...buildServiceDetailLinks(resource));
- const seen = new Set<string>();
- return links.filter((link) => {
- if (seen.has(link.href)) return false;
- seen.add(link.href);
- return true;
- });
- });
+ const relatedLinks = createMemo(() => buildRelatedLinks(resource, displayName()));
const hasRuntimeOperationalContext = createMemo(
- () => kubernetesCapabilityBadges().length > 0 || relatedLinks().length > 0,
+ () => buildHasRuntimeOperationalContext(kubernetesCapabilityBadges(), relatedLinks()),
);
const sourceSections = createMemo(() => {
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index a7bf973022..87423ca726 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -341,6 +341,7 @@ import resourceDetailDrawerDiscoveryModelSource from '@/components/Infrastructur
import resourceDetailMappersSource from '@/components/Infrastructure/resourceDetailMappers.ts?raw';
import resourceDetailDrawerHistoryStateSource from '@/components/Infrastructure/useResourceDetailDrawerHistoryState.ts?raw';
import resourceDetailDrawerDerivedStateSource from '@/components/Infrastructure/useResourceDetailDrawerDerivedState.ts?raw';
+import resourceDetailDrawerOperationalModelSource from '@/components/Infrastructure/resourceDetailDrawerOperationalModel.ts?raw';
import resourceDetailDrawerServiceModelSource from '@/components/Infrastructure/resourceDetailDrawerServiceModel.ts?raw';
import resourceDetailDrawerDockerActionsStateSource from '@/components/Infrastructure/useResourceDetailDrawerDockerActionsState.ts?raw';
import resourceDetailDrawerStateSource from '@/components/Infrastructure/useResourceDetailDrawerState.ts?raw';
@@ -993,12 +994,23 @@ describe('frontend resource type boundaries', () => {
expect(resourceDetailDrawerDerivedStateSource).toContain(
"from '@/components/Infrastructure/resourceDetailDiscoveryModel'",
);
- expect(resourceDetailDrawerDerivedStateSource).toContain('buildWorkloadsHref');
- expect(resourceDetailDrawerDerivedStateSource).toContain('buildServiceDetailLinks');
+ expect(resourceDetailDrawerDerivedStateSource).toContain(
+ "from './resourceDetailDrawerOperationalModel'",
+ );
expect(resourceDetailDrawerDerivedStateSource).toContain(
"from './resourceDetailDrawerServiceModel'",
);
expect(resourceDetailDrawerDiscoveryModelSource).toContain('export const toDiscoveryConfig');
+ expect(resourceDetailDrawerDerivedStateSource).not.toContain('buildWorkloadsHref');
+ expect(resourceDetailDrawerDerivedStateSource).not.toContain('buildServiceDetailLinks');
+ expect(resourceDetailDrawerDerivedStateSource).not.toContain('const supportedBadge =');
+ expect(resourceDetailDrawerDerivedStateSource).not.toContain(
+ 'const links: Array<{ href: string;',
+ );
+ expect(resourceDetailDrawerOperationalModelSource).toContain('buildKubernetesCapabilityBadges');
+ expect(resourceDetailDrawerOperationalModelSource).toContain('buildHostDetailCards');
+ expect(resourceDetailDrawerOperationalModelSource).toContain('buildHostDetailSummary');
+ expect(resourceDetailDrawerOperationalModelSource).toContain('buildRelatedLinks');
expect(resourceDetailDrawerServiceModelSource).toContain('getServiceDetailsSummary');
expect(resourceDetailDrawerOverviewSource).not.toContain('MonitoringAPI.');
expect(resourceDetailDrawerOverviewSource).toContain('drawer.queueDockerUpdateCheck');