mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-21 15:46:43 +00:00
feat(nodes): hide hub-only views when active node is remote (#1007)
* feat(nodes): hide hub-only views when active node is remote Fleet, Schedules, Audit, Logs, and Auto-Update operate on hub-owned state (node registry, fleet schedules, centralized audit, fleet-wide log aggregation, fleet-wide update preview). When the active node is remote, proxying those surfaces would show that remote's own disconnected state instead of the hub's. Hide them from the nav strip and force-redirect to Home if one was open during the node switch. Backend hubOnlyGuard middleware sits between nodeContextMiddleware and the remote proxy and rejects /api/scheduled-tasks, /api/audit-log, and /api/notification-routes with 403 + HUB_ONLY_ENDPOINT when nodeId resolves to a remote, closing the script-bypass path the UI gating cannot reach. Settings sub-sections were already gated via the hiddenOnRemote registry; this extends the same model to top-level views. * docs(nodes): note hub-only visibility on Fleet, Schedules, Audit, Logs, Auto-Update Each of the five hub-only feature pages now points readers to the canonical "What top-level views show when a remote node is active" section in multi-node.mdx, so users landing directly on a feature page understand why the nav item disappears when they switch to a remote node.
This commit is contained in:
@@ -2,6 +2,7 @@ import { Suspense, lazy, type ReactNode } from 'react';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { AdmiralGate } from '../AdmiralGate';
|
||||
import { CapabilityGate } from '../CapabilityGate';
|
||||
import { HubOnlyGate } from '../HubOnlyGate';
|
||||
import LazyBoundary from '../LazyBoundary';
|
||||
import { SettingsPage } from '../settings/SettingsPage';
|
||||
import type { SectionId } from '../settings/types';
|
||||
@@ -10,6 +11,7 @@ import ResourcesView from '../ResourcesView';
|
||||
import HomeDashboard from '../HomeDashboard';
|
||||
import type { NotificationItem } from '../dashboard/types';
|
||||
import type { ScheduleTaskPrefill } from '../ScheduledOperationsView';
|
||||
import type { ActiveView } from './hooks/useViewNavigationState';
|
||||
|
||||
// Paid-tier views and the security-history overlay are loaded on demand.
|
||||
// Their internal PaidGate / AdmiralGate / CapabilityGate wrappers render
|
||||
@@ -59,18 +61,7 @@ function LazyView({ children }: { children: ReactNode }) {
|
||||
);
|
||||
}
|
||||
|
||||
export type ActiveView =
|
||||
| 'dashboard'
|
||||
| 'editor'
|
||||
| 'host-console'
|
||||
| 'resources'
|
||||
| 'templates'
|
||||
| 'global-observability'
|
||||
| 'fleet'
|
||||
| 'audit-log'
|
||||
| 'scheduled-ops'
|
||||
| 'auto-updates'
|
||||
| 'settings';
|
||||
export type { ActiveView };
|
||||
|
||||
export interface ViewRouterProps {
|
||||
activeView: ActiveView;
|
||||
@@ -148,50 +139,60 @@ export function ViewRouter({
|
||||
}
|
||||
if (activeView === 'global-observability') {
|
||||
return (
|
||||
<LazyView>
|
||||
<GlobalObservabilityView />
|
||||
</LazyView>
|
||||
<HubOnlyGate>
|
||||
<LazyView>
|
||||
<GlobalObservabilityView />
|
||||
</LazyView>
|
||||
</HubOnlyGate>
|
||||
);
|
||||
}
|
||||
if (activeView === 'fleet') {
|
||||
return (
|
||||
<CapabilityGate capability="fleet" featureName="Fleet Management">
|
||||
<LazyView>
|
||||
<FleetView onNavigateToNode={onFleetNavigateToNode} />
|
||||
</LazyView>
|
||||
</CapabilityGate>
|
||||
<HubOnlyGate>
|
||||
<CapabilityGate capability="fleet" featureName="Fleet Management">
|
||||
<LazyView>
|
||||
<FleetView onNavigateToNode={onFleetNavigateToNode} />
|
||||
</LazyView>
|
||||
</CapabilityGate>
|
||||
</HubOnlyGate>
|
||||
);
|
||||
}
|
||||
if (activeView === 'audit-log') {
|
||||
return (
|
||||
<CapabilityGate capability="audit-log" featureName="Audit Log">
|
||||
<LazyView>
|
||||
<AuditLogView />
|
||||
</LazyView>
|
||||
</CapabilityGate>
|
||||
<HubOnlyGate>
|
||||
<CapabilityGate capability="audit-log" featureName="Audit Log">
|
||||
<LazyView>
|
||||
<AuditLogView />
|
||||
</LazyView>
|
||||
</CapabilityGate>
|
||||
</HubOnlyGate>
|
||||
);
|
||||
}
|
||||
if (activeView === 'auto-updates') {
|
||||
return (
|
||||
<CapabilityGate capability="auto-updates" featureName="Auto-Update Readiness">
|
||||
<LazyView>
|
||||
<AutoUpdateReadinessView />
|
||||
</LazyView>
|
||||
</CapabilityGate>
|
||||
<HubOnlyGate>
|
||||
<CapabilityGate capability="auto-updates" featureName="Auto-Update Readiness">
|
||||
<LazyView>
|
||||
<AutoUpdateReadinessView />
|
||||
</LazyView>
|
||||
</CapabilityGate>
|
||||
</HubOnlyGate>
|
||||
);
|
||||
}
|
||||
if (activeView === 'scheduled-ops') {
|
||||
return (
|
||||
<CapabilityGate capability="scheduled-ops" featureName="Scheduled Operations">
|
||||
<LazyView>
|
||||
<ScheduledOperationsView
|
||||
filterNodeId={filterNodeId}
|
||||
onClearFilter={onClearScheduledOpsFilter}
|
||||
prefill={schedulePrefill}
|
||||
onPrefillConsumed={onPrefillConsumed}
|
||||
/>
|
||||
</LazyView>
|
||||
</CapabilityGate>
|
||||
<HubOnlyGate>
|
||||
<CapabilityGate capability="scheduled-ops" featureName="Scheduled Operations">
|
||||
<LazyView>
|
||||
<ScheduledOperationsView
|
||||
filterNodeId={filterNodeId}
|
||||
onClearFilter={onClearScheduledOpsFilter}
|
||||
prefill={schedulePrefill}
|
||||
onPrefillConsumed={onPrefillConsumed}
|
||||
/>
|
||||
</LazyView>
|
||||
</CapabilityGate>
|
||||
</HubOnlyGate>
|
||||
);
|
||||
}
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user