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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
Normalize PMG drawer tables
rcourtmanba896a53668b
diff --git a/frontend-modern/src/components/PMG/PMGInstanceDrawer.tsx b/frontend-modern/src/components/PMG/PMGInstanceDrawer.tsxindex d3e842bea5..e3a8ee0656 100644--- a/frontend-modern/src/components/PMG/PMGInstanceDrawer.tsx+++ b/frontend-modern/src/components/PMG/PMGInstanceDrawer.tsx@@ -12,6 +12,12 @@ import {TableCell,} from '@/components/shared/Table';import { EmptyState } from '@/components/shared/EmptyState';+import {+ PLATFORM_TABLE_BODY_CLASS,+ PLATFORM_TABLE_HEADER_ROW_CLASS,+ getPlatformTableCellClassForKind,+ getPlatformTableHeadClassForKind,+} from '@/features/platformPage/sharedPlatformPage';import { formatBytes, formatRelativeTime } from '@/utils/format';import { getServiceHealthPresentation } from '@/utils/serviceHealthPresentation';import { asTrimmedString } from '@/utils/stringUtils';@@ -201,8 +207,7 @@ export const PMGInstanceDrawer: Component<PMGInstanceDrawerProps> = (props) => {);const headingId = () => `pmg-drawer-heading-${resourceId() || 'instance'}`;- const drawerLabel = () =>- asTrimmedString(props.resourceName) || resourceId() || 'PMG instance';+ const drawerLabel = () => asTrimmedString(props.resourceName) || resourceId() || 'PMG instance';return (<section class="space-y-3" aria-labelledby={headingId()}>@@ -335,33 +340,56 @@ export const PMGInstanceDrawer: Component<PMGInstanceDrawerProps> = (props) => {<div class="text-xs font-semibold text-base-content">{drawerPresentation.nodesSectionTitle}</div>- <Table wrapperClass="mt-2" class="min-w-full text-xs">- <TableHeader class="text-[10px] uppercase tracking-wide text-muted">- <TableRow>- <TableHead class="text-left py-2 pr-3">+ <Table+ wrapperClass="mt-2"+ class="min-w-full table-fixed text-xs md:min-w-[560px]"+ >+ <TableHeader>+ <TableRow class={PLATFORM_TABLE_HEADER_ROW_CLASS}>+ <TableHead class={`${getPlatformTableHeadClassForKind('name')} md:w-[34%]`}>{drawerPresentation.nodeColumnLabel}</TableHead>- <TableHead class="text-left py-2 pr-3">+ <TableHead class={`${getPlatformTableHeadClassForKind('text')} md:w-[22%]`}>{drawerPresentation.roleColumnLabel}</TableHead>- <TableHead class="text-left py-2 pr-3">+ <TableHead class={`${getPlatformTableHeadClassForKind('text')} md:w-[22%]`}>{drawerPresentation.statusColumnLabel}</TableHead>- <TableHead class="text-right py-2 pl-3">+ <TableHead+ class={`${getPlatformTableHeadClassForKind('numeric-value')} md:w-[22%]`}+ >{drawerPresentation.queueColumnLabel}</TableHead></TableRow></TableHeader>- <TableBody class="divide-y divide-border-subtle">+ <TableBody class={PLATFORM_TABLE_BODY_CLASS}><For each={pmgData().nodes || []}>{(node) => (- <TableRow>- <TableCell class="py-2 pr-3 font-medium text-base-content">- {node.name}+ <TableRow class="text-[11px] sm:text-xs">+ <TableCell+ class={`${getPlatformTableCellClassForKind('name')} text-base-content`}+ >+ <span class="block truncate" title={node.name}>+ {node.name}+ </span>+ </TableCell>+ <TableCell+ class={`${getPlatformTableCellClassForKind('text')} text-muted`}+ >+ <span class="block truncate" title={node.role || '—'}>+ {node.role || '—'}+ </span></TableCell>- <TableCell class="py-2 pr-3 text-muted">{node.role || '—'}</TableCell>- <TableCell class="py-2 pr-3 text-muted">{node.status || '—'}</TableCell>- <TableCell class="py-2 pl-3 text-right text-muted">+ <TableCell+ class={`${getPlatformTableCellClassForKind('text')} text-muted`}+ >+ <span class="block truncate" title={node.status || '—'}>+ {node.status || '—'}+ </span>+ </TableCell>+ <TableCell+ class={`${getPlatformTableCellClassForKind('numeric-value')} text-muted tabular-nums`}+ >{formatCompact(node.queueStatus?.total ?? 0)}</TableCell></TableRow>@@ -386,25 +414,38 @@ export const PMGInstanceDrawer: Component<PMGInstanceDrawerProps> = (props) => {inputClass="py-1 text-xs"/></div>- <Table wrapperClass="mt-2" class="min-w-full text-xs">- <TableHeader class="text-[10px] uppercase tracking-wide text-muted">- <TableRow>- <TableHead class="text-left py-2 pr-3">+ <Table+ wrapperClass="mt-2"+ class="min-w-full table-fixed text-xs md:min-w-[520px]"+ >+ <TableHeader>+ <TableRow class={PLATFORM_TABLE_HEADER_ROW_CLASS}>+ <TableHead class={`${getPlatformTableHeadClassForKind('name')} md:w-[45%]`}>{drawerPresentation.domainColumnLabel}</TableHead>- <TableHead class="text-left py-2 pr-3">+ <TableHead class={`${getPlatformTableHeadClassForKind('text')} md:w-[55%]`}>{drawerPresentation.commentColumnLabel}</TableHead></TableRow></TableHeader>- <TableBody class="divide-y divide-border-subtle">+ <TableBody class={PLATFORM_TABLE_BODY_CLASS}><For each={relayDomains()}>{(row) => (- <TableRow>- <TableCell class="py-2 pr-3 font-medium text-base-content">- {row.domain}+ <TableRow class="text-[11px] sm:text-xs">+ <TableCell+ class={`${getPlatformTableCellClassForKind('name')} text-base-content`}+ >+ <span class="block truncate" title={row.domain}>+ {row.domain}+ </span>+ </TableCell>+ <TableCell+ class={`${getPlatformTableCellClassForKind('text')} text-muted`}+ >+ <span class="block truncate" title={row.comment || '—'}>+ {row.comment || '—'}+ </span></TableCell>- <TableCell class="py-2 pr-3 text-muted">{row.comment || '—'}</TableCell></TableRow>)}</For>@@ -434,43 +475,66 @@ export const PMGInstanceDrawer: Component<PMGInstanceDrawerProps> = (props) => {inputClass="py-1 text-xs"/></div>- <Table wrapperClass="mt-2" class="min-w-full text-xs">- <TableHeader class="text-[10px] uppercase tracking-wide text-muted">- <TableRow>- <TableHead class="text-left py-2 pr-3">+ <Table+ wrapperClass="mt-2"+ class="min-w-full table-fixed text-xs md:min-w-[720px]"+ >+ <TableHeader>+ <TableRow class={PLATFORM_TABLE_HEADER_ROW_CLASS}>+ <TableHead class={`${getPlatformTableHeadClassForKind('name')} md:w-[36%]`}>{drawerPresentation.domainColumnLabel}</TableHead>- <TableHead class="text-right py-2 pl-3">+ <TableHead+ class={`${getPlatformTableHeadClassForKind('numeric-value')} md:w-[16%]`}+ >{drawerPresentation.mailColumnLabel}</TableHead>- <TableHead class="text-right py-2 pl-3">+ <TableHead+ class={`${getPlatformTableHeadClassForKind('numeric-value')} md:w-[16%]`}+ >{drawerPresentation.spamColumnLabel}</TableHead>- <TableHead class="text-right py-2 pl-3">+ <TableHead+ class={`${getPlatformTableHeadClassForKind('numeric-value')} md:w-[16%]`}+ >{drawerPresentation.virusColumnLabel}</TableHead>- <TableHead class="text-right py-2 pl-3">+ <TableHead+ class={`${getPlatformTableHeadClassForKind('numeric-value')} md:w-[16%]`}+ >{drawerPresentation.bytesColumnLabel}</TableHead></TableRow></TableHeader>- <TableBody class="divide-y divide-border-subtle">+ <TableBody class={PLATFORM_TABLE_BODY_CLASS}><For each={domainStats()}>{(row) => (- <TableRow>- <TableCell class="py-2 pr-3 font-medium text-base-content">- {row.domain}+ <TableRow class="text-[11px] sm:text-xs">+ <TableCell+ class={`${getPlatformTableCellClassForKind('name')} text-base-content`}+ >+ <span class="block truncate" title={row.domain}>+ {row.domain}+ </span></TableCell>- <TableCell class="py-2 pl-3 text-right text-muted">+ <TableCell+ class={`${getPlatformTableCellClassForKind('numeric-value')} text-muted tabular-nums`}+ >{formatCompact(row.mailCount)}</TableCell>- <TableCell class="py-2 pl-3 text-right text-muted">+ <TableCell+ class={`${getPlatformTableCellClassForKind('numeric-value')} text-muted tabular-nums`}+ >{formatCompact(row.spamCount)}</TableCell>- <TableCell class="py-2 pl-3 text-right text-muted">+ <TableCell+ class={`${getPlatformTableCellClassForKind('numeric-value')} text-muted tabular-nums`}+ >{formatCompact(row.virusCount)}</TableCell>- <TableCell class="py-2 pl-3 text-right text-muted">+ <TableCell+ class={`${getPlatformTableCellClassForKind('numeric-value')} text-muted tabular-nums`}+ >{row.bytes ? formatBytes(row.bytes) : '—'}</TableCell></TableRow>diff --git a/frontend-modern/src/components/PMG/__tests__/PMGInstanceDrawer.test.tsx b/frontend-modern/src/components/PMG/__tests__/PMGInstanceDrawer.test.tsxnew file mode 100644index 0000000000..cdf5e616c5--- /dev/null+++ b/frontend-modern/src/components/PMG/__tests__/PMGInstanceDrawer.test.tsx@@ -0,0 +1,73 @@+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import { cleanup, render, screen, waitFor } from '@solidjs/testing-library';++const apiFetchJSONMock = vi.fn();++vi.mock('@/utils/apiClient', () => ({+ apiFetchJSON: (...args: unknown[]) => apiFetchJSONMock(...args),+}));++import { PMGInstanceDrawer } from '@/components/PMG/PMGInstanceDrawer';++describe('PMGInstanceDrawer', () => {+ beforeEach(() => {+ apiFetchJSONMock.mockReset();+ });++ afterEach(() => {+ cleanup();+ });++ it('uses the shared platform table spacing and divider contract for detail tables', async () => {+ apiFetchJSONMock.mockResolvedValueOnce({+ id: 'pmg-1',+ type: 'pmg',+ name: 'mail-gateway',+ pmg: {+ hostname: 'mail-gateway.local',+ version: '8.1.0',+ nodes: [+ {+ name: 'mail-node-a',+ role: 'master',+ status: 'online',+ queueStatus: { total: 12 },+ },+ ],+ relayDomains: [{ domain: 'example.com', comment: 'primary' }],+ domainStats: [+ {+ domain: 'example.com',+ mailCount: 128,+ spamCount: 4,+ virusCount: 1,+ bytes: 4096,+ },+ ],+ },+ });++ const { container } = render(() => (+ <PMGInstanceDrawer resourceId="pmg-1" resourceName="Mail Gateway" />+ ));++ await waitFor(() => {+ expect(screen.getByText('mail-node-a')).toBeInTheDocument();+ expect(screen.getAllByText('example.com').length).toBeGreaterThan(0);+ });++ expect(apiFetchJSONMock).toHaveBeenCalledWith('/api/resources/pmg-1', {+ cache: 'no-store',+ });++ const tables = Array.from(container.querySelectorAll('table'));+ expect(tables).toHaveLength(3);+ for (const table of tables) {+ expect(table).toHaveClass('table-fixed');+ expect(table.querySelector('thead tr')).toHaveClass('bg-surface-alt');+ expect(table.querySelector('tbody')).toHaveClass('divide-y', 'divide-border');+ expect(table.querySelector('tbody')).not.toHaveClass('divide-border-subtle');+ expect(table.querySelector('th')).toHaveClass('px-1.5', 'py-0.5');+ }+ });+});diff --git a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.tsindex 55f02bc3f8..9f6c95bc59 100644--- a/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts+++ b/frontend-modern/src/utils/__tests__/frontendResourceTypeBoundaries.test.ts@@ -3257,6 +3257,11 @@ describe('frontend resource type boundaries', () => {expect(pmgInstanceDrawerSource).toContain('PMG_DETAILS_LOADING_STATE_DESCRIPTION');expect(pmgInstanceDrawerSource).toContain('PMG_DETAILS_FAILURE_STATE_TITLE');expect(pmgInstanceDrawerSource).toMatch(/<Table(?:\s|>)/);+ expect(pmgInstanceDrawerSource).toContain('PLATFORM_TABLE_HEADER_ROW_CLASS');+ expect(pmgInstanceDrawerSource).toContain('PLATFORM_TABLE_BODY_CLASS');+ expect(pmgInstanceDrawerSource).toContain('getPlatformTableHeadClassForKind');+ expect(pmgInstanceDrawerSource).toContain('getPlatformTableCellClassForKind');+ expect(pmgInstanceDrawerSource).not.toContain('divide-y divide-border-subtle');expect(pmgInstanceDrawerSource).not.toContain('<div class="mt-2 overflow-x-auto">');expect(mailGatewaySource).not.toContain('<div class="overflow-x-auto -mx-4 px-4">');expect(mailGatewaySource).not.toContain('wrapperClass="-mx-4 px-4"');