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.

Preserve role drafts across unchanged status refreshes

pulse-triage[bot]09084eb90cf3
diff --git a/frontend-modern/src/components/Settings/__tests__/RolesReaderLifetime.test.tsx b/frontend-modern/src/components/Settings/__tests__/RolesReaderLifetime.test.tsx
index 31c5e729c2..7601e5c840 100644
--- a/frontend-modern/src/components/Settings/__tests__/RolesReaderLifetime.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/RolesReaderLifetime.test.tsx
@@ -135,6 +135,31 @@ describe('Roles reader lifetime', () => {
},
);
+ it('preserves the draft when reactive status props refresh without changing the reader', async () => {
+ const [status, setStatus] = createSignal({ user: 'reader-a', allowed: true });
+ let state!: ReturnType<typeof useRolesPanelState>;
+ render(() => {
+ state = useRolesPanelState({
+ get currentUser() {
+ return status().user;
+ },
+ get canManage() {
+ return status().allowed;
+ },
+ });
+ return <div />;
+ });
+ await loaded(state);
+ state.openEditRole(north);
+ state.setFormName('Unchanged reader draft');
+ const reads = mocks.getRoles.mock.calls.length;
+ setStatus({ user: 'reader-a', allowed: true });
+ await pause();
+ expect(state.showModal()).toBe(true);
+ expect(state.formName()).toBe('Unchanged reader draft');
+ expect(mocks.getRoles).toHaveBeenCalledTimes(reads);
+ });
+
it('reactivates rendered controls after capability withdrawal and restoration', async () => {
const [feature, setFeature] = createSignal(true);
enabled = feature;
diff --git a/frontend-modern/src/components/Settings/useRolesPanelState.ts b/frontend-modern/src/components/Settings/useRolesPanelState.ts
index d7cdfad525..3419bd9dbf 100644
--- a/frontend-modern/src/components/Settings/useRolesPanelState.ts
+++ b/frontend-modern/src/components/Settings/useRolesPanelState.ts
@@ -168,7 +168,10 @@ export function useRolesPanelState(props: RolesPanelProps = {}) {
if (!disposed) void loadRoles();
};
createEffect(
- on([featureGate.licenseReady, accessAllowed, () => props.currentUser], resetContext),
+ on([featureGate.licenseReady, accessAllowed, () => props.currentUser], (current, previous) => {
+ // Dynamic props can refresh without changing the admitted reader.
+ if (!previous || current.some((value, index) => value !== previous[index])) resetContext();
+ }),
);
const unsubscribeOrg = eventBus.on('org_switched', resetContext);
onCleanup(() => {