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.

feat(connections): wire vmware/truenas edit through ConnectionEditor

rcourtman9bd5d37f6a20
diff --git a/frontend-modern/src/components/Settings/ConnectionDetailDrawer.tsx b/frontend-modern/src/components/Settings/ConnectionDetailDrawer.tsx
index 1f5218dbec..4eb7db1b84 100644
--- a/frontend-modern/src/components/Settings/ConnectionDetailDrawer.tsx
+++ b/frontend-modern/src/components/Settings/ConnectionDetailDrawer.tsx
@@ -10,7 +10,13 @@ interface ConnectionDetailDrawerProps {
onEdit?: (connection: Connection) => void;
}
-const EDITABLE_CONNECTION_TYPES: readonly Connection['type'][] = ['pve', 'pbs', 'pmg'];
+const EDITABLE_CONNECTION_TYPES: readonly Connection['type'][] = [
+ 'pve',
+ 'pbs',
+ 'pmg',
+ 'vmware',
+ 'truenas',
+];
const REMOVE_CONFIRM_TIMEOUT_MS = 4000;
diff --git a/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/TrueNASCredentialSlot.tsx b/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/TrueNASCredentialSlot.tsx
index ab4443683f..f8a18cd7d0 100644
--- a/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/TrueNASCredentialSlot.tsx
+++ b/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/TrueNASCredentialSlot.tsx
@@ -8,6 +8,7 @@ import {
formSelect,
} from '@/components/shared/Form';
import { MonitoredSystemAdmissionPreview } from '../../MonitoredSystemAdmissionPreview';
+import type { TrueNASConnection } from '@/api/truenas';
import type { TrueNASSettingsPanelState } from '../../useTrueNASSettingsPanelState';
const buttonClass =
@@ -17,6 +18,7 @@ const primaryButtonClass =
export interface TrueNASCredentialSlotProps {
state: TrueNASSettingsPanelState;
+ editingConnection?: TrueNASConnection | null;
onCancel: () => void;
onSaved: () => void;
}
@@ -26,7 +28,11 @@ export const TrueNASCredentialSlot: Component<TrueNASCredentialSlotProps> = (pro
onMount(() => {
if (!props.state.dialogOpen()) {
- props.state.openCreateDialog();
+ if (props.editingConnection) {
+ props.state.openEditDialog(props.editingConnection);
+ } else {
+ props.state.openCreateDialog();
+ }
}
primed = true;
});
diff --git a/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/VMwareCredentialSlot.tsx b/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/VMwareCredentialSlot.tsx
index e8d97422e3..3a1103f7ea 100644
--- a/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/VMwareCredentialSlot.tsx
+++ b/frontend-modern/src/components/Settings/ConnectionEditor/CredentialSlots/VMwareCredentialSlot.tsx
@@ -9,6 +9,7 @@ import {
formLabel,
} from '@/components/shared/Form';
import { MonitoredSystemAdmissionPreview } from '../../MonitoredSystemAdmissionPreview';
+import type { VMwareConnection } from '@/api/vmware';
import type { VMwareSettingsPanelState } from '../../useVMwareSettingsPanelState';
const buttonClass =
@@ -18,6 +19,7 @@ const primaryButtonClass =
export interface VMwareCredentialSlotProps {
state: VMwareSettingsPanelState;
+ editingConnection?: VMwareConnection | null;
onCancel: () => void;
onSaved: () => void;
}
@@ -27,7 +29,11 @@ export const VMwareCredentialSlot: Component<VMwareCredentialSlotProps> = (props
onMount(() => {
if (!props.state.dialogOpen()) {
- props.state.openCreateDialog();
+ if (props.editingConnection) {
+ props.state.openEditDialog(props.editingConnection);
+ } else {
+ props.state.openCreateDialog();
+ }
}
primed = true;
});
diff --git a/frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx b/frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx
index f0d30b728f..2b48180b83 100644
--- a/frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx
+++ b/frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx
@@ -10,6 +10,8 @@ import { NodeCredentialSlot } from './ConnectionEditor/CredentialSlots/NodeCrede
import { TrueNASCredentialSlot } from './ConnectionEditor/CredentialSlots/TrueNASCredentialSlot';
import { VMwareCredentialSlot } from './ConnectionEditor/CredentialSlots/VMwareCredentialSlot';
import type { Connection, ConnectionType } from '@/api/connections';
+import type { TrueNASConnection } from '@/api/truenas';
+import type { VMwareConnection } from '@/api/vmware';
import type { NodeConfigWithStatus } from '@/types/nodes';
import { InfrastructureInstallerSection } from './InfrastructureInstallerSection';
import {
@@ -64,6 +66,21 @@ const InfrastructureWorkspaceContent: Component<InfrastructureWorkspaceProps> =
return accessor().find((node) => node.name === connection.name) ?? null;
};
+ const aggregatorSuffix = (id: string): string => {
+ const colonIndex = id.indexOf(':');
+ return colonIndex === -1 ? id : id.slice(colonIndex + 1);
+ };
+
+ const findEditableVMware = (connection: Connection): VMwareConnection | null => {
+ const suffix = aggregatorSuffix(connection.id);
+ return props.vmwareSettings.connections().find((conn) => conn.id === suffix) ?? null;
+ };
+
+ const findEditableTrueNAS = (connection: Connection): TrueNASConnection | null => {
+ const suffix = aggregatorSuffix(connection.id);
+ return props.trueNASSettings.connections().find((conn) => conn.id === suffix) ?? null;
+ };
+
// Redirect legacy deep links and pre-select the matching type in the editor.
createEffect(() => {
const path = location.pathname;
@@ -182,8 +199,54 @@ const InfrastructureWorkspaceContent: Component<InfrastructureWorkspaceProps> =
<Match when={mode() === 'edit' && editingConnection()}>
{(accessor) => {
const connection = accessor();
- const editingNode = findEditableNode(connection);
- if (!editingNode) {
+ const editableSlot = (() => {
+ switch (connection.type) {
+ case 'pve':
+ case 'pbs':
+ case 'pmg': {
+ const node = findEditableNode(connection);
+ return node
+ ? { kind: 'node' as const, render: () => renderNodeSlot(connection.type as 'pve' | 'pbs' | 'pmg', node) }
+ : null;
+ }
+ case 'vmware': {
+ const vmware = findEditableVMware(connection);
+ return vmware
+ ? {
+ kind: 'vmware' as const,
+ render: () => (
+ <VMwareCredentialSlot
+ state={props.vmwareSettings}
+ editingConnection={vmware}
+ onCancel={exitEditMode}
+ onSaved={handleEditSaved}
+ />
+ ),
+ }
+ : null;
+ }
+ case 'truenas': {
+ const truenas = findEditableTrueNAS(connection);
+ return truenas
+ ? {
+ kind: 'truenas' as const,
+ render: () => (
+ <TrueNASCredentialSlot
+ state={props.trueNASSettings}
+ editingConnection={truenas}
+ onCancel={exitEditMode}
+ onSaved={handleEditSaved}
+ />
+ ),
+ }
+ : null;
+ }
+ default:
+ return null;
+ }
+ })();
+
+ if (!editableSlot) {
return (
<div class="space-y-4">
<div class="flex items-center justify-between gap-3">
@@ -227,10 +290,7 @@ const InfrastructureWorkspaceContent: Component<InfrastructureWorkspaceProps> =
</div>
<div class="rounded-lg border border-border bg-surface p-4">
- {renderNodeSlot(
- connection.type as 'pve' | 'pbs' | 'pmg',
- editingNode,
- )}
+ {editableSlot.render()}
</div>
</div>
);
diff --git a/frontend-modern/src/components/Settings/__tests__/ConnectionDetailDrawer.test.tsx b/frontend-modern/src/components/Settings/__tests__/ConnectionDetailDrawer.test.tsx
index b86e6de121..257cfe01e4 100644
--- a/frontend-modern/src/components/Settings/__tests__/ConnectionDetailDrawer.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/ConnectionDetailDrawer.test.tsx
@@ -91,6 +91,44 @@ describe('ConnectionDetailDrawer', () => {
expect(onEdit.mock.calls[0][0]).toMatchObject({ id: 'pve:tower', type: 'pve' });
});
+ it('shows Edit for vmware connections', () => {
+ const onEdit = vi.fn();
+ render(() => (
+ <ConnectionDetailDrawer
+ connection={() =>
+ pveConnection({ id: 'vmware:abc', type: 'vmware', name: 'vcsa' })
+ }
+ onClose={() => {}}
+ onMutated={() => {}}
+ onEdit={onEdit}
+ />
+ ));
+
+ const editButton = screen.getByRole('button', { name: 'Edit' });
+ fireEvent.click(editButton);
+ expect(onEdit).toHaveBeenCalledTimes(1);
+ expect(onEdit.mock.calls[0][0]).toMatchObject({ id: 'vmware:abc', type: 'vmware' });
+ });
+
+ it('shows Edit for truenas connections', () => {
+ const onEdit = vi.fn();
+ render(() => (
+ <ConnectionDetailDrawer
+ connection={() =>
+ pveConnection({ id: 'truenas:xyz', type: 'truenas', name: 'tower' })
+ }
+ onClose={() => {}}
+ onMutated={() => {}}
+ onEdit={onEdit}
+ />
+ ));
+
+ const editButton = screen.getByRole('button', { name: 'Edit' });
+ fireEvent.click(editButton);
+ expect(onEdit).toHaveBeenCalledTimes(1);
+ expect(onEdit.mock.calls[0][0]).toMatchObject({ id: 'truenas:xyz', type: 'truenas' });
+ });
+
it('omits Edit for agent connections (edit is not yet supported)', () => {
render(() => (
<ConnectionDetailDrawer