mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-11-29 01:08:56 +01:00
The "No workload inventory available" empty state told every session to
"Review source credentials, permissions, and collection status in Settings
→ Infrastructure" and rendered a button to /settings/infrastructure. Since
755a88878 gated that nav item on the infrastructureRead capability, a
non-admin viewer cannot open the page — and once inventory source health is
served at monitoring:read, a viewer with a broken source lands on this exact
state and is pointed at a door that is locked for them.
Gate the call to action on the destination's own capability. Reusing
infrastructureRead rather than a second predicate is what keeps the link and
the nav gate from drifting apart. Without it the copy now names the action a
viewer can actually take: contact an administrator.
The signal did not exist outside Settings — infrastructureRead only reached
useSettingsAccess's local fetch, which runs when Settings mounts and so is no
help to a page deciding whether to link there. Publish it from the
/api/security/status resolve that useAppRuntimeState already performs on
mount, alongside the sessionCapabilities sync that hangs off the same call.
No new request is added. Unresolved sessions keep the link, matching how
settingsNavVisibility treats an unresolved capability set, so an admin never
flickers through the restricted copy.
The banner itself, the admin path, and the monitoring:read inventory-sources
call are all unchanged. The surface's inline fallback now defers to the
shared presentation helper instead of duplicating the copy, so the gate
cannot be bypassed by whichever path renders.
Verified on a scratch instance against real proxy-auth sessions: the viewer
(detailLevel authenticated, infrastructureRead false) gets the reworded copy
and no link at 1280x800 and 375x812, while the admin (privileged) is
byte-identical to before. Because the empty state is only reachable by a
viewer once inventory health is served at monitoring:read, the live exercise
ran with that branch's route present.
84 lines
3.2 KiB
TypeScript
84 lines
3.2 KiB
TypeScript
import { getInfrastructureSourceStrategyDescription } from '@/utils/infrastructureSettingsPresentation';
|
|
|
|
export function getWorkloadsInfrastructureEmptyState() {
|
|
return {
|
|
title: 'No infrastructure sources connected',
|
|
description: getInfrastructureSourceStrategyDescription(),
|
|
actionLabel: 'Add infrastructure source',
|
|
} as const;
|
|
}
|
|
|
|
export function getWorkloadsGuestsEmptyState(search: string) {
|
|
const normalized = search.trim();
|
|
return {
|
|
title: 'No guests found',
|
|
description:
|
|
normalized.length > 0
|
|
? `No guests match your search "${normalized}"`
|
|
: 'No guests match your current filters',
|
|
} as const;
|
|
}
|
|
|
|
/**
|
|
* `canReviewInfrastructureSources` reflects the session's `infrastructureRead`
|
|
* capability — the same gate that decides whether Settings → Infrastructure is
|
|
* in the nav at all. A viewer without it reaches this state (the inventory
|
|
* source issues that trigger it are served at monitoring:read), so the copy has
|
|
* to stop naming a page they cannot open and point them at someone who can.
|
|
*/
|
|
export function getWorkloadsNoInventoryState(canReviewInfrastructureSources = true) {
|
|
return {
|
|
title: 'No workload inventory available',
|
|
description: canReviewInfrastructureSources
|
|
? 'Pulse has infrastructure sources, but no VM, container, or pod inventory is available right now. Review source credentials, permissions, and collection status in Settings → Infrastructure.'
|
|
: 'Pulse has infrastructure sources, but no VM, container, or pod inventory is available right now. Contact a Pulse administrator to check source credentials, permissions, and collection status.',
|
|
actionLabel: canReviewInfrastructureSources ? 'Review infrastructure sources' : undefined,
|
|
} as const;
|
|
}
|
|
|
|
export function getWorkloadsLoadingState(reconnecting: boolean) {
|
|
return {
|
|
title: 'Loading workloads...',
|
|
description: reconnecting
|
|
? 'Reconnecting to monitoring service…'
|
|
: 'Connecting to monitoring service',
|
|
} as const;
|
|
}
|
|
|
|
export function getWorkloadsDisconnectedState(reconnecting: boolean) {
|
|
return {
|
|
title: 'Connection lost',
|
|
description: reconnecting
|
|
? 'Attempting to reconnect…'
|
|
: 'Unable to connect to the backend server',
|
|
actionLabel: reconnecting ? undefined : 'Reconnect now',
|
|
} as const;
|
|
}
|
|
|
|
export function getWorkloadsDisconnectedBannerState(reconnecting: boolean) {
|
|
return {
|
|
title: 'Connection lost',
|
|
description: reconnecting
|
|
? 'Real-time data is reconnecting. Showing last-known state.'
|
|
: 'Real-time data is currently unavailable. Showing last-known state.',
|
|
actionLabel: 'Reconnect',
|
|
} as const;
|
|
}
|
|
|
|
export function getWorkloadsUnavailableState() {
|
|
return {
|
|
title: 'Workloads unavailable',
|
|
description: 'Real-time workload data is currently unavailable. Reconnect to try again.',
|
|
actionLabel: 'Reconnect',
|
|
} as const;
|
|
}
|
|
|
|
export function getWorkloadsNoResourcesState() {
|
|
return {
|
|
title: 'Connect your first infrastructure source',
|
|
description:
|
|
'Workloads appear after Pulse receives its first monitored system. Add an infrastructure source with API inventory, Agent telemetry, or both, then return here to inspect running VMs, containers, and pods.',
|
|
actionLabel: 'Add infrastructure source',
|
|
} as const;
|
|
}
|