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.

Remove infrastructure inline sizing from live demo

rcourtman96ecd93ce9b3
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 80d54fc896..c56b63071a 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -1258,6 +1258,16 @@ styling. `TableHeader` and `TableBody` may provide canonical default borders
and dividers, but when a caller supplies explicit border or divide classes the
shared primitive must defer to that local contract instead of silently forcing
the default separator treatment back into the rendered DOM.
+That same shared table boundary now owns CSP-safe sizing for infrastructure
+tables and metric bars. `frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts`
+and `frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts`
+must express table layout and column sizing as shared class/attribute
+presentation instead of inline `style=` maps, and
+`frontend-modern/src/components/shared/ProgressBar.tsx` must render fill width
+through DOM attributes rather than inline width styles. Infrastructure host and
+service tables may still vary by breakpoint and column family, but they must do
+so through the shared presentation owner instead of lane-local style objects
+that break the public demo CSP.
That same shared-boundary rule applies to summary density. The shared compact
mode on `SummaryPanel.tsx` and `SummaryMetricCard.tsx` exists for genuinely
dense monitoring surfaces, but pages that are trying to align with the normal
diff --git a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
index b409af838a..6194e7868e 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -662,6 +662,14 @@ and viewport-sync plus selected-row reveal behavior now live in
so future hot-path table-state changes must not fold selector derivation,
layout policy, and scroll coordination back into one mixed owner or the render
shell.
+That same hot-path boundary now also owns CSP-safe table sizing. Infrastructure
+host, PBS, and PMG table shells must take their layout and column sizing from
+the shared presentation owner in
+`frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts`
+and apply those values through classes and width/height attributes, not inline
+`style=` maps on the live table DOM. Future hot-path table work must not
+reintroduce inline width, min/max width, or row-height styles into the render
+shell just to land a local layout tweak.
That hot-path contract now includes policy badge rendering on resource rows.
The infrastructure summary hot path is now explicit shared ownership too:
`InfrastructureSummary.tsx` stays a render shell,
@@ -687,6 +695,11 @@ forking separate table-only presentation logic. That component now also
consumes the shared `frontend-modern/src/utils/resourceChangePresentation.ts`
label helper for canonical change kinds, source types, and adapter provenance
so the chip wording stays consistent without adding extra hot-path branching.
+The same infrastructure hot path now also depends on the shared
+`frontend-modern/src/components/shared/ProgressBar.tsx` primitive for metric
+fill rendering. Performance-sensitive metric bars may vary by value and color,
+but they must render width through shared attribute-driven progress geometry
+instead of per-row inline width styles that break the hosted demo CSP.
The default table hot path now scopes those summary chips to timeline and
change-provenance badges only. Generic capability and relationship badges are
removed from the default row surface entirely until the underlying data is
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 5996b266df..a191bdb8da 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -826,6 +826,12 @@ and viewport reveal plus scroll synchronization now route through
`frontend-modern/src/components/Infrastructure/useUnifiedResourceTableViewportSync.ts`,
so the shared consumer model is no longer interleaving selector derivation,
layout policy, and DOM viewport coordination inside one mixed state boundary.
+That same unified-resource consumer contract now also owns CSP-safe table
+presentation for infrastructure rows. Host, PBS, and PMG table sections must
+consume the shared column presentation owner and render canonical table sizing
+through classes plus DOM width/height attributes rather than lane-local inline
+style objects, so the same unified-resource dataset can reach the public demo
+without transport-specific DOM drift.
The canonical unified-resource change and relationship presenters now also
share the same elapsed-time and "ago" wording utilities, so `observed`,
`last seen`, and `ago` fragments stay consistent without each formatter
diff --git a/frontend-modern/src/components/Dashboard/MetricBar.test.tsx b/frontend-modern/src/components/Dashboard/MetricBar.test.tsx
index c9f637d367..773e633db0 100644
--- a/frontend-modern/src/components/Dashboard/MetricBar.test.tsx
+++ b/frontend-modern/src/components/Dashboard/MetricBar.test.tsx
@@ -31,8 +31,9 @@ describe('MetricBar', () => {
expect(screen.getByText('50%')).toBeInTheDocument();
const textEl = screen.getByText('50%');
const container = textEl.closest('.relative') as HTMLElement;
- const bar = container.firstElementChild as HTMLElement;
- expect(bar).toHaveStyle({ width: '50%' });
+ const fill = container.querySelector('[data-progress-fill="true"]');
+ expect(fill).toHaveAttribute('width', '50');
+ expect(container.querySelector('[style]')).toBeNull();
});
it('renders correct color classes for CPU', () => {
diff --git a/frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx b/frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx
index 7161ad5cc8..43de79001c 100644
--- a/frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx
+++ b/frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx
@@ -66,71 +66,73 @@ export const UnifiedResourceHostTableCard: Component<UnifiedResourceHostTableCar
onClear={tableProps.clearPinnedSummaryScope}
/>
<div class="overflow-x-auto">
- <Table
- class="whitespace-nowrap min-w-[max-content]"
- style={{
- 'table-layout': 'fixed',
- 'min-width': table.isMobile() ? '100%' : 'max-content',
- }}
- >
+ <Table class={`whitespace-nowrap ${table.tableShellClass()}`}>
<TableHeader>
<TableRow class="bg-surface-alt text-muted border-b border-border">
<TableHead
- class="text-left pl-2 sm:pl-3"
- style={table.resourceColumnStyle()}
+ class={`text-left pl-2 sm:pl-3 ${table.resourceColumn().className}`}
+ width={table.resourceColumn().width}
onClick={() => table.handleSort('name')}
>
Resource {table.renderSortIndicator('name')}
</TableHead>
<TableHead
- style={table.metricColumnStyle()}
+ class={table.metricColumn().className}
+ width={table.metricColumn().width}
onClick={() => table.handleSort('cpu')}
>
CPU {table.renderSortIndicator('cpu')}
</TableHead>
<TableHead
- style={table.metricColumnStyle()}
+ class={table.metricColumn().className}
+ width={table.metricColumn().width}
onClick={() => table.handleSort('memory')}
>
Memory {table.renderSortIndicator('memory')}
</TableHead>
<TableHead
- style={table.metricColumnStyle()}
+ class={table.metricColumn().className}
+ width={table.metricColumn().width}
onClick={() => table.handleSort('disk')}
>
Disk {table.renderSortIndicator('disk')}
</TableHead>
<TableHead
classList={{ hidden: table.isMobile() || !table.isVisible('secondary') }}
- style={table.ioColumnStyle()}
+ class={table.ioColumn().className}
+ width={table.ioColumn().width}
onClick={() => table.handleSort('network')}
>
Net I/O {table.renderSortIndicator('network')}
</TableHead>
<TableHead
classList={{ hidden: table.isMobile() || !table.isVisible('supplementary') }}
- style={table.ioColumnStyle()}
+ class={table.ioColumn().className}
+ width={table.ioColumn().width}
onClick={() => table.handleSort('diskio')}
>
Disk I/O {table.renderSortIndicator('diskio')}
</TableHead>
<TableHead
classList={{ hidden: table.isMobile() || !table.isVisible('secondary') }}
- style={table.sourceColumnStyle()}
+ class={table.sourceColumn().className}
+ width={table.sourceColumn().width}
onClick={() => table.handleSort('source')}
>
Source {table.renderSortIndicator('source')}
</TableHead>
<TableHead
classList={{ hidden: table.isMobile() || !table.isVisible('supplementary') }}
- style={table.uptimeColumnStyle()}
+ class={table.uptimeColumn().className}
+ width={table.uptimeColumn().width}
onClick={() => table.handleSort('uptime')}
>
Uptime {table.renderSortIndicator('uptime')}
</TableHead>
<TableHead
classList={{ hidden: table.isMobile() || !table.isVisible('supplementary') }}
- style={table.tempColumnStyle()}
+ class={table.tempColumn().className}
+ width={table.tempColumn().width}
onClick={() => table.handleSort('temp')}
>
Temp {table.renderSortIndicator('temp')}
@@ -142,11 +144,8 @@ export const UnifiedResourceHostTableCard: Component<UnifiedResourceHostTableCar
<TableRow aria-hidden="true">
<TableCell
colspan={9}
- style={{
- height: `${table.hostTopSpacerHeight()}px`,
- padding: '0',
- border: '0',
- }}
+ class="border-0 p-0"
+ height={table.hostTopSpacerHeight()}
/>
</TableRow>
</Show>
@@ -328,8 +327,7 @@ export const UnifiedResourceHostTableCard: Component<UnifiedResourceHostTableCar
? 'true'
: 'false'
}
- class={rowClass()}
- style={{ 'min-height': '32px' }}
+ class={`${rowClass()} h-8`}
onClick={() => table.toggleExpand(resource.id)}
{...resourceRowInteraction}
>
@@ -669,11 +667,8 @@ export const UnifiedResourceHostTableCard: Component<UnifiedResourceHostTableCar
<TableRow aria-hidden="true">
<TableCell
colspan={9}
- style={{
- height: `${table.hostBottomSpacerHeight()}px`,
- padding: '0',
- border: '0',
- }}
+ class="border-0 p-0"
+ height={table.hostBottomSpacerHeight()}
/>
</TableRow>
</Show>
diff --git a/frontend-modern/src/components/Infrastructure/UnifiedResourcePBSTableSection.tsx b/frontend-modern/src/components/Infrastructure/UnifiedResourcePBSTableSection.tsx
index 6a5225e863..a93307d562 100644
--- a/frontend-modern/src/components/Infrastructure/UnifiedResourcePBSTableSection.tsx
+++ b/frontend-modern/src/components/Infrastructure/UnifiedResourcePBSTableSection.tsx
@@ -48,45 +48,56 @@ export const UnifiedResourcePBSTableSection: Component<UnifiedResourcePBSTableSe
<div class="border-b border-border bg-surface-hover px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted">
PBS Services
</div>
- <div class="overflow-x-auto">
- <Table
- class="whitespace-nowrap min-w-[max-content]"
- style={{
- 'table-layout': 'fixed',
- 'min-width': table.isMobile() ? '100%' : 'max-content',
- }}
- >
+ <div class="overflow-x-auto">
+ <Table class={`whitespace-nowrap ${table.tableShellClass()}`}>
<TableHeader>
<TableRow class="bg-surface-alt text-muted border-b border-border">
- <TableHead class="text-left pl-2 sm:pl-3" style={table.resourceColumnStyle()}>
+ <TableHead
+ class={`text-left pl-2 sm:pl-3 ${table.resourceColumn().className}`}
+ width={table.resourceColumn().width}
+ >
Resource
</TableHead>
<TableHead
classList={{ hidden: !table.isVisible('primary') && !table.isMobile() }}
- style={table.serviceCountColumnStyle()}
+ class={table.serviceCountColumn().className}
+ width={table.serviceCountColumn().width}
>
Datastores
</TableHead>
<TableHead
classList={{ hidden: !table.isVisible('secondary') && !table.isMobile() }}
- style={table.serviceCountColumnStyle()}
+ class={table.serviceCountColumn().className}
+ width={table.serviceCountColumn().width}
>
Jobs
</TableHead>
- <TableHead style={table.serviceHealthColumnStyle()}>Health</TableHead>
+ <TableHead
+ class={table.serviceHealthColumn().className}
+ width={table.serviceHealthColumn().width}
+ >
+ Health
+ </TableHead>
<TableHead
classList={{ hidden: !table.isVisible('secondary') && !table.isMobile() }}
- style={table.sourceColumnStyle()}
+ class={table.sourceColumn().className}
+ width={table.sourceColumn().width}
>
Source
</TableHead>
<TableHead
classList={{ hidden: !table.isVisible('supplementary') && !table.isMobile() }}
- style={table.uptimeColumnStyle()}
+ class={table.uptimeColumn().className}
+ width={table.uptimeColumn().width}
>
Uptime
</TableHead>
- <TableHead style={table.serviceActionColumnStyle()}>Action</TableHead>
+ <TableHead
+ class={table.serviceActionColumn().className}
+ width={table.serviceActionColumn().width}
+ >
+ Action
+ </TableHead>
</TableRow>
</TableHeader>
<TableBody>
@@ -151,8 +162,7 @@ export const UnifiedResourcePBSTableSection: Component<UnifiedResourcePBSTableSe
? 'true'
: 'false'
}
- class={rowClass()}
- style={{ 'min-height': '32px' }}
+ class={`${rowClass()} h-8`}
onClick={() => table.toggleExpand(resource.id)}
{...resourceRowInteraction}
>
diff --git a/frontend-modern/src/components/Infrastructure/UnifiedResourcePMGTableSection.tsx b/frontend-modern/src/components/Infrastructure/UnifiedResourcePMGTableSection.tsx
index 6d0b796d71..af660e4d49 100644
--- a/frontend-modern/src/components/Infrastructure/UnifiedResourcePMGTableSection.tsx
+++ b/frontend-modern/src/components/Infrastructure/UnifiedResourcePMGTableSection.tsx
@@ -48,57 +48,70 @@ export const UnifiedResourcePMGTableSection: Component<UnifiedResourcePMGTableSe
<div class="border-b border-border bg-surface-hover px-3 py-2 text-[11px] font-semibold uppercase tracking-wide text-muted">
PMG Services
</div>
- <div class="overflow-x-auto">
- <Table
- class="whitespace-nowrap min-w-[max-content]"
- style={{
- 'table-layout': 'fixed',
- 'min-width': table.isMobile() ? '100%' : 'max-content',
- }}
- >
+ <div class="overflow-x-auto">
+ <Table class={`whitespace-nowrap ${table.tableShellClass()}`}>
<TableHeader>
<TableRow class="bg-surface-alt text-muted border-b border-border">
- <TableHead class="text-left pl-2 sm:pl-3" style={table.resourceColumnStyle()}>
+ <TableHead
+ class={`text-left pl-2 sm:pl-3 ${table.resourceColumn().className}`}
+ width={table.resourceColumn().width}
+ >
Resource
</TableHead>
<TableHead
classList={{ hidden: !table.isVisible('primary') && !table.isMobile() }}
- style={table.serviceQueueColumnStyle()}
+ class={table.serviceQueueColumn().className}
+ width={table.serviceQueueColumn().width}
>
Queue
</TableHead>
<TableHead
classList={{ hidden: !table.isVisible('secondary') && !table.isMobile() }}
- style={table.serviceQueueColumnStyle()}
+ class={table.serviceQueueColumn().className}
+ width={table.serviceQueueColumn().width}
>
Deferred
</TableHead>
<TableHead
classList={{ hidden: !table.isVisible('supplementary') && !table.isMobile() }}
- style={table.serviceQueueColumnStyle()}
+ class={table.serviceQueueColumn().className}
+ width={table.serviceQueueColumn().width}
>
Hold
</TableHead>
<TableHead
classList={{ hidden: !table.isVisible('secondary') && !table.isMobile() }}
- style={table.serviceCountColumnStyle()}
+ class={table.serviceCountColumn().className}
+ width={table.serviceCountColumn().width}
>
Nodes
</TableHead>
- <TableHead style={table.serviceHealthColumnStyle()}>Health</TableHead>
+ <TableHead
+ class={table.serviceHealthColumn().className}
+ width={table.serviceHealthColumn().width}
+ >
+ Health
+ </TableHead>
<TableHead
classList={{ hidden: !table.isVisible('secondary') && !table.isMobile() }}
- style={table.sourceColumnStyle()}
+ class={table.sourceColumn().className}
+ width={table.sourceColumn().width}
>
Source
</TableHead>
<TableHead
classList={{ hidden: !table.isVisible('supplementary') && !table.isMobile() }}
- style={table.uptimeColumnStyle()}
+ class={table.uptimeColumn().className}
+ width={table.uptimeColumn().width}
>
Uptime
</TableHead>
- <TableHead style={table.serviceActionColumnStyle()}>Action</TableHead>
+ <TableHead
+ class={table.serviceActionColumn().className}
+ width={table.serviceActionColumn().width}
+ >
+ Action
+ </TableHead>
</TableRow>
</TableHeader>
<TableBody>
@@ -168,8 +181,7 @@ export const UnifiedResourcePMGTableSection: Component<UnifiedResourcePMGTableSe
? 'true'
: 'false'
}
- class={rowClass()}
- style={{ 'min-height': '32px' }}
+ class={`${rowClass()} h-8`}
onClick={() => table.toggleExpand(resource.id)}
{...resourceRowInteraction}
>
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
index 32152ffcb3..b6015b7cf7 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
+++ b/frontend-modern/src/components/Infrastructure/__tests__/UnifiedResourceTable.performance.contract.test.tsx
@@ -154,6 +154,29 @@ describe('UnifiedResourceTable performance contract', () => {
});
});
+ it('keeps the infrastructure table shell CSP-safe without inline style attributes', async () => {
+ const resources = [
+ makeResource(1),
+ makeResource(2, { type: 'pbs', platformType: 'proxmox-pbs' }),
+ makeResource(3, { type: 'pmg', platformType: 'proxmox-pmg' }),
+ ];
+
+ const { container } = render(() => (
+ <UnifiedResourceTable
+ resources={resources}
+ expandedResourceId={null}
+ onExpandedResourceChange={vi.fn()}
+ groupingMode="flat"
+ />
+ ));
+
+ await waitFor(() => {
+ expect(container.querySelector('table')).toBeInTheDocument();
+ });
+
+ expect(container.querySelector('[style]')).toBeNull();
+ });
+
it('renders the shared facet summary component in timeline-only mode for canonical resource counts', async () => {
const { getByText, queryByText } = render(() => (
<ResourceFacetSummary
@@ -207,13 +230,17 @@ describe('UnifiedResourceTable performance contract', () => {
expect(unifiedResourceTableSource).not.toContain('const getPBSTableRow =');
expect(unifiedResourceTableStateSource).toContain("from './unifiedResourceTableStateModel'");
expect(unifiedResourceTableStateSource).toContain('buildHostTableItems');
- expect(unifiedResourceTableStateSource).toContain('getUnifiedResourceTableColumnStyles');
+ expect(unifiedResourceTableStateSource).toContain('getUnifiedResourceTableColumnPresentations');
+ expect(unifiedResourceTableStateSource).toContain('getUnifiedResourceTableShellClass');
expect(unifiedResourceTableStateSource).toContain('useTableWindowing');
expect(unifiedResourceTableStateSource).toContain('useUnifiedResourceTableViewportSync');
expect(unifiedResourceTableStateSource).toContain('clearPinnedSummaryScope?: () => void;');
expect(unifiedResourceTableStateSource).toContain('showHostClearAction');
expect(unifiedResourceTableStateSource).toContain('showServiceClearAction');
expect(unifiedResourceTableStateSource).not.toContain('const resourceColumnStyle = createMemo(() =>');
+ expect(unifiedResourceHostTableCardSource).not.toContain('style={');
+ expect(unifiedResourcePBSTableSectionSource).not.toContain('style={');
+ expect(unifiedResourcePMGTableSectionSource).not.toContain('style={');
expect(unifiedResourceTableStateSource).not.toContain("const showGroupHeaders = props.groupingMode === 'grouped'");
expect(unifiedResourceTableStateSource).not.toContain('const items: HostTableItem[] = [];');
expect(unifiedResourceTableStateSource).not.toContain('window.addEventListener');
@@ -227,7 +254,10 @@ describe('UnifiedResourceTable performance contract', () => {
expect(unifiedResourceTableModelSource).toContain('export const getOutlierEmphasis');
expect(unifiedResourceTableStateModelSource).toContain('export const buildHostTableItems');
expect(unifiedResourceTableStateModelSource).toContain(
- 'export const getUnifiedResourceTableColumnStyles',
+ 'export const getUnifiedResourceTableColumnPresentations',
+ );
+ expect(unifiedResourceTableStateModelSource).toContain(
+ 'export const getUnifiedResourceTableShellClass',
);
expect(unifiedResourceTableStateModelSource).toContain(
'export const getNextUnifiedResourceTableSortState',
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/unifiedResourceTableStateModel.test.ts b/frontend-modern/src/components/Infrastructure/__tests__/unifiedResourceTableStateModel.test.ts
index 47b5c55286..4d18900b03 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/unifiedResourceTableStateModel.test.ts
+++ b/frontend-modern/src/components/Infrastructure/__tests__/unifiedResourceTableStateModel.test.ts
@@ -8,7 +8,8 @@ import {
getHostRevealTargetIndex,
getHostSpacerHeights,
getNextUnifiedResourceTableSortState,
- getUnifiedResourceTableColumnStyles,
+ getUnifiedResourceTableColumnPresentations,
+ getUnifiedResourceTableShellClass,
getUnifiedResourceTableSortIndicator,
getUnifiedSources,
getVisibleHostTableItems,
@@ -103,12 +104,16 @@ describe('unifiedResourceTableStateModel', () => {
expect(getUnifiedResourceTableSortIndicator('default', 'asc', 'cpu')).toBeNull();
});
- it('derives responsive column styles and host-table visibility as pure layout policy', () => {
- const mobileStyles = getUnifiedResourceTableColumnStyles(true);
- const desktopStyles = getUnifiedResourceTableColumnStyles(false);
+ it('derives responsive column presentations and host-table visibility as pure layout policy', () => {
+ const mobileColumns = getUnifiedResourceTableColumnPresentations(true);
+ const desktopColumns = getUnifiedResourceTableColumnPresentations(false);
- expect(mobileStyles.resourceColumnStyle.width).toBe('100%');
- expect(desktopStyles.resourceColumnStyle['min-width']).toBe('220px');
+ expect(getUnifiedResourceTableShellClass(true)).toContain('table-fixed');
+ expect(getUnifiedResourceTableShellClass(false)).toContain('min-w-[max-content]');
+ expect(mobileColumns.resourceColumn.width).toBe('100%');
+ expect(mobileColumns.metricColumn.width).toBe(70);
+ expect(desktopColumns.resourceColumn.className).toContain('min-w-[220px]');
+ expect(desktopColumns.ioColumn.width).toBe(160);
expect(shouldShowUnifiedResourceHostTable(0, 0)).toBe(true);
expect(shouldShowUnifiedResourceHostTable(0, 2)).toBe(false);
expect(shouldShowUnifiedResourceHostTable(3, 2)).toBe(true);
diff --git a/frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts b/frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts
index 8d14f8351f..c7812d05bd 100644
--- a/frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts
+++ b/frontend-modern/src/components/Infrastructure/unifiedResourceTableStateModel.ts
@@ -160,50 +160,66 @@ export const getUnifiedSources = (resource: Resource): string[] => {
return platformData?.sources ?? [];
};
-type UnifiedResourceTableColumnStyle = Record<string, string>;
-
-export type UnifiedResourceTableColumnStyles = {
- resourceColumnStyle: UnifiedResourceTableColumnStyle;
- metricColumnStyle: UnifiedResourceTableColumnStyle;
- ioColumnStyle: UnifiedResourceTableColumnStyle;
- sourceColumnStyle: UnifiedResourceTableColumnStyle;
- uptimeColumnStyle: UnifiedResourceTableColumnStyle;
- tempColumnStyle: UnifiedResourceTableColumnStyle;
- serviceCountColumnStyle: UnifiedResourceTableColumnStyle;
- serviceQueueColumnStyle: UnifiedResourceTableColumnStyle;
- serviceHealthColumnStyle: UnifiedResourceTableColumnStyle;
- serviceActionColumnStyle: UnifiedResourceTableColumnStyle;
+export interface UnifiedResourceTableColumnPresentation {
+ className: string;
+ width?: string | number;
+}
+
+export type UnifiedResourceTableColumnPresentations = {
+ resourceColumn: UnifiedResourceTableColumnPresentation;
+ metricColumn: UnifiedResourceTableColumnPresentation;
+ ioColumn: UnifiedResourceTableColumnPresentation;
+ sourceColumn: UnifiedResourceTableColumnPresentation;
+ uptimeColumn: UnifiedResourceTableColumnPresentation;
+ tempColumn: UnifiedResourceTableColumnPresentation;
+ serviceCountColumn: UnifiedResourceTableColumnPresentation;
+ serviceQueueColumn: UnifiedResourceTableColumnPresentation;
+ serviceHealthColumn: UnifiedResourceTableColumnPresentation;
+ serviceActionColumn: UnifiedResourceTableColumnPresentation;
};
-export const getUnifiedResourceTableColumnStyles = (
+const buildUnifiedResourceTableColumnPresentation = (
+ className: string,
+ width?: string | number,
+): UnifiedResourceTableColumnPresentation => ({
+ className,
+ width,
+});
+
+export const getUnifiedResourceTableShellClass = (isMobile: boolean): string =>
+ `table-fixed ${isMobile ? 'min-w-full' : 'min-w-[max-content]'}`;
+
+export const getUnifiedResourceTableColumnPresentations = (
isMobile: boolean,
-): UnifiedResourceTableColumnStyles => ({
- resourceColumnStyle: isMobile ? { width: '100%', 'min-width': '120px' } : { 'min-width': '220px' },
- metricColumnStyle: isMobile
- ? { width: '70px', 'min-width': '65px' }
- : { 'min-width': '140px', 'max-width': '180px' },
- ioColumnStyle: isMobile
- ? { width: '180px', 'min-width': '180px' }
- : { width: '160px', 'min-width': '160px', 'max-width': '180px' },
- sourceColumnStyle: isMobile
- ? { width: '140px', 'min-width': '140px' }
- : { width: '160px', 'min-width': '160px' },
- uptimeColumnStyle: isMobile
- ? { width: '70px', 'min-width': '70px', 'max-width': '80px' }
- : { width: '80px', 'min-width': '80px', 'max-width': '80px' },
- tempColumnStyle: isMobile
- ? { width: '50px', 'min-width': '50px', 'max-width': '60px' }
- : { width: '60px', 'min-width': '60px', 'max-width': '70px' },
- serviceCountColumnStyle: isMobile
- ? { width: '80px', 'min-width': '80px', 'max-width': '90px' }
- : { width: '110px', 'min-width': '110px', 'max-width': '130px' },
- serviceQueueColumnStyle: isMobile
- ? { width: '88px', 'min-width': '88px', 'max-width': '104px' }
- : { width: '120px', 'min-width': '120px', 'max-width': '140px' },
- serviceHealthColumnStyle: isMobile
- ? { width: '100px', 'min-width': '100px', 'max-width': '120px' }
- : { width: '140px', 'min-width': '140px', 'max-width': '170px' },
- serviceActionColumnStyle: isMobile
- ? { width: '82px', 'min-width': '82px', 'max-width': '96px' }
- : { width: '120px', 'min-width': '120px', 'max-width': '140px' },
+): UnifiedResourceTableColumnPresentations => ({
+ resourceColumn: isMobile
+ ? buildUnifiedResourceTableColumnPresentation('w-full min-w-[120px]', '100%')
+ : buildUnifiedResourceTableColumnPresentation('min-w-[220px]'),
+ metricColumn: isMobile
+ ? buildUnifiedResourceTableColumnPresentation('min-w-[65px]', 70)
+ : buildUnifiedResourceTableColumnPresentation('min-w-[140px] max-w-[180px]'),
+ ioColumn: isMobile
+ ? buildUnifiedResourceTableColumnPresentation('min-w-[180px]', 180)
+ : buildUnifiedResourceTableColumnPresentation('min-w-[160px] max-w-[180px]', 160),
+ sourceColumn: isMobile
+ ? buildUnifiedResourceTableColumnPresentation('min-w-[140px]', 140)
+ : buildUnifiedResourceTableColumnPresentation('min-w-[160px]', 160),
+ uptimeColumn: isMobile
+ ? buildUnifiedResourceTableColumnPresentation('min-w-[70px] max-w-[80px]', 70)
+ : buildUnifiedResourceTableColumnPresentation('min-w-[80px] max-w-[80px]', 80),
+ tempColumn: isMobile
+ ? buildUnifiedResourceTableColumnPresentation('min-w-[50px] max-w-[60px]', 50)
+ : buildUnifiedResourceTableColumnPresentation('min-w-[60px] max-w-[70px]', 60),
+ serviceCountColumn: isMobile
+ ? buildUnifiedResourceTableColumnPresentation('min-w-[80px] max-w-[90px]', 80)
+ : buildUnifiedResourceTableColumnPresentation('min-w-[110px] max-w-[130px]', 110),
+ serviceQueueColumn: isMobile
+ ? buildUnifiedResourceTableColumnPresentation('min-w-[88px] max-w-[104px]', 88)
+ : buildUnifiedResourceTableColumnPresentation('min-w-[120px] max-w-[140px]', 120),
+ serviceHealthColumn: isMobile
+ ? buildUnifiedResourceTableColumnPresentation('min-w-[100px] max-w-[120px]', 100)
+ : buildUnifiedResourceTableColumnPresentation('min-w-[140px] max-w-[170px]', 140),
+ serviceActionColumn: isMobile
+ ? buildUnifiedResourceTableColumnPresentation('min-w-[82px] max-w-[96px]', 82)
+ : buildUnifiedResourceTableColumnPresentation('min-w-[120px] max-w-[140px]', 120),
});
diff --git a/frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts b/frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts
index 959e092a76..2dcfda1b59 100644
--- a/frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts
+++ b/frontend-modern/src/components/Infrastructure/useUnifiedResourceTableState.ts
@@ -18,7 +18,8 @@ import {
getHostRevealTargetIndex,
getHostSpacerHeights,
getNextUnifiedResourceTableSortState,
- getUnifiedResourceTableColumnStyles,
+ getUnifiedResourceTableColumnPresentations,
+ getUnifiedResourceTableShellClass,
getUnifiedResourceTableSortIndicator,
getUnifiedSources,
getVisibleHostTableItems,
@@ -129,7 +130,8 @@ export function useUnifiedResourceTableState(props: UnifiedResourceTableProps) {
props.onExpandedResourceChange(props.expandedResourceId === resourceId ? null : resourceId);
};
- const columnStyles = createMemo(() => getUnifiedResourceTableColumnStyles(isMobile()));
+ const tableShellClass = createMemo(() => getUnifiedResourceTableShellClass(isMobile()));
+ const columnPresentations = createMemo(() => getUnifiedResourceTableColumnPresentations(isMobile()));
const showHostTable = createMemo(() =>
shouldShowUnifiedResourceHostTable(primaryResources().length, serviceResources().length),
);
@@ -157,19 +159,20 @@ export function useUnifiedResourceTableState(props: UnifiedResourceTableProps) {
sortedPMGResources,
ioScale,
...viewportSync,
- resourceColumnStyle: () => columnStyles().resourceColumnStyle,
- metricColumnStyle: () => columnStyles().metricColumnStyle,
- ioColumnStyle: () => columnStyles().ioColumnStyle,
- sourceColumnStyle: () => columnStyles().sourceColumnStyle,
- uptimeColumnStyle: () => columnStyles().uptimeColumnStyle,
- tempColumnStyle: () => columnStyles().tempColumnStyle,
+ tableShellClass,
+ resourceColumn: () => columnPresentations().resourceColumn,
+ metricColumn: () => columnPresentations().metricColumn,
+ ioColumn: () => columnPresentations().ioColumn,
+ sourceColumn: () => columnPresentations().sourceColumn,
+ uptimeColumn: () => columnPresentations().uptimeColumn,
+ tempColumn: () => columnPresentations().tempColumn,
showHostTable,
showHostClearAction,
showServiceClearAction,
- serviceCountColumnStyle: () => columnStyles().serviceCountColumnStyle,
- serviceQueueColumnStyle: () => columnStyles().serviceQueueColumnStyle,
- serviceHealthColumnStyle: () => columnStyles().serviceHealthColumnStyle,
- serviceActionColumnStyle: () => columnStyles().serviceActionColumnStyle,
+ serviceCountColumn: () => columnPresentations().serviceCountColumn,
+ serviceQueueColumn: () => columnPresentations().serviceQueueColumn,
+ serviceHealthColumn: () => columnPresentations().serviceHealthColumn,
+ serviceActionColumn: () => columnPresentations().serviceActionColumn,
toggleExpand,
buildHostSummaryGroupScope: buildInfrastructureSummaryGroupScope,
getUnifiedSources,
diff --git a/frontend-modern/src/components/shared/ProgressBar.tsx b/frontend-modern/src/components/shared/ProgressBar.tsx
index ca1897416d..183483c70d 100644
--- a/frontend-modern/src/components/shared/ProgressBar.tsx
+++ b/frontend-modern/src/components/shared/ProgressBar.tsx
@@ -16,7 +16,7 @@ const clampPercent = (value: number): number => {
};
export const ProgressBar: Component<ProgressBarProps> = (props) => {
- const width = () => `${clampPercent(props.value)}%`;
+ const width = () => clampPercent(props.value);
return (
<div
@@ -24,10 +24,16 @@ export const ProgressBar: Component<ProgressBarProps> = (props) => {
onMouseEnter={props.onMouseEnter}
onMouseLeave={props.onMouseLeave}
>
- <div
- class={`progress-fill absolute inset-y-0 left-0 ${props.fillClass ?? ''}`}
- style={{ width: width() }}
- />
+ <svg
+ class="absolute inset-0 h-full w-full overflow-visible pointer-events-none"
+ viewBox="0 0 100 100"
+ preserveAspectRatio="none"
+ aria-hidden="true"
+ >
+ <foreignObject data-progress-fill="true" x="0" y="0" width={width()} height="100">
+ <div class={`progress-fill h-full w-full ${props.fillClass ?? ''}`} />
+ </foreignObject>
+ </svg>
{props.overlays}
{props.label}
</div>
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index 9b552c2693..fad8e1880c 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -34,6 +34,7 @@ import mobileNavBarModelSource from '@/components/shared/mobileNavBarModel.ts?ra
import infrastructureSelectorSource from '@/components/shared/InfrastructureSelector.tsx?raw';
import pulseDataGridSource from '@/components/shared/PulseDataGrid.tsx?raw';
import pulseDataGridModelSource from '@/components/shared/pulseDataGridModel.ts?raw';
+import progressBarSource from '@/components/shared/ProgressBar.tsx?raw';
import whatsNewModalSource from '@/components/shared/WhatsNewModal.tsx?raw';
import whatsNewModalModelSource from '@/components/shared/whatsNewModalModel.ts?raw';
import searchFieldSource from '@/components/shared/SearchField.tsx?raw';
@@ -1054,6 +1055,13 @@ describe('shared primitive guardrails', () => {
expect(pulseDataGridModelSource).toContain('target.closest(');
});
+ it('keeps progress bars CSP-safe in the shared primitive owner', () => {
+ expect(progressBarSource).toContain('data-progress-fill');
+ expect(progressBarSource).toContain('foreignObject');
+ expect(progressBarSource).not.toContain('style={{');
+ expect(progressBarSource).not.toContain('style={');
+ });
+
it('keeps search field on shell, runtime, and model owners', () => {
expect(searchFieldSource).toContain('useSearchFieldState');
expect(searchFieldSource).not.toContain('let inputEl: HTMLInputElement');
diff --git a/frontend-modern/src/components/shared/Table.tsx b/frontend-modern/src/components/shared/Table.tsx
index f216b2c586..91ae8ff9b3 100644
--- a/frontend-modern/src/components/shared/Table.tsx
+++ b/frontend-modern/src/components/shared/Table.tsx
@@ -94,6 +94,7 @@ export function TableHead(props: TableHeadProps) {
export type TableCellProps = JSX.HTMLAttributes<HTMLTableCellElement> & {
colSpan?: number;
colspan?: number;
+ height?: string | number;
width?: string | number;
};
diff --git a/frontend-modern/src/components/shared/__tests__/PulseDataGrid.test.tsx b/frontend-modern/src/components/shared/__tests__/PulseDataGrid.test.tsx
index 93e293c058..7af2800045 100644
--- a/frontend-modern/src/components/shared/__tests__/PulseDataGrid.test.tsx
+++ b/frontend-modern/src/components/shared/__tests__/PulseDataGrid.test.tsx
@@ -5,6 +5,7 @@ import pulseDataGridSource from '@/components/shared/PulseDataGrid.tsx?raw';
import pulseDataGridModelSource from '@/components/shared/pulseDataGridModel.ts?raw';
import pulseDataGridStateSource from '@/components/shared/usePulseDataGridState.ts?raw';
import { PulseDataGrid } from '@/components/shared/PulseDataGrid';
+import { TableCell } from '@/components/shared/Table';
import tableSource from '@/components/shared/Table.tsx?raw';
type TestRow = {
@@ -41,10 +42,28 @@ describe('PulseDataGrid', () => {
expect(tableSource).toContain('customDividePattern');
expect(tableSource).toContain('customBorderPattern');
expect(tableSource).toContain('touch-scroll');
+ expect(tableSource).toContain('height?: string | number;');
expect(tableSource).not.toContain('style={{');
expect(tableSource).not.toContain('style={');
});
+ it('preserves caller-owned table cell height attributes without inline styles', () => {
+ render(() => (
+ <table>
+ <tbody>
+ <tr>
+ <TableCell height={64}>spacer</TableCell>
+ </tr>
+ </tbody>
+ </table>
+ ));
+
+ const cell = screen.getByText('spacer').closest('td');
+ expect(cell).not.toBeNull();
+ expect(cell).toHaveAttribute('height', '64');
+ expect(cell).not.toHaveAttribute('style');
+ });
+
it('triggers the row handler when a non-interactive cell is clicked', () => {
const onRowClick = vi.fn();
diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
index 4bd7eea813..9225987d2e 100644
--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts
@@ -3269,7 +3269,8 @@ describe('frontend resource type boundaries', () => {
expect(unifiedResourceTableStateSource).toContain('export function useUnifiedResourceTableState');
expect(unifiedResourceTableStateSource).toContain("from './unifiedResourceTableStateModel'");
expect(unifiedResourceTableStateSource).toContain('buildHostTableItems');
- expect(unifiedResourceTableStateSource).toContain('getUnifiedResourceTableColumnStyles');
+ expect(unifiedResourceTableStateSource).toContain('getUnifiedResourceTableColumnPresentations');
+ expect(unifiedResourceTableStateSource).toContain('getUnifiedResourceTableShellClass');
expect(unifiedResourceTableStateSource).toContain('useTableWindowing');
expect(unifiedResourceTableStateSource).toContain('useUnifiedResourceTableViewportSync');
expect(unifiedResourceTableStateSource).not.toContain('const resourceColumnStyle = createMemo(() =>');
@@ -3279,7 +3280,10 @@ describe('frontend resource type boundaries', () => {
expect(unifiedResourceTableStateSource).not.toContain('getBoundingClientRect');
expect(unifiedResourceTableStateModelSource).toContain('export const buildHostTableItems');
expect(unifiedResourceTableStateModelSource).toContain(
- 'export const getUnifiedResourceTableColumnStyles',
+ 'export const getUnifiedResourceTableColumnPresentations',
+ );
+ expect(unifiedResourceTableStateModelSource).toContain(
+ 'export const getUnifiedResourceTableShellClass',
);
expect(unifiedResourceTableStateModelSource).toContain(
'export const getNextUnifiedResourceTableSortState',