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
Make shared resource labels policy aware
rcourtmana682e9dfd70e
diff --git a/docs/release-control/v6/internal/subsystems/organization-settings.md b/docs/release-control/v6/internal/subsystems/organization-settings.mdindex fe0d35e5b1..5a75b6bdea 100644--- a/docs/release-control/v6/internal/subsystems/organization-settings.md+++ b/docs/release-control/v6/internal/subsystems/organization-settings.md@@ -102,3 +102,6 @@ settings surfaces. The organization settings panels now also normalize orgscope through `frontend-modern/src/utils/orgScope.ts` instead of carryingtheir own `getOrgID() || 'default'` fallbacks, so access, overview, andsharing views stay aligned with the shared multi-tenant org context contract.+The organization sharing surface now also sources resource quick-pick labels+from the shared policy-aware resource display helper, so governed resources do+not fall back to raw names inside share creation.diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.mdindex 0dd8795dd3..90594d0ebb 100644--- a/docs/release-control/v6/internal/subsystems/unified-resources.md+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md@@ -281,6 +281,9 @@ The shared frontend resource identity helper now inherits the same policy-awaredisplay contract, so other infrastructure surfaces that ask for the preferredresource label no longer need to re-encode the governed summary boundary byhand.+The generic frontend `getDisplayName` helper in `types/resource.ts` now+follows that same policy-aware boundary as well, so settings quick-picks and+other shared resource selectors do not keep a second raw-name fallback fork.That same contract also owns the canonical resource display-name fallback, soname-or-ID presentation stays consistent between the unified AI adapter, theAI resource context, and the connected-infrastructure / monitored-systemdiff --git a/frontend-modern/src/components/Settings/__tests__/OrganizationSharingPanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/OrganizationSharingPanel.test.tsxindex 6f8e700a77..c10d212e9d 100644--- a/frontend-modern/src/components/Settings/__tests__/OrganizationSharingPanel.test.tsx+++ b/frontend-modern/src/components/Settings/__tests__/OrganizationSharingPanel.test.tsx@@ -1,6 +1,6 @@import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';-import type { Resource } from '@/types/resource';+import { getDisplayName as getResourceDisplayName, type Resource } from '@/types/resource';import { OrganizationSharingPanel } from '../OrganizationSharingPanel';import organizationSharingPanelSource from '../OrganizationSharingPanel.tsx?raw';@@ -36,8 +36,7 @@ vi.mock('@/hooks/useResources', () => ({useResources: () => ({resources: () => mockResources,}),- getDisplayName: (resource: { displayName?: string; name?: string; id: string }) =>- resource.displayName || resource.name || resource.id,+ getDisplayName: (resource: Resource) => getResourceDisplayName(resource),}));vi.mock('@/stores/license', () => ({@@ -269,6 +268,43 @@ describe('OrganizationSharingPanel', () => {});});+ it('uses the governed resource label in quick-pick share payloads', async () => {+ mockResources = [+ makeResource({+ id: 'vm-200',+ name: 'secret-vm-200',+ displayName: 'secret-vm-200',+ policy: {+ sensitivity: 'restricted',+ routing: { scope: 'local-only', redact: ['hostname'] },+ },+ aiSafeSummary: 'Production VM',+ }),+ ];++ renderPanel();++ await waitFor(() => {+ expect(screen.getByRole('heading', { name: 'Create Share' })).toBeInTheDocument();+ });++ fireEvent.change(screen.getByLabelText('Quick Pick Resource'), {+ target: { value: 'vm::vm-200' },+ });++ fireEvent.click(screen.getByRole('button', { name: 'Create Share' }));++ await waitFor(() => {+ expect(createShareMock).toHaveBeenCalledWith('org-a', {+ targetOrgId: 'org-b',+ resourceType: 'vm',+ resourceId: 'vm-200',+ resourceName: 'Production VM',+ accessRole: 'viewer',+ });+ });+ });+it('normalizes org scope through the shared helper', () => {expect(organizationSharingPanelSource).toContain('normalizeOrgScope(getOrgID())');expect(organizationSharingPanelSource).not.toContain("getOrgID() || 'default'");diff --git a/frontend-modern/src/components/Settings/__tests__/ResourcePicker.test.tsx b/frontend-modern/src/components/Settings/__tests__/ResourcePicker.test.tsxindex 72a3045494..34bef310cd 100644--- a/frontend-modern/src/components/Settings/__tests__/ResourcePicker.test.tsx+++ b/frontend-modern/src/components/Settings/__tests__/ResourcePicker.test.tsx@@ -1,7 +1,7 @@import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';import { cleanup, fireEvent, render, screen, waitFor } from '@solidjs/testing-library';import { createSignal } from 'solid-js';-import type { Resource } from '@/types/resource';+import { getDisplayName as getResourceDisplayName, type Resource } from '@/types/resource';import { ResourcePicker, type SelectedResource } from '../ResourcePicker';let mockResources: Resource[] = [];@@ -11,8 +11,7 @@ vi.mock('@/hooks/useResources', () => ({useResources: () => ({resources: () => mockResources,}),- getDisplayName: (resource: { displayName?: string; name?: string; id: string }) =>- resource.displayName || resource.name || resource.id,+ getDisplayName: (resource: Resource) => getResourceDisplayName(resource),}));vi.mock('@/utils/toast', () => ({@@ -83,6 +82,28 @@ describe('ResourcePicker', () => {expect(screen.queryByText('TrueNAS')).not.toBeInTheDocument();});+ it('renders governed resources with the safe display label', async () => {+ mockResources = [+ makeResource({+ id: 'vm-2',+ type: 'vm',+ name: 'secret-vm-2',+ displayName: 'secret-vm-2',+ policy: {+ sensitivity: 'restricted',+ routing: { scope: 'local-only', redact: ['hostname'] },+ },+ aiSafeSummary: 'Production VM',+ status: 'running',+ }),+ ];++ renderPicker();++ expect(await screen.findByText('Production VM')).toBeInTheDocument();+ expect(screen.queryByText('secret-vm-2')).not.toBeInTheDocument();+ });+it('applies type filter buttons', async () => {mockResources = [makeResource({diff --git a/frontend-modern/src/types/__tests__/resource.test.ts b/frontend-modern/src/types/__tests__/resource.test.tsindex ea945a1bf2..e16d78946b 100644--- a/frontend-modern/src/types/__tests__/resource.test.ts+++ b/frontend-modern/src/types/__tests__/resource.test.ts@@ -108,6 +108,33 @@ describe('Resource Helper Functions', () => {(resource as any).displayName = undefined;expect(getDisplayName(resource)).toBe('machine-1');});++ it('returns the safe label for governed resources', () => {+ const resource = createResource({+ name: 'secret-vm-1',+ displayName: 'secret-vm-1',+ policy: {+ sensitivity: 'restricted',+ routing: { scope: 'local-only', redact: ['hostname'] },+ },+ aiSafeSummary: 'Production VM',+ } as Partial<Resource>);++ expect(getDisplayName(resource)).toBe('Production VM');+ });++ it('falls back to the redacted policy label when the safe summary is missing', () => {+ const resource = createResource({+ name: 'secret-vm-1',+ displayName: 'secret-vm-1',+ policy: {+ sensitivity: 'restricted',+ routing: { scope: 'local-only', redact: ['hostname'] },+ },+ } as Partial<Resource>);++ expect(getDisplayName(resource)).toBe('redacted by policy');+ });});describe('getCpuPercent', () => {diff --git a/frontend-modern/src/types/resource.ts b/frontend-modern/src/types/resource.tsindex d4747eae34..dfa66f4530 100644--- a/frontend-modern/src/types/resource.ts+++ b/frontend-modern/src/types/resource.ts@@ -136,6 +136,11 @@ export interface ResourcePolicy {routing: ResourceRoutingPolicy;}+export const requiresGovernedResourceDisplay = (policy?: ResourcePolicy | null): boolean => {+ if (!policy) return false;+ return policy.routing.scope === 'local-only' || (policy.routing.redact?.length ?? 0) > 0;+};+export type ResourceApprovalLevel = 'none' | 'dry_run_only' | 'admin' | 'mfa';export type ResourceChangeConfidence = 'high' | 'medium' | 'low';export type ResourceChangeKind =@@ -500,6 +505,9 @@ export interface ResourceFilter {* Helper to get effective display name*/export function getDisplayName(r: Resource): string {+ if (requiresGovernedResourceDisplay(r.policy)) {+ return r.aiSafeSummary?.trim() || 'redacted by policy';+ }return r.displayName || r.name;}diff --git a/frontend-modern/src/utils/resourceIdentity.ts b/frontend-modern/src/utils/resourceIdentity.tsindex 412d381d53..fe7f6bebbd 100644--- a/frontend-modern/src/utils/resourceIdentity.ts+++ b/frontend-modern/src/utils/resourceIdentity.ts@@ -1,10 +1,11 @@import type { Agent, Node } from '@/types/api';-import type { Resource, ResourceCanonicalIdentity } from '@/types/resource';-import type { NodeConfig } from '@/types/nodes';import {- getResourcePolicyDisplayLabel,requiresGovernedResourceDisplay,-} from '@/utils/resourcePolicyPresentation';+ type Resource,+ type ResourceCanonicalIdentity,+} from '@/types/resource';+import type { NodeConfig } from '@/types/nodes';+import { getResourcePolicyDisplayLabel } from '@/utils/resourcePolicyPresentation';import {getActionableAgentIdFromResource,getActionableDockerRuntimeIdFromResource,diff --git a/frontend-modern/src/utils/resourcePolicyPresentation.ts b/frontend-modern/src/utils/resourcePolicyPresentation.tsindex 12df5f45ef..e1e3caeca9 100644--- a/frontend-modern/src/utils/resourcePolicyPresentation.ts+++ b/frontend-modern/src/utils/resourcePolicyPresentation.ts@@ -5,6 +5,7 @@ import type {ResourceRoutingScope,ResourceSensitivity,} from '@/types/resource';+import { requiresGovernedResourceDisplay } from '@/types/resource';import type { IntelligencePolicyPostureSummary } from '@/types/aiIntelligence';type PolicyBadgePresentation = {@@ -119,11 +120,6 @@ export const getResourceRedactionHintLabel = (hint?: ResourceRedactionHint): strexport const getResourcePolicyRedactionLabels = (policy?: ResourcePolicy): string[] =>(policy?.routing.redact ?? []).map((hint) => getResourceRedactionHintLabel(hint));-export const requiresGovernedResourceDisplay = (policy?: ResourcePolicy | null): boolean => {- if (!policy) return false;- return policy.routing.scope === 'local-only' || (policy.routing.redact?.length ?? 0) > 0;-};-const buildCountSummaries = <T extends string>(counts: Partial<Record<T, number>> | undefined,order: readonly T[],