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.

Keep saved configuration recovery truthful through reader withdrawal

pulse-triage[bot]773a60da1822
diff --git a/frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx b/frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx
index f82a0a58fb..f437fc089a 100644
--- a/frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx
+++ b/frontend-modern/src/components/Settings/InfrastructureWorkspace.tsx
@@ -726,6 +726,42 @@ const InfrastructureWorkspaceContent: Component<InfrastructureWorkspaceProps> =
);
};
+ const renderUnavailableSavedConfiguration = (
+ connection: Connection,
+ platform: 'TrueNAS' | 'VMware',
+ state:
+ | InfrastructureWorkspaceProps['trueNASSettings']
+ | InfrastructureWorkspaceProps['vmwareSettings'],
+ ) => (
+ <div class="space-y-3">
+ <div
+ role={state.loading() ? 'status' : 'alert'}
+ class="rounded-md border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-900 dark:border-amber-900/25 dark:bg-amber-950/25 dark:text-amber-200"
+ >
+ <Show
+ when={state.loading()}
+ fallback={
+ <>
+ Saved {platform} configuration for {connection.name} is unavailable. Retry to verify
+ access and read it again before editing. This does not confirm removal.
+ </>
+ }
+ >
+ Reading saved {platform} configuration for {connection.name}…
+ </Show>
+ </div>
+ <Button
+ type="button"
+ variant="secondary"
+ size="mdCompact"
+ disabled={state.loading()}
+ onClick={() => void state.loadConnections()}
+ >
+ Retry saved configuration
+ </Button>
+ </div>
+ );
+
const renderConnectionSlot = (context: {
mode: 'add' | 'edit';
type: ConnectionType;
@@ -791,61 +827,59 @@ const InfrastructureWorkspaceContent: Component<InfrastructureWorkspaceProps> =
);
}
case 'vmware': {
- const vmware = findEditableVMware(connection);
- if (!vmware) {
- return (
- <div
- role="alert"
- class="rounded-md border border-rose-300 bg-rose-50 px-4 py-3 text-sm text-rose-800 dark:border-rose-900/25 dark:bg-rose-950/25 dark:text-rose-200"
- >
- Couldn't find the saved VMware configuration for {connection.name}. It may have
- already been removed.
- </div>
- );
- }
return (
- <VMwareCredentialSlot
- state={props.vmwareSettings}
- editingConnection={vmware}
- onCancel={context.onCancel}
- onSaved={context.onSaved}
- onToggleEnabled={() => void rowActions.togglePause(connection)}
- togglePending={rowActions.pendingAction(connection.id) === 'pause'}
- connectionEnabled={connection.enabled}
- onDelete={() => void rowActions.requestRemove(connection)}
- deletePending={rowActions.pendingAction(connection.id) === 'remove'}
- deleteConfirming={rowActions.confirmingRemove(connection.id)}
- deleteError={rowActions.actionError(connection.id)}
- />
+ <Show
+ when={findEditableVMware(connection)}
+ fallback={renderUnavailableSavedConfiguration(
+ connection,
+ 'VMware',
+ props.vmwareSettings,
+ )}
+ >
+ {(editableConnection) => (
+ <VMwareCredentialSlot
+ state={props.vmwareSettings}
+ editingConnection={editableConnection()}
+ onCancel={context.onCancel}
+ onSaved={context.onSaved}
+ onToggleEnabled={() => void rowActions.togglePause(connection)}
+ togglePending={rowActions.pendingAction(connection.id) === 'pause'}
+ connectionEnabled={connection.enabled}
+ onDelete={() => void rowActions.requestRemove(connection)}
+ deletePending={rowActions.pendingAction(connection.id) === 'remove'}
+ deleteConfirming={rowActions.confirmingRemove(connection.id)}
+ deleteError={rowActions.actionError(connection.id)}
+ />
+ )}
+ </Show>
);
}
case 'truenas': {
- const truenas = findEditableTrueNAS(connection);
- if (!truenas) {
- return (
- <div
- role="alert"
- class="rounded-md border border-rose-300 bg-rose-50 px-4 py-3 text-sm text-rose-800 dark:border-rose-900/25 dark:bg-rose-950/25 dark:text-rose-200"
- >
- Couldn't find the saved TrueNAS configuration for {connection.name}. It may have
- already been removed.
- </div>
- );
- }
return (
- <TrueNASCredentialSlot
- state={props.trueNASSettings}
- editingConnection={truenas}
- onCancel={context.onCancel}
- onSaved={context.onSaved}
- onToggleEnabled={() => void rowActions.togglePause(connection)}
- togglePending={rowActions.pendingAction(connection.id) === 'pause'}
- connectionEnabled={connection.enabled}
- onDelete={() => void rowActions.requestRemove(connection)}
- deletePending={rowActions.pendingAction(connection.id) === 'remove'}
- deleteConfirming={rowActions.confirmingRemove(connection.id)}
- deleteError={rowActions.actionError(connection.id)}
- />
+ <Show
+ when={findEditableTrueNAS(connection)}
+ fallback={renderUnavailableSavedConfiguration(
+ connection,
+ 'TrueNAS',
+ props.trueNASSettings,
+ )}
+ >
+ {(editableConnection) => (
+ <TrueNASCredentialSlot
+ state={props.trueNASSettings}
+ editingConnection={editableConnection()}
+ onCancel={context.onCancel}
+ onSaved={context.onSaved}
+ onToggleEnabled={() => void rowActions.togglePause(connection)}
+ togglePending={rowActions.pendingAction(connection.id) === 'pause'}
+ connectionEnabled={connection.enabled}
+ onDelete={() => void rowActions.requestRemove(connection)}
+ deletePending={rowActions.pendingAction(connection.id) === 'remove'}
+ deleteConfirming={rowActions.confirmingRemove(connection.id)}
+ deleteError={rowActions.actionError(connection.id)}
+ />
+ )}
+ </Show>
);
}
default:
diff --git a/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx b/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx
index b7a600ed96..67d17d4439 100644
--- a/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/InfrastructureWorkspace.test.tsx
@@ -2,6 +2,10 @@ import { cleanup, fireEvent, render, screen, waitFor, within } from '@solidjs/te
import { createSignal } from 'solid-js';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import type { Connection } from '@/api/connections';
+import { TrueNASAPI } from '@/api/truenas';
+import { VMwareAPI } from '@/api/vmware';
+import { useTrueNASSettingsPanelState } from '../useTrueNASSettingsPanelState';
+import { useVMwareSettingsPanelState } from '../useVMwareSettingsPanelState';
import { eventBus } from '@/stores/events';
import {
agentAttachmentProblem,
@@ -41,6 +45,11 @@ const ledgerReadState = vi.hoisted(() => ({
reload: vi.fn(),
}));
const nodeCredentialSlotState = vi.hoisted(() => ({ mountCount: 0 }));
+const savedCredentialSlotMounts = vi.hoisted(() => ({
+ truenas: 0,
+ vmware: 0,
+ useRealSlots: false,
+}));
const emptyFleetRow = vi.hoisted(
() =>
({
@@ -206,13 +215,42 @@ vi.mock('../ConnectionEditor/CredentialSlots/NodeCredentialSlot', () => ({
},
}));
-vi.mock('../ConnectionEditor/CredentialSlots/TrueNASCredentialSlot', () => ({
- TrueNASCredentialSlot: () => <div data-testid="truenas-section">truenas</div>,
-}));
+vi.mock('../ConnectionEditor/CredentialSlots/TrueNASCredentialSlot', async (importOriginal) => {
+ const actual =
+ await importOriginal<
+ typeof import('../ConnectionEditor/CredentialSlots/TrueNASCredentialSlot')
+ >();
+ return {
+ TrueNASCredentialSlot: (props: Parameters<typeof actual.TrueNASCredentialSlot>[0]) => {
+ savedCredentialSlotMounts.truenas += 1;
+ if (savedCredentialSlotMounts.useRealSlots)
+ return <actual.TrueNASCredentialSlot {...props} />;
+ return (
+ <div data-testid="truenas-section" data-editing-id={props.editingConnection?.id}>
+ <input aria-label="Synthetic credential draft" />
+ </div>
+ );
+ },
+ };
+});
-vi.mock('../ConnectionEditor/CredentialSlots/VMwareCredentialSlot', () => ({
- VMwareCredentialSlot: () => <div data-testid="vmware-section">vmware</div>,
-}));
+vi.mock('../ConnectionEditor/CredentialSlots/VMwareCredentialSlot', async (importOriginal) => {
+ const actual =
+ await importOriginal<
+ typeof import('../ConnectionEditor/CredentialSlots/VMwareCredentialSlot')
+ >();
+ return {
+ VMwareCredentialSlot: (props: Parameters<typeof actual.VMwareCredentialSlot>[0]) => {
+ savedCredentialSlotMounts.vmware += 1;
+ if (savedCredentialSlotMounts.useRealSlots) return <actual.VMwareCredentialSlot {...props} />;
+ return (
+ <div data-testid="vmware-section" data-editing-id={props.editingConnection?.id}>
+ <input aria-label="Synthetic credential draft" />
+ </div>
+ );
+ },
+ };
+});
vi.mock('../AgentProfilesPanel', () => ({
AgentProfilesPanel: () => <div data-testid="agent-profiles">profiles</div>,
@@ -325,6 +363,9 @@ describe('InfrastructureWorkspace', () => {
() => {},
);
nodeCredentialSlotState.mountCount = 0;
+ savedCredentialSlotMounts.useRealSlots = false;
+ savedCredentialSlotMounts.truenas = 0;
+ savedCredentialSlotMounts.vmware = 0;
Object.defineProperty(window, 'innerWidth', {
configurable: true,
writable: true,
@@ -334,6 +375,7 @@ describe('InfrastructureWorkspace', () => {
afterEach(() => {
cleanup();
+ vi.restoreAllMocks();
restoreResizeObserver();
});
@@ -1238,6 +1280,228 @@ describe('InfrastructureWorkspace', () => {
}
});
+ it.each([
+ ['truenas', 401],
+ ['truenas', 403],
+ ['truenas', 404],
+ ['truenas', 503],
+ ['truenas', 200],
+ ['vmware', 401],
+ ['vmware', 403],
+ ['vmware', 404],
+ ['vmware', 503],
+ ['vmware', 200],
+ ] as const)(
+ 'keeps the real %s consumer open after read status %s withdraws its draft and recovers afresh',
+ async (type, status) => {
+ savedCredentialSlotMounts.useRealSlots = true;
+ const api = type === 'truenas' ? TrueNASAPI : VMwareAPI;
+ const saved = {
+ id: 'source-1',
+ name: 'Saved source',
+ host: 'source.example.invalid',
+ username: 'monitor',
+ apiKey: '********',
+ password: '********',
+ useHttps: true,
+ insecureSkipVerify: false,
+ fingerprint: 'SHA256:synthetic-pin',
+ enabled: true,
+ monitorVms: true,
+ monitorHosts: true,
+ monitorDatastores: true,
+ monitorDatasets: true,
+ monitorPools: true,
+ monitorReplication: true,
+ };
+ const list = vi.spyOn(api, 'listConnections').mockImplementation(async () => [{ ...saved }]);
+ const update = vi.spyOn(api, 'updateConnection');
+ const remove = vi.spyOn(api, 'deleteConnection');
+ const create = vi.spyOn(api, 'createConnection');
+ connectionState.connections = [
+ connectionFixture({ id: `${type}:source-1`, type, name: 'Saved source' }),
+ ];
+ let state!:
+ | ReturnType<typeof useTrueNASSettingsPanelState>
+ | ReturnType<typeof useVMwareSettingsPanelState>;
+ render(() => {
+ state = type === 'truenas' ? useTrueNASSettingsPanelState() : useVMwareSettingsPanelState();
+ return (
+ <InfrastructureWorkspace
+ {...baseProps()}
+ {...{ [type === 'truenas' ? 'trueNASSettings' : 'vmwareSettings']: state }}
+ />
+ );
+ });
+ await waitFor(() => expect(state.connections()).toHaveLength(1));
+ fireEvent.click(await screen.findByRole('button', { name: 'Manage' }));
+ const dialog = screen.getByRole('dialog');
+ const name = within(dialog).getByRole('textbox', { name: 'Name' });
+ const storedSecretPlaceholder =
+ type === 'truenas'
+ ? 'Saved API key retained unless replaced'
+ : 'Saved password retained unless replaced';
+ const secret = within(dialog).getByPlaceholderText(storedSecretPlaceholder);
+ fireEvent.input(name, { target: { value: 'Unconfirmed name' } });
+ fireEvent.input(secret, { target: { value: 'synthetic-unsaved-secret' } });
+ await state.loadConnections();
+ expect(within(dialog).getByRole('textbox', { name: 'Name' })).toBe(name);
+ expect(name).toHaveValue('Unconfirmed name');
+ expect(secret).toHaveValue('synthetic-unsaved-secret');
+ if (status === 200) list.mockResolvedValueOnce([]);
+ else list.mockRejectedValueOnce({ status, message: 'synthetic private failure' });
+ await state.loadConnections();
+ await waitFor(() => expect(within(dialog).queryByRole('textbox')).toBeNull());
+ expect(screen.getByRole('dialog')).toBe(dialog);
+ expect(within(dialog).getByRole('alert')).toHaveTextContent('is unavailable');
+ expect(dialog).not.toHaveTextContent('synthetic private failure');
+ expect(state.form()).toMatchObject({ name: '', password: '' });
+ expect(state.dialogOpen()).toBe(false);
+ expect(within(dialog).queryByRole('button', { name: 'Save changes' })).toBeNull();
+ expect(within(dialog).queryByRole('button', { name: 'Test connection' })).toBeNull();
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Retry saved configuration' }));
+ await waitFor(() =>
+ expect(within(dialog).getByRole('textbox', { name: 'Name' })).toHaveValue('Saved source'),
+ );
+ const recoveredSecret = within(dialog).getByPlaceholderText(storedSecretPlaceholder);
+ expect(recoveredSecret).toHaveValue('');
+ expect(recoveredSecret).toHaveAttribute(
+ 'placeholder',
+ type === 'truenas'
+ ? 'Saved API key retained unless replaced'
+ : 'Saved password retained unless replaced',
+ );
+ expect(screen.getByRole('dialog')).toBe(dialog);
+ expect(state.form()).toMatchObject({
+ host: saved.host,
+ username: saved.username,
+ insecureSkipVerify: false,
+ ...(type === 'truenas'
+ ? {
+ useHttps: true,
+ fingerprint: saved.fingerprint,
+ monitorPools: true,
+ monitorDatasets: true,
+ monitorReplication: true,
+ }
+ : { monitorVms: true, monitorHosts: true, monitorDatastores: true }),
+ });
+ expect(update).not.toHaveBeenCalled();
+ expect(remove).not.toHaveBeenCalled();
+ expect(create).not.toHaveBeenCalled();
+ },
+ );
+
+ describe.each([
+ ['truenas', 'TrueNAS', 'trueNASSettings'],
+ ['vmware', 'VMware', 'vmwareSettings'],
+ ] as const)('%s saved configuration', (type, platform, propName) => {
+ it.each([401, 403, 503, 404, 200])(
+ 'keeps a %s unavailable read distinct from removal and explicitly recovers the same source',
+ async (status) => {
+ connectionState.connections = [
+ connectionFixture({ id: `${type}:source-1`, type, name: 'Saved source' }),
+ ];
+ const [connections, setConnections] = createSignal<any[]>([]);
+ const [loading, setLoading] = createSignal(false);
+ const loadConnections = vi.fn(() => setLoading(true));
+ renderWorkspace({
+ [propName]: {
+ closeDialog: vi.fn(),
+ connections,
+ loading,
+ loadingError: () => (status === 200 ? null : `HTTP ${status}: private detail`),
+ featureDisabled: () => status === 404,
+ loadConnections,
+ },
+ });
+ fireEvent.click(await screen.findByRole('button', { name: 'Manage' }));
+ const dialog = screen.getByRole('dialog');
+ expect(within(dialog).getByRole('alert')).toHaveTextContent(
+ `Saved ${platform} configuration for Saved source is unavailable`,
+ );
+ expect(dialog).toHaveTextContent('does not confirm removal');
+ expect(dialog).not.toHaveTextContent('already been removed');
+ expect(dialog).not.toHaveTextContent('private detail');
+ expect(within(dialog).queryByTestId(`${type}-section`)).toBeNull();
+ expect(loadConnections).not.toHaveBeenCalled();
+ const retry = within(dialog).getByRole('button', { name: 'Retry saved configuration' });
+ fireEvent.click(retry);
+ expect(retry).toBeDisabled();
+ expect(within(dialog).getByRole('status')).toHaveTextContent(
+ `Reading saved ${platform} configuration for Saved source`,
+ );
+ expect(loadConnections).toHaveBeenCalledTimes(1);
+ // A completed empty read, or a namesake with another ID, still cannot
+ // establish that this selected connection was removed.
+ setLoading(false);
+ setConnections([{ id: 'another-source', name: 'Saved source' }]);
+ expect(within(dialog).queryByTestId(`${type}-section`)).toBeNull();
+ expect(within(dialog).getByRole('alert')).toBeInTheDocument();
+ fireEvent.click(retry);
+ setConnections([{ id: 'source-1', name: 'Saved source' }]);
+ setLoading(false);
+ await waitFor(() =>
+ expect(within(dialog).getByTestId(`${type}-section`)).toHaveAttribute(
+ 'data-editing-id',
+ 'source-1',
+ ),
+ );
+ expect(screen.getByRole('dialog')).toBe(dialog);
+ expect(loadConnections).toHaveBeenCalledTimes(2);
+ expect(ledgerReadState.reload).not.toHaveBeenCalled();
+ },
+ );
+
+ it('reacts to withdrawn inventory without remounting an unchanged credential draft on polls', async () => {
+ connectionState.connections = [
+ connectionFixture({ id: `${type}:source-1`, type, name: 'Saved source' }),
+ ];
+ const [connections, setConnections] = createSignal<any[]>([{ id: 'source-1' }]);
+ const [loading, setLoading] = createSignal(false);
+ renderWorkspace({
+ [propName]: { closeDialog: vi.fn(), connections, loading, loadConnections: vi.fn() },
+ });
+ fireEvent.click(await screen.findByRole('button', { name: 'Manage' }));
+ const dialog = screen.getByRole('dialog');
+ const draft = within(dialog).getByRole('textbox', { name: 'Synthetic credential draft' });
+ fireEvent.input(draft, { target: { value: 'synthetic-unsaved-secret' } });
+ setLoading(true);
+ setConnections([{ id: 'source-1' }]);
+ setLoading(false);
+ expect(within(dialog).getByRole('textbox')).toBe(draft);
+ expect(draft).toHaveValue('synthetic-unsaved-secret');
+ expect(savedCredentialSlotMounts[type]).toBe(1);
+ setConnections([]);
+ expect(within(dialog).queryByRole('textbox')).toBeNull();
+ expect(within(dialog).getByRole('alert')).toHaveTextContent('is unavailable');
+ expect(screen.getByRole('dialog')).toBe(dialog);
+ });
+
+ it('reports an initial pending read and recovers without closing Manage', async () => {
+ connectionState.connections = [
+ connectionFixture({ id: `${type}:source-1`, type, name: 'Saved source' }),
+ ];
+ const [connections, setConnections] = createSignal<any[]>([]);
+ const [loading, setLoading] = createSignal(true);
+ renderWorkspace({
+ [propName]: { closeDialog: vi.fn(), connections, loading, loadConnections: vi.fn() },
+ });
+ fireEvent.click(await screen.findByRole('button', { name: 'Manage' }));
+ const dialog = screen.getByRole('dialog');
+ expect(within(dialog).getByRole('status')).toHaveTextContent(`Reading saved ${platform}`);
+ expect(
+ within(dialog).getByRole('button', { name: 'Retry saved configuration' }),
+ ).toBeDisabled();
+ setConnections([{ id: 'source-1' }]);
+ setLoading(false);
+ await waitFor(() =>
+ expect(within(dialog).getByTestId(`${type}-section`)).toBeInTheDocument(),
+ );
+ expect(screen.getByRole('dialog')).toBe(dialog);
+ });
+ });
+
it('opens the manage dialog directly from an existing source card', async () => {
renderWorkspace({
pveNodes: () => [{ name: 'zeus', host: 'https://10.0.0.1:8006' } as any],
diff --git a/frontend-modern/src/components/Settings/__tests__/useInfrastructureSettingsState.reader.test.tsx b/frontend-modern/src/components/Settings/__tests__/useInfrastructureSettingsState.reader.test.tsx
index ec554c4067..6b69b1fed6 100644
--- a/frontend-modern/src/components/Settings/__tests__/useInfrastructureSettingsState.reader.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/useInfrastructureSettingsState.reader.test.tsx
@@ -85,12 +85,21 @@ describe('Infrastructure settings VMware reader wiring', () => {
const old = state.connections()[0];
state.openEditDialog(old);
state.updateForm({ password: 'synthetic-draft' });
- const first = vi.mocked(VMwareAPI.listConnections).mock.calls[0][0]!;
+ let release!: (value: VMwareConnection[]) => void;
+ vi.mocked(VMwareAPI.listConnections).mockReturnValueOnce(
+ new Promise((resolve) => {
+ release = resolve;
+ }),
+ );
+ const reading = state.loadConnections();
+ const pending = vi.mocked(VMwareAPI.listConnections).mock.calls[1][0]!;
setUser('reader-b');
- await waitFor(() => expect(VMwareAPI.listConnections).toHaveBeenCalledTimes(2));
- expect(first.signal?.aborted).toBe(true);
+ await waitFor(() => expect(VMwareAPI.listConnections).toHaveBeenCalledTimes(3));
+ expect(pending.signal?.aborted).toBe(true);
expect(state.dialogOpen()).toBe(false);
expect(state.form().password).toBe('');
+ release([old]);
+ await reading;
await waitFor(() => expect(state.loading()).toBe(false));
state.openEditDialog(old);
expect(state.dialogOpen()).toBe(false);
diff --git a/frontend-modern/src/components/Settings/__tests__/useTrueNASSettingsPanelState.reader.test.tsx b/frontend-modern/src/components/Settings/__tests__/useTrueNASSettingsPanelState.reader.test.tsx
index ccc5721f1c..bdbb425efa 100644
--- a/frontend-modern/src/components/Settings/__tests__/useTrueNASSettingsPanelState.reader.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/useTrueNASSettingsPanelState.reader.test.tsx
@@ -67,6 +67,43 @@ describe('TrueNAS reader lifetime', () => {
vi.mocked(TrueNASAPI.listConnections).mockImplementation(async () => [connection()]);
});
+ it.each([404, 503])(
+ 'withdraws a stale draft after a failed settings read (%s) until a fresh read succeeds',
+ async (status) => {
+ const { result } = renderHook(() => useTrueNASSettingsPanelState());
+ await ready(result);
+ openDraft(result);
+ result.openDeleteDialog(result.connections()[0]);
+ vi.mocked(TrueNASAPI.listConnections).mockRejectedValueOnce({
+ status,
+ message: 'synthetic unavailable',
+ });
+ await result.loadConnections();
+ expect(result.connections()).toEqual([]);
+ expect(result.form().apiKey).toBe('');
+ expect(result.dialogOpen()).toBe(false);
+ expect(result.deleteDialogOpen()).toBe(false);
+ expect(result.pendingDeleteConnection()).toBeNull();
+ expect(result.editingConnection()).toBeNull();
+ expect(TrueNASAPI.listConnections).toHaveBeenCalledTimes(2);
+ for (const [method, mock] of Object.entries(TrueNASAPI))
+ if (method !== 'listConnections') expect(mock).not.toHaveBeenCalled();
+ await result.loadConnections();
+ await ready(result);
+ result.openEditDialog(result.connections()[0]);
+ expect(result.form()).toMatchObject({
+ name: 'Synthetic NAS',
+ apiKey: '',
+ hasStoredApiKey: true,
+ useHttps: true,
+ insecureSkipVerify: false,
+ fingerprint: 'SHA256:synthetic-pin',
+ });
+ expect(result.loadingError()).toBeNull();
+ expect(result.featureDisabled()).toBe(false);
+ },
+ );
+
it('withdraws accepted inventory, draft secrets and confirmations when access is revoked', async () => {
const [canLoad, setAllowed] = createSignal(true);
const { result } = renderHook(() => useTrueNASSettingsPanelState({ canLoad }));
diff --git a/frontend-modern/src/components/Settings/useTrueNASSettingsPanelState.ts b/frontend-modern/src/components/Settings/useTrueNASSettingsPanelState.ts
index 39847f94fb..6a8bccde45 100644
--- a/frontend-modern/src/components/Settings/useTrueNASSettingsPanelState.ts
+++ b/frontend-modern/src/components/Settings/useTrueNASSettingsPanelState.ts
@@ -328,6 +328,16 @@ export function useTrueNASSettingsPanelState({
if (!isCurrent()) return;
batch(() => {
setConnections(nextConnections);
+ if (
+ editingConnectionId() &&
+ !nextConnections.some((connection) => connection.id === editingConnectionId())
+ )
+ resetDialogState();
+ if (
+ pendingDeleteConnection() &&
+ !nextConnections.some((connection) => connection.id === pendingDeleteConnection()?.id)
+ )
+ resetDeleteDialogState();
setAccessRejected(false);
setFeatureDisabled(false);
setFeatureDisabledMessage('');
@@ -335,7 +345,11 @@ export function useTrueNASSettingsPanelState({
} catch (error) {
if (!isCurrent()) return;
if (withdrawOnDenial(error)) return;
- setConnections([]);
+ batch(() => {
+ setConnections([]);
+ resetDialogState();
+ resetDeleteDialogState();
+ });
if (apiErrorStatus(error) === 404) {
setFeatureDisabled(true);
setFeatureDisabledMessage(