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.

Promote machine discovery into drawer tabs

rcourtmand168c6262c18
diff --git a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
index 136030177c..52c54152a7 100644
--- a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
+++ b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawer.tsx
@@ -1,4 +1,4 @@
-import { Show, For } from 'solid-js';
+import { Show, For, Suspense } from 'solid-js';
import type { Component } from 'solid-js';
import type { Resource } from '@/types/resource';
import { StatusDot } from '@/components/shared/StatusDot';
@@ -14,6 +14,8 @@ import {
import { ResourceDetailDrawerDebugTab } from './ResourceDetailDrawerDebugTab';
import { ResourceDetailDrawerOverviewTab } from './ResourceDetailDrawerOverviewTab';
import { useResourceDetailDrawerState } from './useResourceDetailDrawerState';
+import { DiscoveryTab } from '@/components/Discovery/DiscoveryTab';
+import { getDiscoveryLoadingState } from '@/utils/discoveryPresentation';
import {
DEFAULT_RESOURCE_DETAIL_DRAWER_PRESENTATION,
type ResourceDetailDrawerPresentation,
@@ -176,6 +178,39 @@ const DrawerContent: Component<ResourceDetailDrawerProps> = (props) => {
</Show>
</div>
+ {/* Discovery Tab */}
+ <div
+ class={drawer.activeTab() === 'discovery' ? '' : 'hidden'}
+ style={{ 'overflow-anchor': 'none' }}
+ >
+ <Show when={drawer.activeTab() === 'discovery'}>
+ <Show
+ when={drawer.discoveryConfig()}
+ fallback={<TabAvailabilityNotice message="Discovery is unavailable." />}
+ >
+ {(config) => (
+ <Suspense
+ fallback={
+ <div class="flex items-center justify-center py-8">
+ <div class="h-6 w-6 animate-spin rounded-full border-2 border-blue-500 border-t-transparent" />
+ <span class="ml-2 text-sm text-muted">{getDiscoveryLoadingState().text}</span>
+ </div>
+ }
+ >
+ <DiscoveryTab
+ resourceType={config().resourceType}
+ agentId={config().agentId}
+ resourceId={config().resourceId}
+ hostname={config().hostname}
+ commandsEnabled={drawer.agentMeta()?.commandsEnabled}
+ showManualRunAction
+ />
+ </Suspense>
+ )}
+ </Show>
+ </Show>
+ </div>
+
{/* PMG Mail Tab */}
<div
class={drawer.activeTab() === 'mail' ? '' : 'hidden'}
diff --git a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx
index c2db3b0dc9..f65a3da7dd 100644
--- a/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx
+++ b/frontend-modern/src/components/Infrastructure/ResourceDetailDrawerOverviewTab.tsx
@@ -585,50 +585,53 @@ export const ResourceDetailDrawerOverviewTab: Component<ResourceDetailDrawerOver
embedded
/>
- <div
- class="space-y-2 border-t border-border pt-3"
- data-testid="resource-access-analysis"
- >
- <div class="flex flex-wrap items-start justify-between gap-3">
- <div>
- <div class="text-[10px] font-medium uppercase tracking-wide text-base-content">
- Analysis
- </div>
- <Show when={drawer.discoveryContextSummary()}>
- <div class="mt-1 text-[10px] text-base-content">
- {drawer.discoveryContextSummary()}
+ <Show when={!drawer.hasDiscoveryTab()}>
+ <div
+ class="space-y-2 border-t border-border pt-3"
+ data-testid="resource-access-analysis"
+ >
+ <div class="flex flex-wrap items-start justify-between gap-3">
+ <div>
+ <div class="text-[10px] font-medium uppercase tracking-wide text-base-content">
+ Analysis
</div>
- </Show>
+ <Show when={drawer.discoveryContextSummary()}>
+ <div class="mt-1 text-[10px] text-base-content">
+ {drawer.discoveryContextSummary()}
+ </div>
+ </Show>
+ </div>
+ <button
+ type="button"
+ onClick={() => drawer.setShowDiscoveryContext((value) => !value)}
+ class="inline-flex items-center rounded-md border border-border bg-surface px-2.5 py-1 text-[10px] font-medium text-base-content transition-colors hover:bg-base"
+ >
+ {drawer.showDiscoveryContext() ? 'Hide analysis' : 'Open analysis'}
+ </button>
</div>
- <button
- type="button"
- onClick={() => drawer.setShowDiscoveryContext((value) => !value)}
- class="inline-flex items-center rounded-md border border-border bg-surface px-2.5 py-1 text-[10px] font-medium text-base-content transition-colors hover:bg-base"
- >
- {drawer.showDiscoveryContext() ? 'Hide analysis' : 'Open analysis'}
- </button>
- </div>
- <Show when={drawer.showDiscoveryContext()}>
- <Suspense
- fallback={
- <div class="flex items-center justify-center py-8">
- <div class="animate-spin h-6 w-6 border-2 border-blue-500 border-t-transparent rounded-full" />
- <span class="ml-2 text-sm text-muted">
- {getDiscoveryLoadingState().text}
- </span>
- </div>
- }
- >
- <DiscoveryTab
- resourceType={config().resourceType}
- agentId={config().agentId}
- resourceId={config().resourceId}
- hostname={config().hostname}
- />
- </Suspense>
- </Show>
- </div>
+ <Show when={drawer.showDiscoveryContext()}>
+ <Suspense
+ fallback={
+ <div class="flex items-center justify-center py-8">
+ <div class="animate-spin h-6 w-6 border-2 border-blue-500 border-t-transparent rounded-full" />
+ <span class="ml-2 text-sm text-muted">
+ {getDiscoveryLoadingState().text}
+ </span>
+ </div>
+ }
+ >
+ <DiscoveryTab
+ resourceType={config().resourceType}
+ agentId={config().agentId}
+ resourceId={config().resourceId}
+ hostname={config().hostname}
+ commandsEnabled={drawer.agentMeta()?.commandsEnabled}
+ />
+ </Suspense>
+ </Show>
+ </div>
+ </Show>
</div>
)}
</Show>
diff --git a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.machine-history.test.tsx b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.machine-history.test.tsx
index f3102a8fe8..8b333ab14e 100644
--- a/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.machine-history.test.tsx
+++ b/frontend-modern/src/components/Infrastructure/__tests__/ResourceDetailDrawer.machine-history.test.tsx
@@ -33,6 +33,25 @@ vi.mock('@/components/Workloads/GuestDrawerHistory', () => ({
),
}));
+vi.mock('@/components/Discovery/DiscoveryTab', () => ({
+ DiscoveryTab: (props: {
+ resourceType: string;
+ agentId?: string;
+ resourceId: string;
+ hostname: string;
+ showManualRunAction?: boolean;
+ }) => (
+ <div
+ data-testid="machine-discovery"
+ data-resource-type={props.resourceType}
+ data-agent-id={props.agentId}
+ data-resource-id={props.resourceId}
+ data-hostname={props.hostname}
+ data-manual-run={String(props.showManualRunAction === true)}
+ />
+ ),
+}));
+
const resource = (overrides: Partial<Resource>): Resource =>
({
id: overrides.id ?? 'agent-1',
@@ -90,6 +109,34 @@ describe('ResourceDetailDrawer machine metrics history', () => {
expect(screen.queryByRole('button', { name: 'History' })).not.toBeInTheDocument();
});
+ it('adds a first-class discovery tab for Pulse Agent machines', async () => {
+ render(() => (
+ <ResourceDetailDrawer
+ resource={resource({
+ id: 'agent-mac-mini',
+ displayName: 'Mac Mini',
+ discoveryTarget: {
+ resourceType: 'agent',
+ agentId: 'agent-mac-mini',
+ resourceId: 'agent-mac-mini',
+ hostname: 'richard-mac-mini.local',
+ },
+ })}
+ />
+ ));
+
+ expect(screen.getByRole('button', { name: 'Discovery' })).toBeInTheDocument();
+
+ await fireEvent.click(screen.getByRole('button', { name: 'Discovery' }));
+
+ const discovery = screen.getByTestId('machine-discovery');
+ expect(discovery).toHaveAttribute('data-resource-type', 'agent');
+ expect(discovery).toHaveAttribute('data-agent-id', 'agent-mac-mini');
+ expect(discovery).toHaveAttribute('data-resource-id', 'agent-mac-mini');
+ expect(discovery).toHaveAttribute('data-hostname', 'richard-mac-mini.local');
+ expect(discovery).toHaveAttribute('data-manual-run', 'true');
+ });
+
it('opens agent machine facts by default in table-row presentation', () => {
render(() => (
<ResourceDetailDrawer
diff --git a/frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts b/frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts
index a27397c70e..0c66963c64 100644
--- a/frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts
+++ b/frontend-modern/src/components/Infrastructure/resourceDetailMappers.ts
@@ -59,6 +59,7 @@ export type AgentPlatformData = {
raid?: HostRAIDArray[];
cpuCount?: number;
memory?: Partial<Memory>;
+ commandsEnabled?: boolean;
};
export type PBSPlatformData = {
@@ -313,6 +314,7 @@ export const toAgentFromResource = (
uptimeSeconds: agent.uptimeSeconds ?? resource.uptime ?? 0,
lastSeen: resource.lastSeen,
agentVersion: agent.agentVersion,
+ commandsEnabled: agent.commandsEnabled,
tags: resource.tags,
} as Agent;
};
diff --git a/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerDerivedState.ts b/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerDerivedState.ts
index 9e6399f155..aa277cdf3a 100644
--- a/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerDerivedState.ts
+++ b/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerDerivedState.ts
@@ -19,6 +19,7 @@ import {
getPreferredResourceClusterName,
getPreferredInfrastructureDisplayName,
} from '@/utils/resourceIdentity';
+import { isPulseAgentPlatformResource } from '@/utils/agentResources';
import { areSystemSettingsLoaded, shouldHideDockerUpdateActions } from '@/stores/systemSettings';
import {
getResourcePolicyBadges,
@@ -80,7 +81,15 @@ import {
} from './resourceDetailDrawerTrueNASModel';
import { getResourceHealthIssuePresentation } from './resourceHealthPresentation';
-type DrawerTab = 'overview' | 'history' | 'mail' | 'namespaces' | 'deployments' | 'swarm' | 'debug';
+type DrawerTab =
+ | 'overview'
+ | 'history'
+ | 'discovery'
+ | 'mail'
+ | 'namespaces'
+ | 'deployments'
+ | 'swarm'
+ | 'debug';
interface ResourceDrawerDiscoverySourceKey {
type: DiscoveryResourceType;
@@ -336,6 +345,9 @@ export const useResourceDetailDrawerDerivedState = (
getResourceMetricsHistoryFallbackMetrics(resource),
);
const hasMetricsHistory = createMemo(() => resourceSupportsMetricsHistory(resource));
+ const hasDiscoveryTab = createMemo(
+ () => isPulseAgentPlatformResource(resource) && Boolean(discoveryConfig()),
+ );
const relatedLinks = createMemo(() => buildRelatedLinks(resource, displayName()));
const accessSummary = createMemo(() =>
@@ -367,6 +379,7 @@ export const useResourceDetailDrawerDerivedState = (
const base = [
{ id: 'overview' as DrawerTab, label: 'Overview' },
...(hasMetricsHistory() ? [{ id: 'history' as DrawerTab, label: 'History' }] : []),
+ ...(hasDiscoveryTab() ? [{ id: 'discovery' as DrawerTab, label: 'Discovery' }] : []),
...(resource.type === 'pmg' ? [{ id: 'mail' as DrawerTab, label: 'Mail' }] : []),
...(resource.type === 'k8s-cluster'
? [{ id: 'namespaces' as DrawerTab, label: 'Namespaces' }]
@@ -462,6 +475,7 @@ export const useResourceDetailDrawerDerivedState = (
metricsHistoryTarget,
metricsHistoryFallbackMetrics,
hasMetricsHistory,
+ hasDiscoveryTab,
hasVMwareDetails,
vmwareDetailsSummary,
vmwareDetailSections,
diff --git a/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerState.ts b/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerState.ts
index 404ad8c35e..a84d8dbd79 100644
--- a/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerState.ts
+++ b/frontend-modern/src/components/Infrastructure/useResourceDetailDrawerState.ts
@@ -9,7 +9,15 @@ import { useResourceDetailDrawerHistoryState } from './useResourceDetailDrawerHi
import { useResourceDetailDrawerDerivedState } from './useResourceDetailDrawerDerivedState';
import type { ResourceDetailDrawerPresentation } from './resourceDetailDrawerPresentation';
-type DrawerTab = 'overview' | 'history' | 'mail' | 'namespaces' | 'deployments' | 'swarm' | 'debug';
+type DrawerTab =
+ | 'overview'
+ | 'history'
+ | 'discovery'
+ | 'mail'
+ | 'namespaces'
+ | 'deployments'
+ | 'swarm'
+ | 'debug';
export interface UseResourceDetailDrawerStateOptions {
resource: Resource;