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.

Honor reporting catalog capability flags

rcourtmanb9af6861fe06
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index f8ee159735..605e45cd38 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -227,6 +227,10 @@ export is intentionally not comment-prefixed like the legacy metrics CSV, and
it now carries Proxmox pool membership from the canonical unified VM runtime
model instead of inferring or reconstructing that field locally inside the
frontend or handler.
+That same catalog payload also owns the optional performance-report capability
+surface: `supportsMetricFilter` and `supportsCustomTitle` are contract flags,
+not UI hints, so frontend consumers and request builders must not render or
+emit unsupported metric-filter or custom-title fields from local assumptions.
The `/api/resources` serializer now also refreshes canonical identity and
policy metadata through the shared unified-resource helper before it writes
the payload, so backend and frontend contract tests stay aligned on one
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 1e40c9382f..f1a799d6a3 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -186,6 +186,12 @@ selection cap for performance reports. `ReportingPanel.tsx` and
`ResourcePicker.tsx` may present or enforce that limit, but they must receive
it from the backend-owned `multiResourceMax` definition rather than hardcoding
the reporting cap in frontend-local constants.
+That same catalog-owned capability contract also governs which optional
+performance-report controls appear at all. The settings shell and reporting
+request builder may not assume metric filtering or custom titles are always
+available; they must honor `supportsMetricFilter` and `supportsCustomTitle`
+from the backend catalog and avoid emitting unsupported controls or request
+parameters from frontend-local defaults.
The shared updates settings owner also defines the user-facing framing for
rc-tagged builds. `frontend-modern/src/components/Settings/updatesSettingsModel.ts`
and `frontend-modern/src/utils/updatesPresentation.ts` must present that
diff --git a/frontend-modern/src/components/Settings/ReportingPanel.tsx b/frontend-modern/src/components/Settings/ReportingPanel.tsx
index 44cf25ce7b..7e7adc71b7 100644
--- a/frontend-modern/src/components/Settings/ReportingPanel.tsx
+++ b/frontend-modern/src/components/Settings/ReportingPanel.tsx
@@ -69,6 +69,12 @@ export function ReportingPanel() {
const performanceReport = () => reportingCatalog()?.performanceReport ?? null;
const inventoryDefinition = () => reportingCatalog()?.vmInventoryExport ?? null;
+ const supportsMetricFilter = () => performanceReport()?.supportsMetricFilter ?? false;
+ const supportsCustomTitle = () => performanceReport()?.supportsCustomTitle ?? false;
+ const optionalFieldCount = () =>
+ Number(supportsMetricFilter()) + Number(supportsCustomTitle());
+ const optionalFieldGridClass = () =>
+ optionalFieldCount() > 1 ? 'grid grid-cols-1 gap-6 md:grid-cols-2' : 'grid grid-cols-1 gap-6';
const rangeFilterOptions = (): FilterOption<ReportingRangeValue>[] =>
(performanceReport()?.ranges ?? []).map((option) => ({
@@ -169,32 +175,38 @@ export function ReportingPanel() {
/>
</FormField>
- <div class="grid grid-cols-1 gap-6 md:grid-cols-2">
- <FormField
- label="Metric Type (Optional)"
- helpText="Filter by specific metric type"
- >
- <input
- id="metric-type"
- type="text"
- class={formControl}
- placeholder="e.g. cpu, memory, disk, temperature (leave empty for all)"
- value={metricType()}
- onInput={(e) => setMetricType(e.currentTarget.value)}
- />
- </FormField>
+ <Show when={optionalFieldCount() > 0}>
+ <div class={optionalFieldGridClass()}>
+ <Show when={supportsMetricFilter()}>
+ <FormField
+ label="Metric Type (Optional)"
+ helpText="Filter by specific metric type"
+ >
+ <input
+ id="metric-type"
+ type="text"
+ class={formControl}
+ placeholder="e.g. cpu, memory, disk, temperature (leave empty for all)"
+ value={metricType()}
+ onInput={(e) => setMetricType(e.currentTarget.value)}
+ />
+ </FormField>
+ </Show>
- <FormField label="Report Title" helpText="Custom title for the PDF report">
- <input
- id="report-title"
- type="text"
- class={formControl}
- placeholder="Auto-generated if empty"
- value={title()}
- onInput={(e) => setTitle(e.currentTarget.value)}
- />
- </FormField>
- </div>
+ <Show when={supportsCustomTitle()}>
+ <FormField label="Report Title" helpText="Custom title for the PDF report">
+ <input
+ id="report-title"
+ type="text"
+ class={formControl}
+ placeholder="Auto-generated if empty"
+ value={title()}
+ onInput={(e) => setTitle(e.currentTarget.value)}
+ />
+ </FormField>
+ </Show>
+ </div>
+ </Show>
<div class="grid grid-cols-1 gap-6 md:grid-cols-2">
<FormField label="Time Range">
diff --git a/frontend-modern/src/components/Settings/__tests__/ReportingPanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/ReportingPanel.test.tsx
new file mode 100644
index 0000000000..f06bcb4d19
--- /dev/null
+++ b/frontend-modern/src/components/Settings/__tests__/ReportingPanel.test.tsx
@@ -0,0 +1,129 @@
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { cleanup, render, screen } from '@solidjs/testing-library';
+import { ReportingPanel } from '../ReportingPanel';
+import type { JSX } from 'solid-js';
+
+const useReportingPanelStateMock = vi.fn();
+
+vi.mock('@/components/Settings/useReportingPanelState', () => ({
+ useReportingPanelState: () => useReportingPanelStateMock(),
+}));
+
+vi.mock('../ResourcePicker', () => ({
+ ResourcePicker: (_props: { maxSelection?: number; selected: () => unknown[]; onSelectionChange: (items: unknown[]) => void }): JSX.Element => (
+ <div>Mock Resource Picker</div>
+ ),
+}));
+
+vi.mock('@/utils/upgradeMetrics', () => ({
+ trackUpgradeClicked: vi.fn(),
+}));
+
+const baseCatalog = {
+ id: 'advanced_reporting',
+ title: 'Detailed Reporting',
+ description: 'Canonical reporting surfaces',
+ performanceReport: {
+ id: 'performance_reports',
+ title: 'Performance Reports',
+ description: 'Historical performance reporting',
+ singleResourceEndpoint: '/api/admin/reports/generate',
+ multiResourceEndpoint: '/api/admin/reports/generate-multi',
+ singleFilenamePrefix: 'report',
+ multiFilenamePrefix: 'fleet-report',
+ formats: [
+ { value: 'pdf', label: 'PDF Report' },
+ { value: 'csv', label: 'CSV Data' },
+ ],
+ defaultFormat: 'pdf' as const,
+ ranges: [
+ {
+ key: '24h',
+ label: 'Last 24 Hours',
+ description: 'Daily review',
+ windowHours: 24,
+ },
+ ],
+ defaultRange: '24h',
+ multiResourceMax: 50,
+ supportsMetricFilter: true,
+ supportsCustomTitle: true,
+ },
+ vmInventoryExport: {
+ id: 'vm_inventory',
+ title: 'VM Inventory Export',
+ description: 'Current-state inventory',
+ format: 'csv' as const,
+ exportEndpoint: '/api/admin/reports/inventory/vms/export',
+ filenamePrefix: 'vm-inventory',
+ columns: [],
+ },
+};
+
+function buildState(overrides: Record<string, unknown> = {}) {
+ return {
+ canStartTrial: () => false,
+ exportingInventory: () => false,
+ format: () => 'pdf' as const,
+ handleExportVMInventory: vi.fn(),
+ generating: () => false,
+ handleGenerate: vi.fn(),
+ handleStartTrial: vi.fn(),
+ isLocked: () => false,
+ isReportingEnabled: () => true,
+ metricType: () => '',
+ range: () => '24h',
+ reportingCatalog: () => baseCatalog,
+ reportingCatalogError: () => '',
+ reportingCatalogLoading: () => false,
+ selectedResources: () => [],
+ setFormat: vi.fn(),
+ setMetricType: vi.fn(),
+ setRange: vi.fn(),
+ setSelectedResources: vi.fn(),
+ setTitle: vi.fn(),
+ startingTrial: () => false,
+ title: () => '',
+ upgradeActionUrl: () => '/pricing',
+ ...overrides,
+ };
+}
+
+describe('ReportingPanel', () => {
+ beforeEach(() => {
+ useReportingPanelStateMock.mockReset();
+ });
+
+ afterEach(() => {
+ cleanup();
+ });
+
+ it('shows metric filter and custom title controls when the catalog supports them', () => {
+ useReportingPanelStateMock.mockReturnValue(buildState());
+
+ render(() => <ReportingPanel />);
+
+ expect(screen.getByText('Metric Type (Optional)')).toBeInTheDocument();
+ expect(screen.getByText('Report Title')).toBeInTheDocument();
+ });
+
+ it('hides unsupported optional controls from the reporting surface', () => {
+ useReportingPanelStateMock.mockReturnValue(
+ buildState({
+ reportingCatalog: () => ({
+ ...baseCatalog,
+ performanceReport: {
+ ...baseCatalog.performanceReport,
+ supportsMetricFilter: false,
+ supportsCustomTitle: false,
+ },
+ }),
+ }),
+ );
+
+ render(() => <ReportingPanel />);
+
+ expect(screen.queryByLabelText('Metric Type (Optional)')).not.toBeInTheDocument();
+ expect(screen.queryByLabelText('Report Title')).not.toBeInTheDocument();
+ });
+});
diff --git a/frontend-modern/src/components/Settings/__tests__/reportingPanelModel.test.ts b/frontend-modern/src/components/Settings/__tests__/reportingPanelModel.test.ts
index ac8e62930c..46a3f80850 100644
--- a/frontend-modern/src/components/Settings/__tests__/reportingPanelModel.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/reportingPanelModel.test.ts
@@ -121,6 +121,38 @@ describe('reporting panel model', () => {
);
});
+ it('omits unsupported metric filters and custom titles from the request contract', () => {
+ const now = new Date('2026-03-20T12:34:56.000Z');
+ const resources: SelectedResource[] = [
+ {
+ id: 'vm-1',
+ type: 'vm',
+ name: 'vm-a',
+ },
+ ];
+
+ const request = buildReportingRequest(
+ {
+ end: now.toISOString(),
+ format: 'pdf',
+ metricType: 'cpu',
+ now,
+ resources,
+ start: '2026-03-19T12:34:56.000Z',
+ title: 'Custom fleet title',
+ },
+ {
+ ...performanceDefinition,
+ supportsMetricFilter: false,
+ supportsCustomTitle: false,
+ },
+ );
+
+ expect(request.request.url).toContain('title=Pulse+Report+-+vm-a');
+ expect(request.request.url).not.toContain('metricType=');
+ expect(request.request.url).not.toContain('Custom+fleet+title');
+ });
+
it('derives canonical range starts from the selected preset', () => {
const now = new Date('2026-03-20T12:00:00.000Z');
diff --git a/frontend-modern/src/components/Settings/reportingPanelModel.ts b/frontend-modern/src/components/Settings/reportingPanelModel.ts
index ba1cdc5de0..e3c53bc5b7 100644
--- a/frontend-modern/src/components/Settings/reportingPanelModel.ts
+++ b/frontend-modern/src/components/Settings/reportingPanelModel.ts
@@ -71,9 +71,18 @@ export function buildReportingRequest(
context: ReportingRequestContext,
definition?: Pick<
ReportingPerformanceReportDefinition,
- 'multiFilenamePrefix' | 'multiResourceEndpoint' | 'singleFilenamePrefix' | 'singleResourceEndpoint'
+ | 'multiFilenamePrefix'
+ | 'multiResourceEndpoint'
+ | 'singleFilenamePrefix'
+ | 'singleResourceEndpoint'
+ | 'supportsCustomTitle'
+ | 'supportsMetricFilter'
> | null,
): ReportingRequestDefinition {
+ const metricType =
+ definition?.supportsMetricFilter === false ? '' : context.metricType.trim();
+ const customTitle = definition?.supportsCustomTitle === false ? '' : context.title.trim();
+
if (context.resources.length === 1) {
const resource = context.resources[0];
const params = new URLSearchParams({
@@ -82,11 +91,11 @@ export function buildReportingRequest(
format: context.format,
start: context.start,
end: context.end,
- title: buildSingleReportTitle(context.title, resource.name),
+ title: buildSingleReportTitle(customTitle, resource.name),
});
- if (context.metricType) {
- params.append('metricType', context.metricType);
+ if (metricType) {
+ params.append('metricType', metricType);
}
return {
@@ -112,8 +121,8 @@ export function buildReportingRequest(
format: context.format,
start: context.start,
end: context.end,
- title: buildFleetReportTitle(context.title),
- metricType: context.metricType || undefined,
+ title: buildFleetReportTitle(customTitle),
+ metricType: metricType || undefined,
}),
},
},
diff --git a/frontend-modern/src/utils/__tests__/reportingPresentation.test.ts b/frontend-modern/src/utils/__tests__/reportingPresentation.test.ts
index e4ec79dd62..96e8e596d7 100644
--- a/frontend-modern/src/utils/__tests__/reportingPresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/reportingPresentation.test.ts
@@ -4,18 +4,9 @@ import {
getReportingGenerateErrorMessage,
getReportingGenerateSelectionRequiredMessage,
getReportingGenerateSuccessMessage,
- REPORTING_RANGE_OPTIONS,
} from '@/utils/reportingPresentation';
describe('reportingPresentation', () => {
- it('returns canonical reporting range options', () => {
- expect(REPORTING_RANGE_OPTIONS).toEqual([
- { value: '24h', label: 'Last 24 Hours' },
- { value: '7d', label: 'Last 7 Days' },
- { value: '30d', label: 'Last 30 Days' },
- ]);
- });
-
it('returns canonical reporting status copy', () => {
expect(getReportingGenerateSelectionRequiredMessage()).toBe(
'Please select at least one resource',
diff --git a/frontend-modern/src/utils/reportingPresentation.ts b/frontend-modern/src/utils/reportingPresentation.ts
index 9cc52d5b78..d6c97bc406 100644
--- a/frontend-modern/src/utils/reportingPresentation.ts
+++ b/frontend-modern/src/utils/reportingPresentation.ts
@@ -1,14 +1,3 @@
-export interface ReportingRangeOption {
- value: '24h' | '7d' | '30d';
- label: string;
-}
-
-export const REPORTING_RANGE_OPTIONS: readonly ReportingRangeOption[] = [
- { value: '24h', label: 'Last 24 Hours' },
- { value: '7d', label: 'Last 7 Days' },
- { value: '30d', label: 'Last 30 Days' },
-];
-
export function getReportingGenerateSelectionRequiredMessage(): string {
return 'Please select at least one resource';
}