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.

Revert "fix(frontend): add global pinned resource context"

rcourtman5aba213be49b
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index 1d68cd10ad..01d3209991 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -507,12 +507,6 @@ theme synchronization, and authenticated runtime startup, and
as org switching and kiosk-safe navigation. Future hosted browser bootstrap
work must extend that split rather than pulling org bootstrap and app chrome
back into one monolithic route component.
-That same authenticated shell split now also owns deliberate global
-resource-context bootstrap. `frontend-modern/src/App.tsx` may install the
-shared provider, and `frontend-modern/src/AppLayout.tsx` may surface and carry
-one shell-level `contextResource` state across tabs, but hosted shell work
-must not fork page-local global-context banners, drop shell context on tab
-changes, or entangle pinned resource scope with tenant/org bootstrap.
That same authenticated shell contract now also has to distinguish backend
availability from websocket-stream liveness. When hosted runtime health stays
available during a stream reconnect or renegotiation window,
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 8051ddb71f..b7a87b7d79 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -133,10 +133,6 @@ work extends shared components instead of creating new local variants.
111. `frontend-modern/src/components/shared/summaryScopePresentation.ts`
112. `frontend-modern/src/components/shared/summaryInteractionA11y.ts`
113. `frontend-modern/src/components/shared/SummaryRowActionButton.tsx`
-114. `frontend-modern/src/features/globalResourceContext/GlobalResourceContext.tsx`
-115. `frontend-modern/src/features/globalResourceContext/GlobalResourceContextBar.tsx`
-116. `frontend-modern/src/features/globalResourceContext/globalResourceContextModel.ts`
-117. `frontend-modern/src/features/globalResourceContext/__tests__/globalResourceContextModel.test.ts`
## Shared Boundaries
@@ -342,19 +338,6 @@ connections` visible as the API-backed alternative for Proxmox and
props that can collapse functions on the live Solid surface. Docker-only
controls in `ThresholdsTableDockerTab.tsx` must remain gated to real
`docker-host` resources instead of leaking onto platform-managed runtimes.
-31. Keep deliberate cross-page resource scope on one shell-owned context
- contract. Hover preview and page-local group scope must stay local to the
- active surface, but an explicitly pinned resource may promote into the
- shared app-shell `contextResource` route state through
- `frontend-modern/src/features/globalResourceContext/GlobalResourceContext.tsx`,
- `frontend-modern/src/features/globalResourceContext/globalResourceContextModel.ts`,
- `frontend-modern/src/features/globalResourceContext/GlobalResourceContextBar.tsx`,
- `frontend-modern/src/AppLayout.tsx`, and
- `frontend-modern/src/routing/resourceLinks.ts`. That shell-owned context
- must render once in shared chrome, survive tab navigation, refresh,
- copy-paste, and back/forward navigation, and clear through one canonical
- action instead of reviving per-page scope badges, page-local query names,
- or hidden route-only filters.
## Current State
@@ -377,16 +360,6 @@ The subsystem registry now also requires explicit proof-policy coverage for all
shared runtime files, and shared-component guardrails fail if raw table
composition is reintroduced in new shared components outside the canonical
allowlist.
-The app shell now also owns one explicit global pinned-resource context.
-`frontend-modern/src/features/globalResourceContext/GlobalResourceContext.tsx`,
-`frontend-modern/src/features/globalResourceContext/GlobalResourceContextBar.tsx`,
-`frontend-modern/src/features/globalResourceContext/globalResourceContextModel.ts`,
-`frontend-modern/src/AppLayout.tsx`, and
-`frontend-modern/src/routing/resourceLinks.ts` must keep that context limited
-to deliberate resource pins, visible once in shared chrome, and preserved
-across platform navigation. Page-local hover preview and group scope remain
-local interaction state; they must not silently escalate into shell-wide
-context.
The settings reporting shell now also owns a deliberate split between
historical performance reports and current-state VM inventory export.
`frontend-modern/src/components/Settings/ReportingPanel.tsx`,
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 2f701334b8..8db4c374b9 100644
--- a/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
+++ b/docs/release-control/v6/internal/subsystems/performance-and-scalability.md
@@ -176,15 +176,6 @@ regression protection.
branches, focusable-row toggles, or touch-hostile synthetic hover behavior
inside individual row renderers.
28. Keep summary-card hover emphasis on one bounded rendering budget: when a summary row is active, shared sparkline and density-map primitives must promote the selected series and demote background series through the same active-series ID rather than layering a second page-local highlight pass, so zoom-range and hover scrubbing stay visually coherent without reintroducing multi-series overdraw on the hot summary cards. Density maps on that hot path must stay overview-first under focus: preserve the multi-entity heatmap rows, layer focused-entity detail inside the card, and avoid swapping transient hover into a separate single-series chart path.
-29. Keep deliberate global resource pinning off the hot-path filter model.
- Infrastructure summary-linked rows may expose a deliberate global-context
- pin through `frontend-modern/src/components/shared/SummaryRowActionButton.tsx`,
- but that pin must route through the shell-owned `contextResource`
- contract instead of becoming another per-page selector or hot-path table
- filter. Infrastructure row renderers should reuse the shared action
- control plus app-shell context owner rather than introducing provider-
- local pin buttons or route writes that add extra hover/focus work to the
- hot table path.
## Forbidden Paths
diff --git a/docs/release-control/v6/internal/subsystems/storage-recovery.md b/docs/release-control/v6/internal/subsystems/storage-recovery.md
index f4abb4a8ae..c0ebd62c31 100644
--- a/docs/release-control/v6/internal/subsystems/storage-recovery.md
+++ b/docs/release-control/v6/internal/subsystems/storage-recovery.md
@@ -247,16 +247,6 @@ querying, and the operator-facing storage health presentation layer.
`createRouteStateNavigateScheduler` helper so back-to-back storage filter
changes coalesce against the current location instead of reintroducing a
storage-local timeout queue.
-20. Keep storage and recovery global resource context route-backed and
- lossless. When the shared shell carries `contextResource`, storage and
- recovery route builders may add their own canonical node, platform, or tab
- filters, but `frontend-modern/src/routing/resourceLinks.ts`,
- `frontend-modern/src/features/recovery/useRecoverySurfaceState.ts`, and
- storage route state must preserve that shell-owned context on rewrites,
- refresh, and deep links instead of dropping it when a feature-local route
- writer rebuilds query state. Clearing the shell context must also return
- these surfaces to their canonical base routes rather than leaving orphaned
- node or platform filters behind.
## Current State
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index fe3891c1ef..5e9cfb9135 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -244,15 +244,6 @@ assembly branch.
provider-reported storage `pool` metadata alongside path and ZFS health so
storage consumers do not have to recover backing-pool identity from names
or path heuristics.
-17. Keep global app context on canonical unified-resource IDs. When an
- operator deliberately pins a resource into the shared shell context,
- `frontend-modern/src/routing/resourceLinks.ts`,
- `frontend-modern/src/features/globalResourceContext/globalResourceContextModel.ts`,
- infrastructure route state, and any cross-surface handoff must preserve
- that scope as `contextResource=<canonical-resource-id>` and derive page
- scoping from the same unified-resource identity plus governed display
- label, rather than provider-native node names, hostnames, or page-local
- aliases.
## Current State
diff --git a/frontend-modern/src/App.tsx b/frontend-modern/src/App.tsx
index 550f8fa070..9f4bad9d5f 100644
--- a/frontend-modern/src/App.tsx
+++ b/frontend-modern/src/App.tsx
@@ -42,7 +42,6 @@ import {
} from './routing/resourceLinks';
import { AppLayout } from '@/AppLayout';
import { useAppRuntimeState } from '@/useAppRuntimeState';
-import { GlobalResourceContextProvider } from '@/features/globalResourceContext/GlobalResourceContext';
function isPublicRoutePath(pathname: string): boolean {
// Public routes must be viewable without authentication.
@@ -325,26 +324,24 @@ function App() {
<div
class={`app-scroll-shell flex-1 min-w-0 overflow-y-scroll bg-base text-base-content font-sans py-4 sm:py-6 transition-all duration-300`}
>
- <GlobalResourceContextProvider>
- <AppLayout
- connectionStatus={runtime.connectionStatus}
- dataUpdated={runtime.dataUpdated}
- lastUpdateText={runtime.lastUpdateText}
- versionInfo={runtime.versionInfo}
- hasAuth={runtime.hasAuth}
- needsAuth={runtime.needsAuth}
- proxyAuthInfo={runtime.proxyAuthInfo}
- handleLogout={runtime.handleLogout}
- state={runtime.state}
- tokenScopes={() => runtime.securityStatus()?.tokenScopes}
- organizations={runtime.organizations}
- activeOrgID={runtime.activeOrgID}
- orgsLoading={runtime.orgsLoading}
- onSwitchOrg={runtime.handleOrgSwitch}
- >
- {props.children}
- </AppLayout>
- </GlobalResourceContextProvider>
+ <AppLayout
+ connectionStatus={runtime.connectionStatus}
+ dataUpdated={runtime.dataUpdated}
+ lastUpdateText={runtime.lastUpdateText}
+ versionInfo={runtime.versionInfo}
+ hasAuth={runtime.hasAuth}
+ needsAuth={runtime.needsAuth}
+ proxyAuthInfo={runtime.proxyAuthInfo}
+ handleLogout={runtime.handleLogout}
+ state={runtime.state}
+ tokenScopes={() => runtime.securityStatus()?.tokenScopes}
+ organizations={runtime.organizations}
+ activeOrgID={runtime.activeOrgID}
+ orgsLoading={runtime.orgsLoading}
+ onSwitchOrg={runtime.handleOrgSwitch}
+ >
+ {props.children}
+ </AppLayout>
</div>
{/* AI Panel - slides in from right, pushes content */}
<AIChat onClose={() => aiChatStore.close()} />
diff --git a/frontend-modern/src/AppLayout.tsx b/frontend-modern/src/AppLayout.tsx
index 4aa728c053..52e949aa72 100644
--- a/frontend-modern/src/AppLayout.tsx
+++ b/frontend-modern/src/AppLayout.tsx
@@ -30,7 +30,8 @@ import { useKioskMode } from '@/hooks/useKioskMode';
import { layoutStore } from '@/utils/layout';
import { getActiveTabForPath } from '@/routing/navigation';
import {
- buildPathWithGlobalResourceContext,
+ buildInfrastructurePath,
+ buildWorkloadsPath,
DASHBOARD_PATH,
} from '@/routing/resourceLinks';
import { buildStorageRecoveryTabSpecs } from '@/routing/platformTabs';
@@ -39,8 +40,9 @@ import { updateStore } from '@/stores/updates';
import { aiChatStore } from '@/stores/aiChat';
import { isMultiTenantEnabled, isPro } from '@/stores/license';
import type { AppConnectionStatus } from '@/useAppRuntimeState';
-import { useGlobalResourceContext } from '@/features/globalResourceContext/GlobalResourceContext';
-import { GlobalResourceContextBar } from '@/features/globalResourceContext/GlobalResourceContextBar';
+
+const ROOT_INFRASTRUCTURE_PATH = buildInfrastructurePath();
+const ROOT_WORKLOADS_PATH = buildWorkloadsPath();
type PlatformTab = {
id: string;
@@ -158,7 +160,6 @@ export function AppLayout(props: AppLayoutProps) {
const navigate = useNavigate();
const location = useLocation();
const kioskMode = useKioskMode();
- const globalContext = useGlobalResourceContext();
const [headerVisible, setHeaderVisible] = createSignal(true);
let headerEl: HTMLDivElement | undefined;
@@ -279,7 +280,7 @@ export function AppLayout(props: AppLayoutProps) {
{
id: 'dashboard',
label: 'Dashboard',
- route: globalContext.buildPlatformRoute('dashboard'),
+ route: DASHBOARD_PATH,
settingsRoute: '/settings',
tooltip: 'Environment overview and command center',
enabled: true,
@@ -290,7 +291,7 @@ export function AppLayout(props: AppLayoutProps) {
{
id: 'infrastructure',
label: 'Infrastructure',
- route: globalContext.buildPlatformRoute('infrastructure'),
+ route: ROOT_INFRASTRUCTURE_PATH,
settingsRoute: '/settings',
tooltip: 'All agents and nodes across platforms',
enabled: true,
@@ -301,7 +302,7 @@ export function AppLayout(props: AppLayoutProps) {
{
id: 'workloads',
label: 'Workloads',
- route: globalContext.buildPlatformRoute('workloads'),
+ route: ROOT_WORKLOADS_PATH,
settingsRoute: '/settings/workloads/docker',
tooltip: 'VMs, containers, and Kubernetes workloads',
enabled: true,
@@ -311,7 +312,6 @@ export function AppLayout(props: AppLayoutProps) {
},
...buildStorageRecoveryTabSpecs().map((tab) => ({
...tab,
- route: globalContext.buildPlatformRoute(tab.id),
enabled: true,
live: true,
icon: tab.id.startsWith('storage') ? (
@@ -331,7 +331,7 @@ export function AppLayout(props: AppLayoutProps) {
{
id: 'dashboard',
label: 'Dashboard',
- route: globalContext.buildPlatformRoute('dashboard'),
+ route: DASHBOARD_PATH,
settingsRoute: '/settings',
tooltip: 'Environment overview and command center',
enabled: true,
@@ -342,7 +342,7 @@ export function AppLayout(props: AppLayoutProps) {
{
id: 'infrastructure',
label: 'Infrastructure',
- route: globalContext.buildPlatformRoute('infrastructure'),
+ route: ROOT_INFRASTRUCTURE_PATH,
settingsRoute: '/settings',
tooltip: 'All agents and nodes across platforms',
enabled: true,
@@ -353,7 +353,7 @@ export function AppLayout(props: AppLayoutProps) {
{
id: 'workloads',
label: 'Workloads',
- route: globalContext.buildPlatformRoute('workloads'),
+ route: ROOT_WORKLOADS_PATH,
settingsRoute: '/settings/workloads/docker',
tooltip: 'VMs, containers, and Kubernetes workloads',
enabled: true,
@@ -363,7 +363,6 @@ export function AppLayout(props: AppLayoutProps) {
},
...buildStorageRecoveryTabSpecs().map((tab) => ({
...tab,
- route: globalContext.buildPlatformRoute(tab.id),
enabled: true,
live: true,
icon: tab.id.startsWith('storage') ? (
@@ -403,7 +402,7 @@ export function AppLayout(props: AppLayoutProps) {
{
id: 'alerts',
label: 'Alerts',
- route: buildPathWithGlobalResourceContext('/alerts', globalContext.contextResourceId()),
+ route: '/alerts',
tooltip: 'Review active alerts and automation rules',
badge: null,
count: activeAlertCount,
@@ -413,7 +412,7 @@ export function AppLayout(props: AppLayoutProps) {
{
id: 'ai',
label: 'Patrol',
- route: buildPathWithGlobalResourceContext('/ai', globalContext.contextResourceId()),
+ route: '/ai',
tooltip: 'Pulse Patrol monitoring and analysis',
badge: null,
count: undefined,
@@ -423,10 +422,7 @@ export function AppLayout(props: AppLayoutProps) {
{
id: 'operations',
label: 'Operations',
- route: buildPathWithGlobalResourceContext(
- '/operations',
- globalContext.contextResourceId(),
- ),
+ route: '/operations',
tooltip: 'System operations, diagnostics, and reporting',
badge: null,
count: undefined,
@@ -439,10 +435,7 @@ export function AppLayout(props: AppLayoutProps) {
tabs.push({
id: 'settings',
label: 'Settings',
- route: buildPathWithGlobalResourceContext(
- '/settings',
- globalContext.contextResourceId(),
- ),
+ route: '/settings',
tooltip: 'Configure Pulse preferences and integrations',
badge: updateStore.isUpdateVisible() ? 'update' : null,
count: undefined,
@@ -458,12 +451,7 @@ export function AppLayout(props: AppLayoutProps) {
if (platform.enabled) {
navigate(platform.route);
} else {
- navigate(
- buildPathWithGlobalResourceContext(
- platform.settingsRoute,
- globalContext.contextResourceId(),
- ),
- );
+ navigate(platform.settingsRoute);
}
};
@@ -755,7 +743,6 @@ export function AppLayout(props: AppLayoutProps) {
class="tab-content block bg-surface rounded-b rounded-tr rounded-tl shadow mb-2"
>
<div class="pulse-panel">
- <GlobalResourceContextBar class="border-b border-border px-4 py-2" />
<Suspense fallback={<div class="p-6 text-sm text-muted">Loading view...</div>}>
{props.children}
</Suspense>
diff --git a/frontend-modern/src/__tests__/App.architecture.test.ts b/frontend-modern/src/__tests__/App.architecture.test.ts
index 1d0f3c9124..c4ec7cf044 100644
--- a/frontend-modern/src/__tests__/App.architecture.test.ts
+++ b/frontend-modern/src/__tests__/App.architecture.test.ts
@@ -7,9 +7,6 @@ describe('App architecture', () => {
it('keeps App as the entry shell that delegates runtime and chrome ownership', () => {
expect(appSource).toContain('DASHBOARD_PATH,');
expect(appSource).toContain("import { AppLayout } from '@/AppLayout';");
- expect(appSource).toContain(
- "import { GlobalResourceContextProvider } from '@/features/globalResourceContext/GlobalResourceContext';",
- );
expect(appSource).toContain("import { useAppRuntimeState } from '@/useAppRuntimeState';");
expect(appSource).toContain('const runtime = useAppRuntimeState();');
expect(appSource).toContain('const ROOT_DASHBOARD_PATH = DASHBOARD_PATH;');
@@ -26,18 +23,10 @@ describe('App architecture', () => {
expect(appSource).not.toContain('const [organizations, setOrganizations] = createSignal(');
expect(appSource).not.toContain('const [themePreference, setThemePreference] =');
expect(appSource).not.toContain('const [activeOrgID, setActiveOrgID] = createSignal(');
- expect(appSource).toContain('<GlobalResourceContextProvider>');
- expect(appSource).toContain('</GlobalResourceContextProvider>');
});
it('keeps authenticated chrome in AppLayout and hosted bootstrap in useAppRuntimeState', () => {
expect(appLayoutSource).toContain('export function AppLayout(props: AppLayoutProps)');
- expect(appLayoutSource).toContain(
- "import { useGlobalResourceContext } from '@/features/globalResourceContext/GlobalResourceContext';",
- );
- expect(appLayoutSource).toContain(
- "import { GlobalResourceContextBar } from '@/features/globalResourceContext/GlobalResourceContextBar';",
- );
expect(appLayoutSource).toContain('<OrgSwitcher');
expect(appLayoutSource).toContain('const status = () => props.connectionStatus();');
expect(appLayoutSource).toContain("status().kind === 'sync-reconnecting' || status().kind === 'reconnecting'");
@@ -53,14 +42,6 @@ describe('App architecture', () => {
expect(appSource).not.toContain("apiFetch('/api/security/status')");
expect(appLayoutSource).not.toContain("eventBus.on('theme_changed'");
expect(appLayoutSource).not.toContain("apiFetch('/api/security/status')");
- expect(appLayoutSource).toContain('const globalContext = useGlobalResourceContext();');
- expect(appLayoutSource).toContain("route: globalContext.buildPlatformRoute('infrastructure')");
- expect(appLayoutSource).toContain(
- "route: buildPathWithGlobalResourceContext('/alerts', globalContext.contextResourceId())",
- );
- expect(appLayoutSource).toContain(
- '<GlobalResourceContextBar class="border-b border-border px-4 py-2" />',
- );
expect(appRuntimeStateSource).toContain('export const useAppRuntimeState = () =>');
expect(appRuntimeStateSource).toContain('const connectionStatus = createMemo<AppConnectionStatus>(() => {');
expect(appRuntimeStateSource).toContain('const beginAuthenticatedRuntime = async () =>');
diff --git a/frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx b/frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx
index 2533bf78dc..4408560898 100644
--- a/frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx
+++ b/frontend-modern/src/components/Infrastructure/UnifiedResourceHostTableCard.tsx
@@ -38,7 +38,6 @@ import {
createSummaryInteractiveRowPreviewHandlers,
} from '@/components/shared/summaryInteractionA11y';
import { SummaryRowActionButton } from '@/components/shared/SummaryRowActionButton';
-import { useGlobalResourceContext } from '@/features/globalResourceContext/GlobalResourceContext';
import {
type UnifiedResourceTableProps,
type UnifiedResourceTableState,
@@ -55,7 +54,6 @@ export const UnifiedResourceHostTableCard: Component<UnifiedResourceHostTableCar
props,
) => {
const { table, tableProps } = props;
- const globalContext = useGlobalResourceContext();
return (
<Show when={table.showHostTable()}>
@@ -307,12 +305,6 @@ export const UnifiedResourceHostTableCard: Component<UnifiedResourceHostTableCar
getResourcePolicyTableBadges(resource.policy),
);
const workloadsHref = createMemo(() => buildWorkloadsHref(resource));
- const supportsGlobalContext = createMemo(() =>
- globalContext.canPinResource(resource),
- );
- const isGlobalContextPinned = createMemo(() =>
- globalContext.isPinnedGlobalResource(resource.id),
- );
const resourceRowInteraction = createSummaryInteractiveRowPreviewHandlers({
onPreview: () => tableProps.onHoverChange?.(resource.id),
onPreviewClear: () => tableProps.onHoverChange?.(null),
@@ -344,19 +336,6 @@ export const UnifiedResourceHostTableCard: Component<UnifiedResourceHostTableCar
onAction={() => table.toggleExpand(resource.id)}
onPreviewClear={() => tableProps.onHoverChange?.(null)}
/>
- <Show when={supportsGlobalContext()}>
- <SummaryRowActionButton
- kind="context"
- subjectLabel={displayName()}
- pressed={isGlobalContextPinned()}
- onAction={() =>
- globalContext.setGlobalResourceContext(
- isGlobalContextPinned() ? null : resource,
- )
- }
- onPreviewClear={() => tableProps.onHoverChange?.(null)}
- />
- </Show>
<StatusDot
variant={statusIndicator().variant}
title={statusIndicator().label}
diff --git a/frontend-modern/src/components/Infrastructure/UnifiedResourcePBSTableSection.tsx b/frontend-modern/src/components/Infrastructure/UnifiedResourcePBSTableSection.tsx
index aa43fdbb64..96bc3e2afa 100644
--- a/frontend-modern/src/components/Infrastructure/UnifiedResourcePBSTableSection.tsx
+++ b/frontend-modern/src/components/Infrastructure/UnifiedResourcePBSTableSection.tsx
@@ -7,7 +7,6 @@ import {
createSummaryInteractiveRowPreviewHandlers,
} from '@/components/shared/summaryInteractionA11y';
import { SummaryRowActionButton } from '@/components/shared/SummaryRowActionButton';
-import { useGlobalResourceContext } from '@/features/globalResourceContext/GlobalResourceContext';
import {
Table,
TableBody,
@@ -43,7 +42,6 @@ export const UnifiedResourcePBSTableSection: Component<UnifiedResourcePBSTableSe
props,
) => {
const { table, tableProps } = props;
- const globalContext = useGlobalResourceContext();
return (
<Show when={table.sortedPBSResources().length > 0}>
@@ -142,12 +140,6 @@ export const UnifiedResourcePBSTableSection: Component<UnifiedResourcePBSTableSe
onPreview: () => tableProps.onHoverChange?.(resource.id),
onPreviewClear: () => tableProps.onHoverChange?.(null),
});
- const supportsGlobalContext = createMemo(() =>
- globalContext.canPinResource(resource),
- );
- const isGlobalContextPinned = createMemo(() =>
- globalContext.isPinnedGlobalResource(resource.id),
- );
return (
<>
@@ -174,19 +166,6 @@ export const UnifiedResourcePBSTableSection: Component<UnifiedResourcePBSTableSe
onAction={() => table.toggleExpand(resource.id)}
onPreviewClear={() => tableProps.onHoverChange?.(null)}
/>
- <Show when={supportsGlobalContext()}>
- <SummaryRowActionButton
- kind="context"
- subjectLabel={displayName()}
- pressed={isGlobalContextPinned()}
- onAction={() =>
- globalContext.setGlobalResourceContext(
- isGlobalContextPinned() ? null : resource,
- )
- }
- onPreviewClear={() => tableProps.onHoverChange?.(null)}
- />
- </Show>
<StatusDot
variant={statusIndicator().variant}
title={statusIndicator().label}
diff --git a/frontend-modern/src/components/Infrastructure/UnifiedResourcePMGTableSection.tsx b/frontend-modern/src/components/Infrastructure/UnifiedResourcePMGTableSection.tsx
index 6821866163..4e77e53a15 100644
--- a/frontend-modern/src/components/Infrastructure/UnifiedResourcePMGTableSection.tsx
+++ b/frontend-modern/src/components/Infrastructure/UnifiedResourcePMGTableSection.tsx
@@ -7,7 +7,6 @@ import {
createSummaryInteractiveRowPreviewHandlers,
} from '@/components/shared/summaryInteractionA11y';
import { SummaryRowActionButton } from '@/components/shared/SummaryRowActionButton';
-import { useGlobalResourceContext } from '@/features/globalResourceContext/GlobalResourceContext';
import {
Table,
TableBody,
@@ -43,7 +42,6 @@ export const UnifiedResourcePMGTableSection: Component<UnifiedResourcePMGTableSe
props,
) => {
const { table, tableProps } = props;
- const globalContext = useGlobalResourceContext();
return (
<Show when={table.sortedPMGResources().length > 0}>
@@ -159,12 +157,6 @@ export const UnifiedResourcePMGTableSection: Component<UnifiedResourcePMGTableSe
onPreview: () => tableProps.onHoverChange?.(resource.id),
onPreviewClear: () => tableProps.onHoverChange?.(null),
});
- const supportsGlobalContext = createMemo(() =>
- globalContext.canPinResource(resource),
- );
- const isGlobalContextPinned = createMemo(() =>
- globalContext.isPinnedGlobalResource(resource.id),
- );
return (
<>
@@ -191,19 +183,6 @@ export const UnifiedResourcePMGTableSection: Component<UnifiedResourcePMGTableSe
onAction={() => table.toggleExpand(resource.id)}
onPreviewClear={() => tableProps.onHoverChange?.(null)}
/>
- <Show when={supportsGlobalContext()}>
- <SummaryRowActionButton
- kind="context"
- subjectLabel={displayName()}
- pressed={isGlobalContextPinned()}
- onAction={() =>
- globalContext.setGlobalResourceContext(
- isGlobalContextPinned() ? null : resource,
- )
- }
- onPreviewClear={() => tableProps.onHoverChange?.(null)}
- />
- </Show>
<StatusDot
variant={statusIndicator().variant}
title={statusIndicator().label}
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 19f8199f26..4272ba1fb8 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
@@ -229,20 +229,6 @@ describe('UnifiedResourceTable performance contract', () => {
);
});
- it('keeps infrastructure global resource pinning on the shared row action and shell context contract', () => {
- expect(summaryRowActionButtonSource).toContain("kind: 'context'");
-
- for (const source of [
- unifiedResourceHostTableCardSource,
- unifiedResourcePBSTableSectionSource,
- unifiedResourcePMGTableSectionSource,
- ]) {
- expect(source).toContain('useGlobalResourceContext');
- expect(source).toContain('SummaryRowActionButton');
- expect(source).toContain('kind="context"');
- }
- });
-
it('keeps infrastructure summary fetch runtime out of the render shell', () => {
expect(infrastructureSummarySource).toContain('useInfrastructureSummaryState');
expect(infrastructureSummarySource).not.toContain('fetchInfrastructureSummaryAndCache');
diff --git a/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx b/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
index a0c2dc7ad5..ccfeab131a 100644
--- a/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
+++ b/frontend-modern/src/components/Recovery/__tests__/Recovery.test.tsx
@@ -785,21 +785,6 @@ describe('Recovery', () => {
expect(within(detailsPanel as HTMLTableCellElement).getByText('Finance')).toBeInTheDocument();
});
- it('preserves the shell global resource context when focusing recovery history', async () => {
- mockLocationSearch = '?contextResource=agent%3Apve-01';
- render(() => <Recovery />);
-
- const item = await screen.findByText('VM 123');
- fireEvent.click(item);
-
- await waitFor(() => {
- expect(navigateSpy).toHaveBeenCalledWith(
- '/recovery?rollupId=res%3Avm-123&contextResource=agent%3Apve-01',
- ROUTE_STATE_REPLACE_OPTIONS,
- );
- });
- });
-
it('keeps optional history placement columns on the neutral recovery vocabulary', async () => {
facetsPayload.clusters = ['lab-cluster'];
facetsPayload.nodesAgents = ['pve-01'];
diff --git a/frontend-modern/src/components/Storage/DiskList.tsx b/frontend-modern/src/components/Storage/DiskList.tsx
index dc086dfa3e..cac9c074d6 100644
--- a/frontend-modern/src/components/Storage/DiskList.tsx
+++ b/frontend-modern/src/components/Storage/DiskList.tsx
@@ -5,7 +5,6 @@ import {
createSummaryInteractiveRowPreviewHandlers,
} from '@/components/shared/summaryInteractionA11y';
import { SummaryRowActionButton } from '@/components/shared/SummaryRowActionButton';
-import { useGlobalResourceContext } from '@/features/globalResourceContext/GlobalResourceContext';
import { resolvePhysicalDiskMetricResourceId } from '@/features/storageBackups/storageMetricsIdentity';
import {
Table,
@@ -85,7 +84,6 @@ interface DiskListProps {
}
export const DiskList: Component<DiskListProps> = (props) => {
- const globalContext = useGlobalResourceContext();
const model = useDiskListModel({
disks: () => props.disks,
nodes: () => props.nodes,
@@ -174,9 +172,6 @@ export const DiskList: Component<DiskListProps> = (props) => {
const isSummaryHighlighted = () =>
props.highlightedSummarySeriesId === summarySeriesId;
const detailControlsId = buildSummaryDisclosureControlsId(summarySeriesId);
- const supportsGlobalContext = () => globalContext.canPinResourceId(disk.id);
- const isGlobalContextPinned = () =>
- globalContext.isPinnedGlobalResource(disk.id);
const interactiveRowHandlers = createSummaryInteractiveRowPreviewHandlers({
onPreview: () => props.onHoverChange?.(disk.id),
onPreviewClear: () => props.onHoverChange?.(null),
@@ -209,19 +204,6 @@ export const DiskList: Component<DiskListProps> = (props) => {
onAction={() => model.toggleSelectedDisk(disk)}
onPreviewClear={() => props.onHoverChange?.(null)}
/>
- <Show when={supportsGlobalContext()}>
- <SummaryRowActionButton
- kind="context"
- subjectLabel={data.model || 'disk'}
- pressed={isGlobalContextPinned()}
- onAction={() =>
- globalContext.setGlobalResourceContextById(
- isGlobalContextPinned() ? null : disk.id,
- )
- }
- onPreviewClear={() => props.onHoverChange?.(null)}
- />
- </Show>
<span
class={PHYSICAL_DISK_NAME_TEXT_CLASS}
title={data.devPath || data.model || disk.name || 'Unknown Disk'}
diff --git a/frontend-modern/src/components/Storage/StoragePoolRow.tsx b/frontend-modern/src/components/Storage/StoragePoolRow.tsx
index 3ca3c7af92..4a962e567a 100644
--- a/frontend-modern/src/components/Storage/StoragePoolRow.tsx
+++ b/frontend-modern/src/components/Storage/StoragePoolRow.tsx
@@ -36,7 +36,6 @@ import {
createSummaryInteractiveRowPreviewHandlers,
} from '@/components/shared/summaryInteractionA11y';
import { SummaryRowActionButton } from '@/components/shared/SummaryRowActionButton';
-import { useGlobalResourceContext } from '@/features/globalResourceContext/GlobalResourceContext';
interface StoragePoolRowProps {
record: StorageRecord;
@@ -57,18 +56,10 @@ interface StoragePoolRowProps {
}
export const StoragePoolRow: Component<StoragePoolRowProps> = (props) => {
- const globalContext = useGlobalResourceContext();
const row = createMemo(() => buildStoragePoolRowModel(props.record));
const detailControlsId = createMemo(() =>
buildSummaryDisclosureControlsId(props.summarySeriesId),
);
- const globalContextResourceId = createMemo(() => props.record.refs?.resourceId || props.record.id);
- const supportsGlobalContext = createMemo(() =>
- globalContext.canPinResourceId(globalContextResourceId()),
- );
- const isGlobalContextPinned = createMemo(() =>
- globalContext.isPinnedGlobalResource(globalContextResourceId()),
- );
const interactiveRowHandlers = createSummaryInteractiveRowPreviewHandlers({
onPreview: () => props.onHoverChange?.(props.summarySeriesId),
onPreviewClear: () => props.onHoverChange?.(null),
@@ -95,19 +86,6 @@ export const StoragePoolRow: Component<StoragePoolRowProps> = (props) => {
onAction={props.onToggleExpand}
onPreviewClear={() => props.onHoverChange?.(null)}
/>
- <Show when={supportsGlobalContext()}>
- <SummaryRowActionButton
- kind="context"
- subjectLabel={props.record.name}
- pressed={isGlobalContextPinned()}
- onAction={() =>
- globalContext.setGlobalResourceContextById(
- isGlobalContextPinned() ? null : globalContextResourceId(),
- )
- }
- onPreviewClear={() => props.onHoverChange?.(null)}
- />
- </Show>
<span class={STORAGE_POOL_ROW_NAME_TEXT_CLASS} title={props.record.name}>
{props.record.name}
</span>
diff --git a/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx b/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx
index 92f4fd7cdf..8e35e9a219 100644
--- a/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx
+++ b/frontend-modern/src/components/Storage/__tests__/Storage.test.tsx
@@ -3,8 +3,6 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { ChartsAPI } from '@/api/charts';
import StorageSummary from '@/components/Storage/StorageSummary';
import storageSummarySource from '@/components/Storage/StorageSummary.tsx?raw';
-import storagePoolRowSource from '@/components/Storage/StoragePoolRow.tsx?raw';
-import diskListSource from '@/components/Storage/DiskList.tsx?raw';
import type { Alert } from '@/types/api';
import type { Resource, ResourceType } from '@/types/resource';
import Storage from '@/components/Storage/Storage';
@@ -382,15 +380,6 @@ describe('Storage', () => {
expect(screen.queryByText('Local-LVM-PVE2')).not.toBeInTheDocument();
});
- it('keeps storage global resource pinning on the shared row action contract', () => {
- expect(storagePoolRowSource).toContain('useGlobalResourceContext');
- expect(storagePoolRowSource).toContain('SummaryRowActionButton');
- expect(storagePoolRowSource).toContain('kind="context"');
- expect(diskListSource).toContain('useGlobalResourceContext');
- expect(diskListSource).toContain('SummaryRowActionButton');
- expect(diskListSource).toContain('kind="context"');
- });
-
it('routes hovered pool rows into the shared summary highlight contract and keeps the summary sticky', async () => {
const storageSummarySpy = vi.spyOn(ChartsAPI, 'getStorageSummaryCharts').mockResolvedValue({
pools: {
diff --git a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
index 648824957d..2ace8f4031 100644
--- a/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
+++ b/frontend-modern/src/components/shared/SharedPrimitives.guardrails.test.ts
@@ -415,13 +415,10 @@ describe('shared primitive guardrails', () => {
expect(summaryRowActionButtonSource).toContain('SummaryRowActionButton');
expect(summaryRowActionButtonSource).toContain("kind: 'disclosure'");
expect(summaryRowActionButtonSource).toContain("kind: 'scope'");
- expect(summaryRowActionButtonSource).toContain("kind: 'context'");
expect(summaryRowActionButtonSource).toContain('aria-controls');
expect(summaryRowActionButtonSource).toContain('aria-expanded');
expect(summaryRowActionButtonSource).toContain('aria-pressed');
expect(summaryRowActionButtonSource).toContain('data-row-action="true"');
- expect(summaryRowActionButtonSource).toContain('Set global context to');
- expect(summaryRowActionButtonSource).toContain('Clear global context for');
for (const source of [
workloadPanelSource,
@@ -437,17 +434,6 @@ describe('shared primitive guardrails', () => {
expect(source).toContain('SummaryRowActionButton');
}
- for (const source of [
- storagePoolRowSource,
- diskListSource,
- unifiedResourceHostTableCardSource,
- unifiedResourcePBSTableSectionSource,
- unifiedResourcePMGTableSectionSource,
- ]) {
- expect(source).toContain('useGlobalResourceContext');
- expect(source).toContain('kind="context"');
- }
-
expect(nodeGroupHeaderSource).toContain('event.stopPropagation()');
});
diff --git a/frontend-modern/src/components/shared/SummaryRowActionButton.tsx b/frontend-modern/src/components/shared/SummaryRowActionButton.tsx
index 647ae1cd77..4208fad038 100644
--- a/frontend-modern/src/components/shared/SummaryRowActionButton.tsx
+++ b/frontend-modern/src/components/shared/SummaryRowActionButton.tsx
@@ -23,14 +23,6 @@ type SummaryRowActionButtonProps =
activeLabel?: string;
onAction: () => void;
onPreviewClear?: () => void;
- }
- | {
- kind: 'context';
- pressed: boolean;
- subjectLabel: string;
- class?: string;
- onAction: () => void;
- onPreviewClear?: () => void;
};
const DISCLOSURE_BUTTON_CLASS = [
@@ -45,12 +37,6 @@ const SCOPE_BUTTON_CLASS = [
SUMMARY_ROW_ACTION_BUTTON_FOCUS_CLASS,
].join(' ');
-const CONTEXT_BUTTON_CLASS = [
- 'inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted transition-colors',
- 'hover:bg-surface hover:text-sky-700 dark:hover:text-sky-300',
- SUMMARY_ROW_ACTION_BUTTON_FOCUS_CLASS,
-].join(' ');
-
export const SummaryRowActionButton: Component<SummaryRowActionButtonProps> = (props) => {
const disclosureLabel = () =>
props.expanded ? `Collapse ${props.subjectLabel}` : `Expand ${props.subjectLabel}`;
@@ -58,33 +44,17 @@ export const SummaryRowActionButton: Component<SummaryRowActionButtonProps> = (p
props.pressed
? `Unpin summary scope for ${props.subjectLabel}`
: `Pin summary scope for ${props.subjectLabel}`;
- const contextLabel = () =>
- props.pressed
- ? `Clear global context for ${props.subjectLabel}`
- : `Set global context to ${props.subjectLabel}`;
return (
<button
type="button"
data-row-action="true"
- class={`${props.kind === 'disclosure' ? DISCLOSURE_BUTTON_CLASS : props.kind === 'scope' ? SCOPE_BUTTON_CLASS : CONTEXT_BUTTON_CLASS} ${props.class ?? ''}`.trim()}
- aria-label={
- props.kind === 'disclosure'
- ? disclosureLabel()
- : props.kind === 'scope'
- ? scopeLabel()
- : contextLabel()
- }
+ class={`${props.kind === 'disclosure' ? DISCLOSURE_BUTTON_CLASS : SCOPE_BUTTON_CLASS} ${props.class ?? ''}`.trim()}
+ aria-label={props.kind === 'disclosure' ? disclosureLabel() : scopeLabel()}
aria-expanded={props.kind === 'disclosure' ? props.expanded : undefined}
aria-controls={props.kind === 'disclosure' ? props.controlsId : undefined}
- aria-pressed={props.kind !== 'disclosure' ? props.pressed : undefined}
- title={
- props.kind === 'disclosure'
- ? disclosureLabel()
- : props.kind === 'scope'
- ? scopeLabel()
- : contextLabel()
- }
+ aria-pressed={props.kind === 'scope' ? props.pressed : undefined}
+ title={props.kind === 'disclosure' ? disclosureLabel() : scopeLabel()}
onClick={(event) => {
event.stopPropagation();
props.onAction();
@@ -95,7 +65,7 @@ export const SummaryRowActionButton: Component<SummaryRowActionButtonProps> = (p
})}
>
<Show
- when={props.kind !== 'disclosure'}
+ when={props.kind === 'scope'}
fallback={
<svg
class={`h-3.5 w-3.5 transition-transform duration-150 ${props.expanded ? 'rotate-90 text-base-content' : ''}`.trim()}
@@ -113,31 +83,11 @@ export const SummaryRowActionButton: Component<SummaryRowActionButtonProps> = (p
</svg>
}
>
- <Show
- when={props.kind === 'scope'}
- fallback={
- <svg
- class={`h-3.5 w-3.5 ${props.pressed ? 'text-sky-600 dark:text-sky-300' : ''}`.trim()}
- fill={props.pressed ? 'currentColor' : 'none'}
- viewBox="0 0 24 24"
- stroke="currentColor"
- stroke-width="1.8"
- aria-hidden="true"
- >
- <path
- stroke-linecap="round"
- stroke-linejoin="round"
- d="M12 17.25V21m0-3.75L8.25 13.5m3.75 3.75L15.75 13.5M6 3.75h12a.75.75 0 01.75.75v1.086a3 3 0 01-.879 2.121l-3.242 3.243a3 3 0 00-.879 2.12V15a.75.75 0 01-.75.75h-2.5a.75.75 0 01-.75-.75v-1.257a3 3 0 00-.879-2.12L5.629 7.707A3 3 0 014.75 5.586V4.5A.75.75 0 015.5 3.75z"
- />
- </svg>
- }
+ <span
+ class={`whitespace-nowrap ${props.pressed ? 'border-sky-200 bg-sky-50 px-0 py-0 text-sky-700 dark:border-sky-900/60 dark:bg-sky-950/40 dark:text-sky-300' : ''}`.trim()}
>
- <span
- class={`whitespace-nowrap ${props.pressed ? 'border-sky-200 bg-sky-50 px-0 py-0 text-sky-700 dark:border-sky-900/60 dark:bg-sky-950/40 dark:text-sky-300' : ''}`.trim()}
- >
- {props.pressed ? (props.activeLabel ?? 'Pinned') : (props.inactiveLabel ?? 'Scope')}
- </span>
- </Show>
+ {props.pressed ? (props.activeLabel ?? 'Pinned') : (props.inactiveLabel ?? 'Scope')}
+ </span>
</Show>
</button>
);
diff --git a/frontend-modern/src/components/shared/__tests__/SummaryRowActionButton.test.tsx b/frontend-modern/src/components/shared/__tests__/SummaryRowActionButton.test.tsx
index 8ce3743a9a..c4a221b76c 100644
--- a/frontend-modern/src/components/shared/__tests__/SummaryRowActionButton.test.tsx
+++ b/frontend-modern/src/components/shared/__tests__/SummaryRowActionButton.test.tsx
@@ -44,26 +44,6 @@ describe('SummaryRowActionButton', () => {
expect(onAction).toHaveBeenCalledTimes(1);
});
- it('owns global context pin semantics with aria-pressed', () => {
- const onAction = vi.fn();
- render(() => (
- <SummaryRowActionButton
- kind="context"
- subjectLabel="pve1"
- pressed={false}
- onAction={onAction}
- />
- ));
-
- const button = screen.getByRole('button', {
- name: 'Set global context to pve1',
- });
- expect(button).toHaveAttribute('aria-pressed', 'false');
-
- fireEvent.click(button);
- expect(onAction).toHaveBeenCalledTimes(1);
- });
-
it('clears preview and blurs on Escape', () => {
const onPreviewClear = vi.fn();
render(() => (
diff --git a/frontend-modern/src/features/globalResourceContext/GlobalResourceContext.tsx b/frontend-modern/src/features/globalResourceContext/GlobalResourceContext.tsx
deleted file mode 100644
index 3330a25e24..0000000000
--- a/frontend-modern/src/features/globalResourceContext/GlobalResourceContext.tsx
+++ /dev/null
@@ -1,204 +0,0 @@
-import {
- createContext,
- createEffect,
- createMemo,
- onCleanup,
- untrack,
- useContext,
- type Accessor,
- type JSX,
-} from 'solid-js';
-import { useLocation, useNavigate } from '@solidjs/router';
-
-import {
- buildPathWithGlobalResourceContext,
- parseGlobalResourceContextSearch,
-} from '@/routing/resourceLinks';
-import { useStorageRecoveryResources, useUnifiedResources } from '@/hooks/useUnifiedResources';
-import type { Resource } from '@/types/resource';
-import { getPreferredResourceDisplayName } from '@/utils/resourceIdentity';
-import { createRouteStateNavigateScheduler } from '@/utils/routeStateNavigation';
-import {
- buildGlobalResourceContextBasePath,
- buildSurfacePathWithGlobalResourceContext,
- resolveGlobalResourceContextClearTarget,
- resolveGlobalResourceContextSurface,
-} from './globalResourceContextModel';
-
-export interface GlobalResourceContextValue {
- canPinResource: (resource: Resource | null | undefined) => boolean;
- canPinResourceId: (resourceId: string | null | undefined) => boolean;
- clearGlobalResourceContext: () => void;
- contextLabel: Accessor<string | null>;
- contextResource: Accessor<Resource | null>;
- contextResourceId: Accessor<string | null>;
- hasGlobalResourceContext: Accessor<boolean>;
- isPinnedGlobalResource: (resourceId: string | null | undefined) => boolean;
- setGlobalResourceContext: (resource: Resource | null | undefined) => void;
- setGlobalResourceContextById: (resourceId: string | null | undefined) => void;
- buildPlatformRoute: (
- surface: 'dashboard' | 'infrastructure' | 'workloads' | 'storage' | 'recovery',
- ) => string;
-}
-
-const EMPTY_CONTEXT_ACCESSOR = () => null;
-const EMPTY_FALSE_ACCESSOR = () => false;
-
-const DEFAULT_GLOBAL_RESOURCE_CONTEXT: GlobalResourceContextValue = {
- canPinResource: () => false,
- canPinResourceId: () => false,
- clearGlobalResourceContext: () => undefined,
- contextLabel: EMPTY_CONTEXT_ACCESSOR,
- contextResource: EMPTY_CONTEXT_ACCESSOR,
- contextResourceId: EMPTY_CONTEXT_ACCESSOR,
- hasGlobalResourceContext: EMPTY_FALSE_ACCESSOR,
- isPinnedGlobalResource: () => false,
- setGlobalResourceContext: () => undefined,
- setGlobalResourceContextById: () => undefined,
- buildPlatformRoute: (surface) => buildGlobalResourceContextBasePath(surface),
-};
-
-const GlobalResourceContext = createContext<GlobalResourceContextValue>(
- DEFAULT_GLOBAL_RESOURCE_CONTEXT,
-);
-
-export const useGlobalResourceContext = (): GlobalResourceContextValue =>
- useContext(GlobalResourceContext) ?? DEFAULT_GLOBAL_RESOURCE_CONTEXT;
-
-export function GlobalResourceContextProvider(props: { children: JSX.Element }) {
- const location = useLocation();
- const navigate = useNavigate();
- const routeStateNavigate = createRouteStateNavigateScheduler(
- navigate,
- () => `${untrack(() => location.pathname)}${untrack(() => location.search || '')}`,
- );
-
- const shellResources = useUnifiedResources();
- const storageRecoveryResources = useStorageRecoveryResources();
-
- const resourcesById = createMemo(() => {
- const resources = new Map<string, Resource>();
- for (const resource of shellResources.resources() || []) {
- if (resource?.id) resources.set(resource.id, resource);
- }
- for (const resource of storageRecoveryResources.resources() || []) {
- if (resource?.id) resources.set(resource.id, resource);
- }
- return resources;
- });
-
- const contextResourceId = createMemo<string | null>(() => {
- const parsed = parseGlobalResourceContextSearch(location.search || '');
- return parsed.resource || null;
- });
-
- const contextResource = createMemo<Resource | null>(() => {
- const resourceId = contextResourceId();
- if (!resourceId) return null;
- return resourcesById().get(resourceId) ?? null;
- });
-
- const contextLabel = createMemo(() => {
- const resource = contextResource();
- if (resource) {
- return getPreferredResourceDisplayName(resource) || resource.id;
- }
- return contextResourceId();
- });
-
- const hasGlobalResourceContext = createMemo(() => Boolean(contextResourceId()));
-
- const scheduleCurrentPathWithContext = (resourceId: string | null) => {
- const currentPath = `${location.pathname}${location.search || ''}`;
- const nextPath = buildPathWithGlobalResourceContext(currentPath, resourceId);
- if (nextPath === currentPath) {
- return;
- }
- routeStateNavigate.schedule(nextPath);
- };
-
- const clearGlobalResourceContext = () => {
- const currentPath = `${location.pathname}${location.search || ''}`;
- const nextPath = resolveGlobalResourceContextClearTarget({
- currentPath,
- resource: contextResource(),
- });
- if (!nextPath || nextPath === currentPath) {
- return;
- }
- routeStateNavigate.schedule(nextPath);
- };
-
- const setGlobalResourceContext = (resource: Resource | null | undefined) => {
- scheduleCurrentPathWithContext(resource?.id ?? null);
- };
- const setGlobalResourceContextById = (resourceId: string | null | undefined) => {
- const normalizedResourceId = resourceId?.trim() || null;
- if (!normalizedResourceId || !resourcesById().has(normalizedResourceId)) {
- scheduleCurrentPathWithContext(null);
- return;
- }
- scheduleCurrentPathWithContext(normalizedResourceId);
- };
-
- const buildPlatformRoute: GlobalResourceContextValue['buildPlatformRoute'] = (surface) => {
- const resource = contextResource();
- if (!resource) {
- return buildGlobalResourceContextBasePath(surface);
- }
- return buildSurfacePathWithGlobalResourceContext(surface, resource);
- };
-
- const canPinResource = (resource: Resource | null | undefined): boolean =>
- Boolean(resource?.id?.trim() && resourcesById().has(resource.id.trim()));
- const canPinResourceId = (resourceId: string | null | undefined): boolean =>
- Boolean(resourceId?.trim() && resourcesById().has(resourceId.trim()));
-
- const isPinnedGlobalResource = (resourceId: string | null | undefined): boolean =>
- Boolean(resourceId && contextResourceId() === resourceId.trim());
-
- createEffect(() => {
- const resource = contextResource();
- if (!resource) {
- return;
- }
- const currentPath = `${location.pathname}${location.search || ''}`;
- const surface = resolveGlobalResourceContextSurface(location.pathname);
- if (!surface) {
- return;
- }
-
- const targetBasePath = buildGlobalResourceContextBasePath(surface);
- const pathWithoutContext = buildPathWithGlobalResourceContext(currentPath, null);
- if (pathWithoutContext !== targetBasePath) {
- return;
- }
-
- const nextPath = buildPlatformRoute(surface);
- if (nextPath !== currentPath) {
- routeStateNavigate.schedule(nextPath);
- }
- });
-
- onCleanup(() => {
- routeStateNavigate.cleanup();
- });
-
- const value: GlobalResourceContextValue = {
- canPinResource,
- canPinResourceId,
- clearGlobalResourceContext,
- contextLabel,
- contextResource,
- contextResourceId,
- hasGlobalResourceContext,
- isPinnedGlobalResource,
- setGlobalResourceContext,
- setGlobalResourceContextById,
- buildPlatformRoute,
- };
-
- return (
- <GlobalResourceContext.Provider value={value}>{props.children}</GlobalResourceContext.Provider>
- );
-}
diff --git a/frontend-modern/src/features/globalResourceContext/GlobalResourceContextBar.tsx b/frontend-modern/src/features/globalResourceContext/GlobalResourceContextBar.tsx
deleted file mode 100644
index 63427fefda..0000000000
--- a/frontend-modern/src/features/globalResourceContext/GlobalResourceContextBar.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import { Show, type Component } from 'solid-js';
-import { useGlobalResourceContext } from './GlobalResourceContext';
-
-export const GlobalResourceContextBar: Component<{ class?: string }> = (props) => {
- const globalContext = useGlobalResourceContext();
-
- return (
- <Show when={globalContext.hasGlobalResourceContext()}>
- <div
- class={`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 px-1 py-1 ${props.class ?? ''}`.trim()}
- data-global-resource-context="true"
- >
- <span class="shrink-0 text-[11px] font-semibold tracking-[0.01em] text-sky-700 dark:text-sky-300">
- Context
- </span>
- <span
- class="min-w-0 truncate text-sm font-medium text-base-content"
- title={globalContext.contextLabel() ?? undefined}
- >
- {globalContext.contextLabel()}
- </span>
- <span class="min-w-0 truncate text-xs text-muted">
- Scoped across platform views
- </span>
- <button
- type="button"
- aria-label="Clear global context"
- class="ml-auto shrink-0 text-xs font-medium text-muted transition-colors hover:text-base-content focus-visible:text-base-content"
- onClick={() => globalContext.clearGlobalResourceContext()}
- >
- Clear
- </button>
- </div>
- </Show>
- );
-};
-
-export default GlobalResourceContextBar;
diff --git a/frontend-modern/src/features/globalResourceContext/__tests__/globalResourceContextModel.test.ts b/frontend-modern/src/features/globalResourceContext/__tests__/globalResourceContextModel.test.ts
deleted file mode 100644
index df016c4651..0000000000
--- a/frontend-modern/src/features/globalResourceContext/__tests__/globalResourceContextModel.test.ts
+++ /dev/null
@@ -1,88 +0,0 @@
-import { describe, expect, it } from 'vitest';
-
-import type { Resource } from '@/types/resource';
-import {
- areGlobalResourceContextPathsEquivalent,
- buildGlobalResourceContextBasePath,
- buildGlobalResourceContextScopedPath,
- buildSurfacePathWithGlobalResourceContext,
- resolveGlobalResourceContextClearTarget,
- resolveGlobalResourceContextSurface,
-} from '@/features/globalResourceContext/globalResourceContextModel';
-
-const makeAgent = (overrides: Partial<Resource> = {}): Resource =>
- ({
- id: 'pve-1',
- type: 'agent',
- name: 'pve1',
- displayName: 'pve1',
- platformId: 'pve-1',
- platformType: 'proxmox-pve',
- sourceType: 'agent',
- status: 'online',
- lastSeen: Date.now(),
- ...overrides,
- }) as Resource;
-
-describe('globalResourceContextModel', () => {
- it('resolves canonical surfaces from platform paths', () => {
- expect(resolveGlobalResourceContextSurface('/dashboard')).toBe('dashboard');
- expect(resolveGlobalResourceContextSurface('/infrastructure')).toBe('infrastructure');
- expect(resolveGlobalResourceContextSurface('/workloads')).toBe('workloads');
- expect(resolveGlobalResourceContextSurface('/storage')).toBe('storage');
- expect(resolveGlobalResourceContextSurface('/ceph')).toBe('storage');
- expect(resolveGlobalResourceContextSurface('/recovery')).toBe('recovery');
- expect(resolveGlobalResourceContextSurface('/settings')).toBeNull();
- });
-
- it('builds scoped platform paths from a canonical pinned resource', () => {
- const resource = makeAgent();
- expect(buildGlobalResourceContextBasePath('storage')).toBe('/storage');
- expect(buildGlobalResourceContextScopedPath('infrastructure', resource)).toBe(
- '/infrastructure?resource=pve-1',
- );
- expect(buildGlobalResourceContextScopedPath('workloads', resource)).toBe(
- '/workloads?agent=pve1',
- );
- expect(buildGlobalResourceContextScopedPath('storage', resource)).toBe(
- '/storage?source=proxmox-pve&node=pve-1',
- );
- expect(buildGlobalResourceContextScopedPath('recovery', resource)).toBe(
- '/recovery?platform=proxmox-pve&node=pve-1',
- );
- });
-
- it('adds the canonical global context query param to scoped surface routes', () => {
- expect(buildSurfacePathWithGlobalResourceContext('dashboard', makeAgent())).toBe(
- '/dashboard?contextResource=pve-1',
- );
- expect(buildSurfacePathWithGlobalResourceContext('storage', makeAgent())).toBe(
- '/storage?source=proxmox-pve&node=pve-1&contextResource=pve-1',
- );
- });
-
- it('treats paths with equivalent local filters as equal when only query ordering differs', () => {
- expect(
- areGlobalResourceContextPathsEquivalent(
- '/storage?source=proxmox-pve&node=pve-1&contextResource=pve-1',
- '/storage?node=pve-1&contextResource=pve-1&source=proxmox-pve',
- ),
- ).toBe(true);
- });
-
- it('clears back to the base platform path when the current route is only context-derived', () => {
- const target = resolveGlobalResourceContextClearTarget({
- currentPath: '/storage?source=proxmox-pve&node=pve-1&contextResource=pve-1',
- resource: makeAgent(),
- });
- expect(target).toBe('/storage');
- });
-
- it('only strips the context param when the page has diverged from the derived scoped path', () => {
- const target = resolveGlobalResourceContextClearTarget({
- currentPath: '/storage?source=proxmox-pve&node=pve-1&q=tank&contextResource=pve-1',
- resource: makeAgent(),
- });
- expect(target).toBe('/storage?source=proxmox-pve&node=pve-1&q=tank');
- });
-});
diff --git a/frontend-modern/src/features/globalResourceContext/globalResourceContextModel.ts b/frontend-modern/src/features/globalResourceContext/globalResourceContextModel.ts
deleted file mode 100644
index f1379c3e8e..0000000000
--- a/frontend-modern/src/features/globalResourceContext/globalResourceContextModel.ts
+++ /dev/null
@@ -1,122 +0,0 @@
-import { DASHBOARD_PATH } from '@/routing/resourceLinks';
-import {
- buildInfrastructurePath,
- buildInfrastructureResourceHref,
- buildPathWithGlobalResourceContext,
- buildRecoveryHrefForResource,
- buildRecoveryPath,
- buildStorageHrefForResource,
- buildStoragePath,
- buildWorkloadsHrefForResource,
- buildWorkloadsPath,
- stripGlobalResourceContextFromPath,
-} from '@/routing/resourceLinks';
-import type { Resource } from '@/types/resource';
-import { areSearchParamsEquivalent } from '@/utils/searchParams';
-
-export type GlobalResourceContextSurface =
- | 'dashboard'
- | 'infrastructure'
- | 'workloads'
- | 'storage'
- | 'recovery';
-
-const normalizePath = (path: string): string => {
- const url = new URL(path, 'http://pulse.local');
- const search = url.searchParams.toString();
- return `${url.pathname}${search ? `?${search}` : ''}`;
-};
-
-export const resolveGlobalResourceContextSurface = (
- pathname: string,
-): GlobalResourceContextSurface | null => {
- if (pathname.startsWith('/dashboard')) return 'dashboard';
- if (pathname.startsWith('/infrastructure')) return 'infrastructure';
- if (pathname.startsWith('/workloads')) return 'workloads';
- if (pathname.startsWith('/storage') || pathname.startsWith('/ceph')) return 'storage';
- if (pathname.startsWith('/recovery')) return 'recovery';
- return null;
-};
-
-export const buildGlobalResourceContextBasePath = (
- surface: GlobalResourceContextSurface,
-): string => {
- switch (surface) {
- case 'dashboard':
- return DASHBOARD_PATH;
- case 'infrastructure':
- return buildInfrastructurePath();
- case 'workloads':
- return buildWorkloadsPath();
- case 'storage':
- return buildStoragePath();
- case 'recovery':
- return buildRecoveryPath();
- }
-};
-
-export const buildGlobalResourceContextScopedPath = (
- surface: GlobalResourceContextSurface,
- resource: Resource | null | undefined,
-): string => {
- if (!resource) {
- return buildGlobalResourceContextBasePath(surface);
- }
-
- switch (surface) {
- case 'dashboard':
- return DASHBOARD_PATH;
- case 'infrastructure':
- return buildInfrastructureResourceHref(resource.id) ?? buildInfrastructurePath();
- case 'workloads':
- return buildWorkloadsHrefForResource(resource) ?? buildWorkloadsPath();
- case 'storage':
- return buildStorageHrefForResource(resource) ?? buildStoragePath();
- case 'recovery':
- return buildRecoveryHrefForResource(resource) ?? buildRecoveryPath();
- }
-};
-
-export const buildSurfacePathWithGlobalResourceContext = (
- surface: GlobalResourceContextSurface,
- resource: Resource | null | undefined,
-): string =>
- buildPathWithGlobalResourceContext(
- buildGlobalResourceContextScopedPath(surface, resource),
- resource?.id ?? null,
- );
-
-export const areGlobalResourceContextPathsEquivalent = (
- leftPath: string,
- rightPath: string,
-): boolean => {
- const leftUrl = new URL(stripGlobalResourceContextFromPath(leftPath), 'http://pulse.local');
- const rightUrl = new URL(stripGlobalResourceContextFromPath(rightPath), 'http://pulse.local');
- if (leftUrl.pathname !== rightUrl.pathname) {
- return false;
- }
- return areSearchParamsEquivalent(leftUrl.searchParams, rightUrl.searchParams);
-};
-
-export const resolveGlobalResourceContextClearTarget = (options: {
- currentPath: string;
- resource: Resource | null | undefined;
-}): string | null => {
- const surface = resolveGlobalResourceContextSurface(
- new URL(options.currentPath, 'http://pulse.local').pathname,
- );
- if (!surface) {
- const stripped = stripGlobalResourceContextFromPath(options.currentPath);
- return normalizePath(stripped) === normalizePath(options.currentPath) ? null : stripped;
- }
-
- const strippedCurrentPath = stripGlobalResourceContextFromPath(options.currentPath);
- const scopedPath = buildGlobalResourceContextScopedPath(surface, options.resource);
- if (areGlobalResourceContextPathsEquivalent(strippedCurrentPath, scopedPath)) {
- return buildGlobalResourceContextBasePath(surface);
- }
-
- return normalizePath(strippedCurrentPath) === normalizePath(options.currentPath)
- ? null
- : strippedCurrentPath;
-};
diff --git a/frontend-modern/src/features/recovery/useRecoverySurfaceState.ts b/frontend-modern/src/features/recovery/useRecoverySurfaceState.ts
index 7156dc4d1a..ce2cf19cd8 100644
--- a/frontend-modern/src/features/recovery/useRecoverySurfaceState.ts
+++ b/frontend-modern/src/features/recovery/useRecoverySurfaceState.ts
@@ -6,12 +6,7 @@ import { useRecoveryRollups } from '@/hooks/useRecoveryRollups';
import { useRecoveryPoints } from '@/hooks/useRecoveryPoints';
import { useRecoveryPointsFacets } from '@/hooks/useRecoveryPointsFacets';
import { useRecoveryPointsSeries } from '@/hooks/useRecoveryPointsSeries';
-import {
- buildPathWithGlobalResourceContext,
- buildRecoveryPath,
- parseGlobalResourceContextSearch,
- parseRecoveryLinkSearch,
-} from '@/routing/resourceLinks';
+import { buildRecoveryPath, parseRecoveryLinkSearch } from '@/routing/resourceLinks';
import type { ProtectionRollup, RecoveryOutcome } from '@/types/recovery';
import type { Resource } from '@/types/resource';
import { createRouteStateNavigateScheduler } from '@/utils/routeStateNavigation';
@@ -411,8 +406,7 @@ export function useRecoverySurfaceState() {
const currentPath = `${location.pathname}${location.search || ''}`;
if (hydratedLocationKey() !== currentPath) return;
- const nextPath = buildPathWithGlobalResourceContext(
- buildRecoveryPath({
+ const nextPath = buildRecoveryPath({
rollupId: rid || null,
view: workspaceView() !== defaultView ? workspaceView() : null,
query: queryFilter().trim() || null,
@@ -428,9 +422,7 @@ export function useRecoverySurfaceState() {
scope: scopeFilter() === 'workload' ? 'workload' : null,
node: nodeFilter() !== 'all' ? nodeFilter() : null,
namespace: namespaceFilter() !== 'all' ? namespaceFilter() : null,
- }),
- parseGlobalResourceContextSearch(location.search || '').resource || null,
- );
+ });
if (nextPath !== currentPath) {
routeStateNavigate.schedule(nextPath);
diff --git a/frontend-modern/src/routing/__tests__/resourceLinks.test.ts b/frontend-modern/src/routing/__tests__/resourceLinks.test.ts
index 6484972740..7a970582ca 100644
--- a/frontend-modern/src/routing/__tests__/resourceLinks.test.ts
+++ b/frontend-modern/src/routing/__tests__/resourceLinks.test.ts
@@ -1,10 +1,8 @@
import { describe, expect, it } from 'vitest';
import type { WorkloadGuest } from '@/types/workloads';
import {
- GLOBAL_CONTEXT_QUERY_PARAMS,
PMG_THRESHOLDS_PATH,
RECOVERY_QUERY_PARAMS,
- buildPathWithGlobalResourceContext,
buildInfrastructureResourceLink,
buildInfrastructureHrefForWorkload,
buildRecoveryPath,
@@ -17,13 +15,11 @@ import {
buildStoragePath,
buildWorkloadsHrefForResource,
buildWorkloadsPath,
- parseGlobalResourceContextSearch,
parseRecoveryLinkSearch,
INFRASTRUCTURE_QUERY_PARAMS,
parseStorageLinkSearch,
parseInfrastructureLinkSearch,
parseWorkloadsLinkSearch,
- stripGlobalResourceContextFromPath,
STORAGE_QUERY_PARAMS,
WORKLOADS_QUERY_PARAMS,
} from '@/routing/resourceLinks';
@@ -88,16 +84,6 @@ describe('resource link routing contract', () => {
expect(WORKLOADS_QUERY_PARAMS.summaryGroup).toBe('summaryGroup');
});
- it('builds and parses the canonical global resource context query param', () => {
- const scoped = buildPathWithGlobalResourceContext('/workloads?type=vm', 'agent:pve1');
- expect(scoped).toBe('/workloads?type=vm&contextResource=agent%3Apve1');
- expect(parseGlobalResourceContextSearch(scoped.slice('/workloads'.length))).toEqual({
- resource: 'agent:pve1',
- });
- expect(stripGlobalResourceContextFromPath(scoped)).toBe('/workloads?type=vm');
- expect(GLOBAL_CONTEXT_QUERY_PARAMS.resource).toBe('contextResource');
- });
-
it('canonicalizes legacy workloads type aliases when building links', () => {
expect(buildWorkloadsPath({ type: 'docker', platform: 'docker', agent: 'runtime-1' })).toBe(
'/workloads?type=app-container&platform=docker&agent=runtime-1',
@@ -343,22 +329,6 @@ describe('resource link routing contract', () => {
expect(href).toBe('/storage?source=truenas&node=truenas-main');
});
- it('builds storage deep links for proxmox agent resources', () => {
- const href = buildStorageHrefForResource({
- id: 'pve-1',
- type: 'agent',
- name: 'pve1',
- displayName: 'pve1',
- platformId: 'pve-1',
- platformType: 'proxmox-pve',
- sourceType: 'agent',
- status: 'online',
- lastSeen: Date.now(),
- } as any);
-
- expect(href).toBe('/storage?source=proxmox-pve&node=pve-1');
- });
-
it('builds storage deep links for hybrid agent resources with merged truenas sources', () => {
const href = buildStorageHrefForResource({
id: 'truenas-main',
@@ -413,22 +383,6 @@ describe('resource link routing contract', () => {
expect(href).toBe('/recovery?platform=truenas&node=truenas-main');
});
- it('builds recovery deep links for proxmox agent resources', () => {
- const href = buildRecoveryHrefForResource({
- id: 'pve-1',
- type: 'agent',
- name: 'pve1',
- displayName: 'pve1',
- platformId: 'pve-1',
- platformType: 'proxmox-pve',
- sourceType: 'agent',
- status: 'online',
- lastSeen: Date.now(),
- } as any);
-
- expect(href).toBe('/recovery?platform=proxmox-pve&node=pve-1');
- });
-
it('builds canonical shared surface links for top-level truenas systems', () => {
expect(
buildResourceSurfaceLinksForResource(
diff --git a/frontend-modern/src/routing/resourceLinks.ts b/frontend-modern/src/routing/resourceLinks.ts
index 160cf15030..2dbe89d7e9 100644
--- a/frontend-modern/src/routing/resourceLinks.ts
+++ b/frontend-modern/src/routing/resourceLinks.ts
@@ -84,10 +84,6 @@ export const RECOVERY_QUERY_PARAMS = {
query: 'q',
} as const;
-export const GLOBAL_CONTEXT_QUERY_PARAMS = {
- resource: 'contextResource',
-} as const;
-
const normalizeQueryValue = (value: string | null | undefined): string => (value || '').trim();
const normalizeQueryBooleanFlag = (value: string | null | undefined): string => {
const normalized = normalizeQueryValue(value).toLowerCase();
@@ -196,31 +192,6 @@ export const parseWorkloadsLinkSearch = (search: string) => {
};
};
-export const parseGlobalResourceContextSearch = (search: string) => {
- const params = new URLSearchParams(search);
- return {
- resource: normalizeQueryValue(params.get(GLOBAL_CONTEXT_QUERY_PARAMS.resource)),
- };
-};
-
-export const buildPathWithGlobalResourceContext = (
- path: string,
- resourceId: string | null | undefined,
-): string => {
- const url = new URL(path, 'http://pulse.local');
- const normalizedResourceId = normalizeQueryValue(resourceId);
- if (normalizedResourceId) {
- url.searchParams.set(GLOBAL_CONTEXT_QUERY_PARAMS.resource, normalizedResourceId);
- } else {
- url.searchParams.delete(GLOBAL_CONTEXT_QUERY_PARAMS.resource);
- }
- const nextSearch = url.searchParams.toString();
- return `${url.pathname}${nextSearch ? `?${nextSearch}` : ''}`;
-};
-
-export const stripGlobalResourceContextFromPath = (path: string): string =>
- buildPathWithGlobalResourceContext(path, null);
-
export const buildWorkloadsPath = (options: WorkloadsLinkOptions = {}): string => {
const params = new URLSearchParams();
const type = normalizeWorkloadsType(options.type);
@@ -506,16 +477,6 @@ export const buildStorageHrefForResource = (resource: Resource): string | null =
});
}
- if (
- resource.type === 'agent' &&
- (source === 'proxmox-pve' || source === 'proxmox-pbs' || source === 'truenas')
- ) {
- return buildStoragePath({
- source,
- node: resource.id,
- });
- }
-
return null;
};
@@ -561,16 +522,6 @@ export const buildRecoveryHrefForResource = (resource: Resource): string | null
});
}
- if (
- (resource.type === 'agent' || resource.type === 'pbs') &&
- (platform === 'proxmox-pve' || platform === 'proxmox-pbs')
- ) {
- return buildRecoveryPath({
- platform,
- node: resource.id,
- });
- }
-
return null;
};
diff --git a/tests/integration/tests/50-global-resource-context.spec.ts b/tests/integration/tests/50-global-resource-context.spec.ts
deleted file mode 100644
index 89a1dfccae..0000000000
--- a/tests/integration/tests/50-global-resource-context.spec.ts
+++ /dev/null
@@ -1,126 +0,0 @@
-import fs from "node:fs";
-import path from "node:path";
-import { fileURLToPath } from "node:url";
-import { expect, test as base } from "@playwright/test";
-
-import {
- createAuthenticatedStorageState,
- getMockMode,
- setMockMode,
-} from "./helpers";
-
-const __dirname = path.dirname(fileURLToPath(import.meta.url));
-
-type WorkerFixtures = {
- authStorageStatePath: string;
-};
-
-let mockModeWasEnabled: boolean | null = null;
-
-const escapeRegExp = (value: string): string =>
- value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
-
-const test = base.extend<Record<string, never>, WorkerFixtures>({
- storageState: async ({ authStorageStatePath }, use) => {
- await use(authStorageStatePath);
- },
- authStorageStatePath: [
- async ({ browser }, use, workerInfo) => {
- const storageStatePath = path.resolve(
- __dirname,
- "..",
- "..",
- "tmp",
- "playwright-auth",
- `global-resource-context-${workerInfo.project.name}.json`,
- );
- fs.mkdirSync(path.dirname(storageStatePath), { recursive: true });
- await createAuthenticatedStorageState(browser, storageStatePath);
- try {
- await use(storageStatePath);
- } finally {
- fs.rmSync(storageStatePath, { force: true });
- }
- },
- { scope: "worker" },
- ],
-});
-
-async function ensureMockModeEnabled(
- page: import("@playwright/test").Page,
-): Promise<void> {
- const state = await getMockMode(page);
- if (mockModeWasEnabled === null) {
- mockModeWasEnabled = state.enabled;
- }
- if (!state.enabled) {
- await setMockMode(page, true);
- }
-}
-
-test.afterAll(async ({ browser }) => {
- if (mockModeWasEnabled === false) {
- const page = await browser.newPage();
- try {
- await setMockMode(page, false);
- } finally {
- await page.close();
- }
- }
- mockModeWasEnabled = null;
-});
-
-test("pins a resource context in infrastructure and carries it across platform views", async ({
- page,
-}) => {
- await ensureMockModeEnabled(page);
-
- await page.goto("/infrastructure");
- await expect(page).toHaveURL(/\/infrastructure/);
-
- const pinButtons = page.getByRole("button", {
- name: /Set global context to/i,
- });
- await expect(pinButtons.first()).toBeAttached();
-
- const pinButton = pinButtons.first();
- await pinButton.scrollIntoViewIfNeeded();
-
- const pinButtonLabel = await pinButton.getAttribute("aria-label");
- expect(pinButtonLabel).toBeTruthy();
- const subjectLabel = pinButtonLabel?.replace(/^Set global context to\s+/i, "").trim() || "";
- expect(subjectLabel.length).toBeGreaterThan(0);
-
- const row = pinButton.locator("xpath=ancestor::tr[1]");
- const resourceId = await row.getAttribute("data-row-id");
- expect(resourceId).toBeTruthy();
- const escapedResourceId = escapeRegExp(resourceId || "");
-
- await pinButton.click();
-
- const contextBar = page.locator('[data-global-resource-context="true"]');
- await expect(contextBar).toContainText(subjectLabel);
- await expect(page).toHaveURL(new RegExp(`contextResource=${escapedResourceId}`));
-
- await page.getByRole("tab", { name: /Workloads/i }).click();
- await expect(page).toHaveURL(/\/workloads\?/);
- await expect(page).toHaveURL(new RegExp(`contextResource=${escapedResourceId}`));
- await expect(page).toHaveURL(/agent=/);
- await expect(contextBar).toContainText(subjectLabel);
-
- await page.getByRole("tab", { name: /^Storage$/ }).click();
- await expect(page).toHaveURL(/\/storage\?/);
- await expect(page).toHaveURL(new RegExp(`contextResource=${escapedResourceId}`));
- await expect(page).toHaveURL(new RegExp(`node=${escapedResourceId}`));
- await expect(page).toHaveURL(/source=proxmox-pve/);
-
- await page.getByRole("tab", { name: /^Recovery$/ }).click();
- await expect(page).toHaveURL(/\/recovery\?/);
- await expect(page).toHaveURL(new RegExp(`contextResource=${escapedResourceId}`));
- await expect(page).toHaveURL(new RegExp(`node=${escapedResourceId}`));
- await expect(page).toHaveURL(/platform=proxmox-pve/);
-
- await page.getByRole("button", { name: "Clear global context" }).click();
- await expect(contextBar).toHaveCount(0);
- await expect(page).toHaveURL(/\/recovery$/);
-});