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.

Converge alert web links on shared primitive

rcourtman761127018e03
diff --git a/docs/release-control/v6/internal/subsystems/alerts.md b/docs/release-control/v6/internal/subsystems/alerts.md
index 7cc542e37f..a898b8e27c 100644
--- a/docs/release-control/v6/internal/subsystems/alerts.md
+++ b/docs/release-control/v6/internal/subsystems/alerts.md
@@ -791,7 +791,13 @@ desktop row ownership lives in
`frontend-modern/src/components/Alerts/AlertResourceTableRow.tsx`, and selection
state, delay-row toggling, and inline metric-input focus live in
`frontend-modern/src/components/Alerts/useAlertResourceTableState.ts`. Shared
-resource-table empty states, badge labels, offline-state wording, note
+web-interface launch affordances inside alert resource rows and grouped agent
+headers must compose
+`frontend-modern/src/components/shared/WebInterfaceNameLink.tsx`; alerts own
+only the alert/resource data and URL availability decision, not the external
+anchor shell, new-tab safety attributes, row-click containment, or accessible
+launch-label semantics.
+Resource-table empty states, badge labels, offline-state wording, note
placeholders, and metric input titles now route through
`frontend-modern/src/utils/alertResourceTablePresentation.ts` instead of
remaining duplicated across the desktop and mobile thresholds surfaces.
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 9cab27675b..913c9fb076 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -2608,11 +2608,12 @@ instead of page-local table columns or one-off external-link anchors.
`frontend-modern/src/components/shared/WebInterfaceNameLink.tsx` owns the
resource-name link shell, new-tab safety attributes, row-click/key propagation
containment, fallback text, and accessible launch labels. Workload guest rows,
-grouped node headers, standalone machine rows, and Proxmox node rows compose
-that primitive so a saved or inferred URL is opened by clicking the resource
-name on every comparable runtime table. Runtime/platform tables must not add
-separate `Web` columns, page-local external-link anchors, or duplicated new-tab
-safety handling for that launch affordance.
+grouped node headers, standalone machine rows, Proxmox node rows, and alert
+resource rows/group headers compose that primitive so a saved or inferred URL
+is opened by clicking the resource name on every comparable runtime table.
+Runtime/platform tables must not add separate `Web` columns, page-local
+external-link anchors, or duplicated new-tab safety handling for that launch
+affordance.
Shared-template drift enforcement is registry-backed:
`frontend-modern/scripts/shared-template-registry.json` is the canonical list of
standardized repeated affordances, required consumers, and forbidden local
diff --git a/frontend-modern/scripts/shared-template-registry.json b/frontend-modern/scripts/shared-template-registry.json
index d56657a324..3a3cf06904 100644
--- a/frontend-modern/scripts/shared-template-registry.json
+++ b/frontend-modern/scripts/shared-template-registry.json
@@ -21,6 +21,12 @@
},
{
"path": "src/features/proxmox/ProxmoxNodesTable.tsx"
+ },
+ {
+ "path": "src/components/Alerts/AlertResourceGroupHeader.tsx"
+ },
+ {
+ "path": "src/components/Alerts/AlertResourceTableRow.tsx"
}
],
"forbiddenPatterns": [
@@ -56,15 +62,25 @@
{
"path": "src/features/proxmox/proxmoxHostTableModel.ts",
"patterns": ["id: 'web'", "label: 'Web'"]
+ },
+ {
+ "path": "src/components/Alerts/AlertResourceGroupHeader.tsx",
+ "patterns": ["target=\"_blank\"", "rel=\"noopener noreferrer\""]
+ },
+ {
+ "path": "src/components/Alerts/AlertResourceTableRow.tsx",
+ "patterns": ["target=\"_blank\"", "rel=\"noopener noreferrer\""]
}
],
"proof": [
"src/components/shared/SharedPrimitives.guardrails.test.ts",
+ "src/components/shared/WebInterfaceNameLink.test.tsx",
"src/components/shared/__tests__/NodeGroupHeader.test.tsx",
"src/features/standalone/__tests__/AgentsMachinesTable.test.tsx",
"src/components/Workloads/__tests__/GuestRow.test.tsx",
"src/features/proxmox/__tests__/ProxmoxNodesTable.test.tsx",
- "src/features/proxmox/__tests__/proxmoxHostTableModel.test.ts"
+ "src/features/proxmox/__tests__/proxmoxHostTableModel.test.ts",
+ "src/components/Alerts/ResourceTable.test.tsx"
]
},
{
diff --git a/frontend-modern/src/components/Alerts/AlertResourceGroupHeader.tsx b/frontend-modern/src/components/Alerts/AlertResourceGroupHeader.tsx
index c4c7459f9a..131614d4c4 100644
--- a/frontend-modern/src/components/Alerts/AlertResourceGroupHeader.tsx
+++ b/frontend-modern/src/components/Alerts/AlertResourceGroupHeader.tsx
@@ -1,6 +1,7 @@
import { Show } from 'solid-js';
import { GROUPED_TABLE_ROW_BADGE_CLASS } from '@/components/shared/groupedTableRowPresentation';
+import { WebInterfaceNameLink } from '@/components/shared/WebInterfaceNameLink';
import type { GroupHeaderMeta } from '@/features/alerts/thresholds/tableTypes';
interface AlertResourceGroupHeaderProps {
@@ -12,32 +13,17 @@ export function AlertResourceGroupHeader(props: AlertResourceGroupHeaderProps) {
const groupLabel = () => props.meta?.displayName || props.meta?.rawName || props.groupKey;
return (
- <Show
- when={props.meta?.type === 'agent'}
- fallback={<span>{groupLabel()}</span>}
- >
+ <Show when={props.meta?.type === 'agent'} fallback={<span>{groupLabel()}</span>}>
<div class="flex flex-wrap items-center gap-3">
- <Show
- when={props.meta?.host}
- fallback={<span>{groupLabel()}</span>}
- >
- {(host) => (
- <a
- href={host()}
- target="_blank"
- rel="noopener noreferrer"
- onClick={(e) => e.stopPropagation()}
- class="text-base-content transition-colors duration-150 hover:text-sky-600 dark:hover:text-sky-400"
- title={`Open ${groupLabel()} web interface`}
- >
- {groupLabel()}
- </a>
- )}
- </Show>
+ <WebInterfaceNameLink
+ name={groupLabel()}
+ url={props.meta?.host}
+ class="text-base-content transition-colors duration-150 hover:text-sky-600 dark:hover:text-sky-400"
+ fallbackClass=""
+ title={`Open ${groupLabel()} web interface`}
+ />
<Show when={props.meta?.clusterName}>
- <span class={GROUPED_TABLE_ROW_BADGE_CLASS}>
- {props.meta?.clusterName}
- </span>
+ <span class={GROUPED_TABLE_ROW_BADGE_CLASS}>{props.meta?.clusterName}</span>
</Show>
</div>
</Show>
diff --git a/frontend-modern/src/components/Alerts/AlertResourceTableRow.tsx b/frontend-modern/src/components/Alerts/AlertResourceTableRow.tsx
index d853e1643f..7764eacaa7 100644
--- a/frontend-modern/src/components/Alerts/AlertResourceTableRow.tsx
+++ b/frontend-modern/src/components/Alerts/AlertResourceTableRow.tsx
@@ -9,6 +9,7 @@ import { TogglePrimitive } from '@/components/shared/Toggle';
import { StatusBadge } from '@/components/shared/StatusBadge';
import { ThresholdSlider } from '@/components/Workloads/ThresholdSlider';
import { TableCell, TableRow } from '@/components/shared/Table';
+import { WebInterfaceNameLink } from '@/components/shared/WebInterfaceNameLink';
import { getPlatformTableCellClassForKind } from '@/features/platformPage/sharedPlatformPage';
import {
getAlertResourceTableCustomBadgeLabel,
@@ -260,33 +261,19 @@ export function AlertResourceTableRow(props: AlertResourceTableRowProps) {
}
>
<div class="flex items-center gap-3 min-w-0" title={props.resource.status || undefined}>
- <Show
- when={props.resource.host}
- fallback={
- <span
- class={`text-sm font-medium truncate flex-nowrap ${props.resource.disabled ? 'text-slate-500 ' : 'text-base-content'}`}
- >
- {resourceLabel()}
- </span>
- }
- >
- {(host) => (
- <a
- href={host() as string}
- target="_blank"
- rel="noopener noreferrer"
- onClick={(e) => e.stopPropagation()}
- class={`text-sm font-medium truncate flex-nowrap transition-colors duration-150 ${
- props.resource.disabled
- ? 'text-slate-500 '
- : 'text-base-content hover:text-sky-600 dark:hover:text-sky-400'
- }`}
- title={`Open ${resourceLabel()} web interface`}
- >
- {resourceLabel()}
- </a>
- )}
- </Show>
+ <WebInterfaceNameLink
+ name={resourceLabel()}
+ url={props.resource.host as string | null | undefined}
+ class={`text-sm font-medium truncate flex-nowrap transition-colors duration-150 ${
+ props.resource.disabled
+ ? 'text-slate-500 '
+ : 'text-base-content hover:text-sky-600 dark:hover:text-sky-400'
+ }`}
+ fallbackClass={`text-sm font-medium truncate flex-nowrap ${
+ props.resource.disabled ? 'text-slate-500 ' : 'text-base-content'
+ }`}
+ title={`Open ${resourceLabel()} web interface`}
+ />
<Show when={props.resource.clusterName}>
<span class="rounded px-2 py-0.5 text-[10px] font-medium whitespace-nowrap bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300">
{props.resource.clusterName}
diff --git a/frontend-modern/src/components/Alerts/ResourceTable.test.tsx b/frontend-modern/src/components/Alerts/ResourceTable.test.tsx
index 9fe26a6486..e8d117b585 100644
--- a/frontend-modern/src/components/Alerts/ResourceTable.test.tsx
+++ b/frontend-modern/src/components/Alerts/ResourceTable.test.tsx
@@ -324,11 +324,17 @@ describe('ResourceTable', () => {
expect(alertResourceTableMobileSource).not.toContain(['<', 'textarea'].join(''));
expect(alertResourceTableMobileSource).not.toContain(rawSvgTag);
expect(alertResourceGroupHeaderSource).toContain('export function AlertResourceGroupHeader');
+ expect(alertResourceGroupHeaderSource).toContain('WebInterfaceNameLink');
+ expect(alertResourceGroupHeaderSource).not.toContain('target="_blank"');
+ expect(alertResourceGroupHeaderSource).not.toContain('rel="noopener noreferrer"');
expect(alertResourceTableRowSource).toContain('export function AlertResourceTableRow');
expect(alertResourceTableRowSource).toContain('alertResourceSupportsMetric');
expect(alertResourceTableRowSource).toContain('FormTextarea');
expect(alertResourceTableRowSource).toContain('ActionIconButton');
+ expect(alertResourceTableRowSource).toContain('WebInterfaceNameLink');
expect(alertResourceTableRowSource).not.toContain(['<', 'textarea'].join(''));
+ expect(alertResourceTableRowSource).not.toContain('target="_blank"');
+ expect(alertResourceTableRowSource).not.toContain('rel="noopener noreferrer"');
expect(alertResourceTableRowSource).not.toContain(rawSvgTag);
expect(alertResourceTableStateSource).toContain('export function useAlertResourceTableState');
expect(alertResourceTableModelSource).toContain(
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index dc8c23ebef..9170821440 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -212,6 +212,7 @@ import alertHistoryTableGroupRowSource from '@/features/alerts/AlertHistoryTable
import alertResourceTableSource from '@/components/Alerts/ResourceTable.tsx?raw';
import alertResourceTableDesktopSource from '@/components/Alerts/AlertResourceTableDesktop.tsx?raw';
import alertResourceTableMobileSource from '@/components/Alerts/AlertResourceTableMobile.tsx?raw';
+import alertResourceGroupHeaderSource from '@/components/Alerts/AlertResourceGroupHeader.tsx?raw';
import alertResourceTableRowSource from '@/components/Alerts/AlertResourceTableRow.tsx?raw';
import aiCostDashboardSource from '@/components/AI/AICostDashboard.tsx?raw';
import resourceDetailSummarySource from '@/components/Infrastructure/ResourceDetailSummary.tsx?raw';
@@ -3902,6 +3903,8 @@ describe('shared primitive guardrails', () => {
'src/components/Workloads/GuestRow.tsx',
'src/features/standalone/AgentsMachinesTable.tsx',
'src/features/proxmox/ProxmoxNodesTable.tsx',
+ 'src/components/Alerts/AlertResourceGroupHeader.tsx',
+ 'src/components/Alerts/AlertResourceTableRow.tsx',
]),
);
@@ -3909,11 +3912,17 @@ describe('shared primitive guardrails', () => {
expect(guestRowSource).toContain('WebInterfaceNameLink');
expect(agentsMachinesTableSource).toContain('WebInterfaceNameLink');
expect(proxmoxNodesTableSource).toContain('WebInterfaceNameLink');
+ expect(alertResourceGroupHeaderSource).toContain('WebInterfaceNameLink');
+ expect(alertResourceTableRowSource).toContain('WebInterfaceNameLink');
expect(nodeGroupHeaderSource).not.toContain('target="_blank"');
expect(guestRowSource).not.toContain('target="_blank"');
expect(agentsMachinesTableSource).not.toContain('target="_blank"');
expect(proxmoxNodesTableSource).not.toContain('target="_blank"');
+ expect(alertResourceGroupHeaderSource).not.toContain('target="_blank"');
+ expect(alertResourceTableRowSource).not.toContain('target="_blank"');
expect(nodeGroupHeaderSource).not.toContain('rel="noopener noreferrer"');
+ expect(alertResourceGroupHeaderSource).not.toContain('rel="noopener noreferrer"');
+ expect(alertResourceTableRowSource).not.toContain('rel="noopener noreferrer"');
expect(agentsMachinesTableSource).not.toContain('AgentMachineWebLinkCell');
expect(agentsMachinesTableSource).not.toContain('data-agent-machine-web-link');
expect(proxmoxNodesTableSource).not.toContain('data-proxmox-host-web-link');
diff --git a/frontend-modern/src/components/shared/WebInterfaceNameLink.test.tsx b/frontend-modern/src/components/shared/WebInterfaceNameLink.test.tsx
new file mode 100644
index 0000000000..5e4d8ea9c6
--- /dev/null
+++ b/frontend-modern/src/components/shared/WebInterfaceNameLink.test.tsx
@@ -0,0 +1,50 @@
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+import { WebInterfaceNameLink } from './WebInterfaceNameLink';
+
+describe('WebInterfaceNameLink', () => {
+ afterEach(() => {
+ cleanup();
+ });
+
+ it('renders a safe web-interface launch link through the resource name', () => {
+ const onRowClick = vi.fn();
+
+ render(() => (
+ <div onClick={onRowClick}>
+ <WebInterfaceNameLink name="node-a" url="https://node-a.example.local:8006" />
+ </div>
+ ));
+
+ const link = screen.getByRole('link', { name: 'Open web interface for node-a' });
+
+ expect(link).toHaveAttribute('href', 'https://node-a.example.local:8006');
+ expect(link).toHaveAttribute('target', '_blank');
+ expect(link).toHaveAttribute('rel', 'noopener noreferrer');
+ expect(link).toHaveAttribute('title', 'Open https://node-a.example.local:8006');
+
+ fireEvent.click(link);
+
+ expect(onRowClick).not.toHaveBeenCalled();
+ });
+
+ it('falls back to inert resource text when no URL is available', () => {
+ render(() => (
+ <WebInterfaceNameLink
+ name="node-b"
+ url=" "
+ class="link-class"
+ fallbackClass="fallback-class"
+ />
+ ));
+
+ const fallback = screen.getByText('node-b');
+
+ expect(screen.queryByRole('link')).not.toBeInTheDocument();
+ expect(fallback.tagName).toBe('SPAN');
+ expect(fallback).toHaveClass('fallback-class');
+ expect(fallback).not.toHaveClass('link-class');
+ expect(fallback).toHaveAttribute('title', 'node-b');
+ });
+});