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.

Withdraw User Access feedback with its reader

pulse-triage[bot]507071722326
diff --git a/docs/release-control/v6/internal/subsystems/organization-settings.md b/docs/release-control/v6/internal/subsystems/organization-settings.md
index f4faa0a306..d39ad77a7d 100644
--- a/docs/release-control/v6/internal/subsystems/organization-settings.md
+++ b/docs/release-control/v6/internal/subsystems/organization-settings.md
@@ -539,3 +539,12 @@ authorisation, IdP deprovisioning and existing self-modification protection rema
unchanged. Registered reader-lifetime, paywall-panel and RBAC transport tests
cover these rules; synthetic desktop/narrow browser proof is not installed
administrator or native IdP recovery.
+
+User Access action feedback is owned by that same reader, not the global toast
+queue: success notices withdraw on context change or a new confirmation, and
+failures stay beside the current save/removal controls without discarding the
+draft. Directory failure has one persistent read-only Retry notice. Account
+principals must not survive an organisation switch in an old notification.
+Paired directory/role reads are aborted when their combined read settles so a
+failed sibling does not leave an unowned pending request. The registered
+reader-lifetime/paywall tests and actual App browser witness cover this bound.
diff --git a/frontend-modern/src/components/Settings/UserAssignmentsDialog.tsx b/frontend-modern/src/components/Settings/UserAssignmentsDialog.tsx
index ca932cb8b6..036fd5a72b 100644
--- a/frontend-modern/src/components/Settings/UserAssignmentsDialog.tsx
+++ b/frontend-modern/src/components/Settings/UserAssignmentsDialog.tsx
@@ -9,6 +9,7 @@ import X from 'lucide-solid/icons/x';
import { getUserIdentityDisplayName, getUserIdentityProviderLabel } from '@/utils/rbacPresentation';
interface UserAssignmentsDialogProps {
+ actionError?: string | null;
editingUser: UserRoleAssignment | null;
formRoleIds: string[];
isOpen: boolean;
@@ -63,6 +64,13 @@ export const UserAssignmentsDialog: Component<UserAssignmentsDialogProps> = (pro
</div>
<div class="px-4 sm:px-6 py-6 space-y-8 max-h-[70vh] overflow-y-auto">
+ <Show when={props.actionError}>
+ {(message) => (
+ <InlineNotice tone="danger" role="alert" aria-live="polite">
+ {message()}
+ </InlineNotice>
+ )}
+ </Show>
<div class="space-y-4">
<h4 class="text-sm font-semibold text-base-content flex items-center gap-2">
<Shield class="w-4 h-4 text-blue-500" />
diff --git a/frontend-modern/src/components/Settings/UserAssignmentsPanel.tsx b/frontend-modern/src/components/Settings/UserAssignmentsPanel.tsx
index 912d1b3db5..2696053358 100644
--- a/frontend-modern/src/components/Settings/UserAssignmentsPanel.tsx
+++ b/frontend-modern/src/components/Settings/UserAssignmentsPanel.tsx
@@ -46,6 +46,14 @@ export const UserAssignmentsPanel: Component<UserAssignmentsPanelProps> = (props
noPadding
bodyClass="divide-y divide-border"
>
+ <Show when={state.successNotice()}>
+ {(message) => (
+ <InlineNotice tone="success" role="status" aria-live="polite">
+ {message()}
+ </InlineNotice>
+ )}
+ </Show>
+
<Show when={state.featureGate.paywallVisible()}>
<RBACFeatureGateSection
copy={state.featureGate.featureGateCopy()}
@@ -205,6 +213,7 @@ export const UserAssignmentsPanel: Component<UserAssignmentsPanelProps> = (props
</SettingsPanel>
<UserAssignmentsDialog
+ actionError={state.actionError()}
editingUser={state.editingUser()}
formRoleIds={state.formRoleIds()}
isOpen={state.showModal()}
@@ -241,6 +250,13 @@ export const UserAssignmentsPanel: Component<UserAssignmentsPanelProps> = (props
This does not disable the account at the identity provider. A later authorized SSO
login will create the user record again.
</div>
+ <Show when={state.actionError()}>
+ {(message) => (
+ <InlineNotice tone="danger" role="alert" aria-live="polite">
+ {message()}
+ </InlineNotice>
+ )}
+ </Show>
<div class="flex flex-col-reverse gap-3 sm:flex-row sm:justify-end">
<Button onClick={state.closeDeleteUser} disabled={state.deletingUser()}>
Cancel
diff --git a/frontend-modern/src/components/Settings/__tests__/RBACPaywallPanels.test.tsx b/frontend-modern/src/components/Settings/__tests__/RBACPaywallPanels.test.tsx
index f9e980f21a..e8ea4bbce0 100644
--- a/frontend-modern/src/components/Settings/__tests__/RBACPaywallPanels.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/RBACPaywallPanels.test.tsx
@@ -487,7 +487,8 @@ describe('RBAC paywall settings panels', () => {
}),
);
});
- expect(notificationSuccessMock).toHaveBeenCalledWith('User access removed for Alice Example');
+ expect(await screen.findByText('User access removed for Alice Example')).toBeInTheDocument();
+ expect(notificationSuccessMock).not.toHaveBeenCalled();
await waitFor(() => {
expect(screen.queryByText('Alice Example')).not.toBeInTheDocument();
});
@@ -509,7 +510,7 @@ describe('RBAC paywall settings panels', () => {
});
expect(screen.queryByText('alice')).not.toBeInTheDocument();
expect(screen.getByPlaceholderText('Search users...')).toBeDisabled();
- expect(notificationErrorMock).toHaveBeenCalledWith('Failed to load user assignments');
+ expect(notificationErrorMock).not.toHaveBeenCalled();
fireEvent.click(screen.getByRole('button', { name: 'Retry' }));
await waitFor(() => {
@@ -568,7 +569,12 @@ describe('RBAC paywall settings panels', () => {
}),
);
});
- expect(notificationErrorMock).toHaveBeenCalledWith('Failed to update user roles');
+ expect(
+ await within(screen.getByRole('dialog', { name: 'Manage access: alice' })).findByRole(
+ 'alert',
+ ),
+ ).toHaveTextContent('Failed to update user roles');
+ expect(notificationErrorMock).not.toHaveBeenCalled();
expect(notificationSuccessMock).not.toHaveBeenCalled();
expect(screen.getByRole('dialog', { name: 'Manage access: alice' })).toBeInTheDocument();
});
diff --git a/frontend-modern/src/components/Settings/__tests__/UserAccessReaderLifetime.test.tsx b/frontend-modern/src/components/Settings/__tests__/UserAccessReaderLifetime.test.tsx
index f20a8183fe..c312ef0c4b 100644
--- a/frontend-modern/src/components/Settings/__tests__/UserAccessReaderLifetime.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/UserAccessReaderLifetime.test.tsx
@@ -274,7 +274,8 @@ describe('User Access reader lifetime', () => {
await state.handleSaveAssignments();
expect(state.showModal()).toBe(true);
expect(state.formRoleIds()).toEqual([]);
- expect(mocks.error).toHaveBeenCalledWith('Failed to update user roles');
+ expect(state.actionError()).toBe('Failed to update user roles');
+ expect(mocks.error).not.toHaveBeenCalled();
expect(JSON.stringify(mocks.log.mock.calls)).not.toContain('private response canary');
expect(mocks.success).not.toHaveBeenCalled();
});
@@ -392,4 +393,34 @@ describe('User Access reader lifetime', () => {
expect(state.showModal()).toBe(false);
expect(state.userPendingDeletion()).toBeNull();
});
+ it('owns successful identity feedback locally and withdraws it on context change', async () => {
+ const { state } = mount();
+ await loaded(state);
+ await state.openManageAccess(alice);
+ await state.handleSaveAssignments();
+ expect(state.successNotice()).toBe(`Roles updated for ${alice.username}`);
+ expect(mocks.success).not.toHaveBeenCalled();
+ switchOrg();
+ await loaded(state);
+ expect(state.successNotice()).toBeNull();
+ expect(state.actionError()).toBeNull();
+ });
+
+ it('withdraws failed-action feedback before another confirmation and when authority changes', async () => {
+ mocks.deleteUser.mockRejectedValueOnce(new Error('private deletion details'));
+ const { state, setAllowed } = mount();
+ await loaded(state);
+ state.openDeleteUser(alice);
+ await state.handleDeleteUser();
+ expect(state.actionError()).not.toBeNull();
+ expect(state.userPendingDeletion()).toEqual(alice);
+ expect(mocks.error).not.toHaveBeenCalled();
+ state.closeDeleteUser();
+ await state.openManageAccess(alice);
+ expect(state.actionError()).toBeNull();
+ setAllowed(false);
+ await pause();
+ expect(state.successNotice()).toBeNull();
+ expect(state.actionError()).toBeNull();
+ });
});
diff --git a/frontend-modern/src/components/Settings/useUserAssignmentsPanelState.ts b/frontend-modern/src/components/Settings/useUserAssignmentsPanelState.ts
index 464f8f3727..991d488d82 100644
--- a/frontend-modern/src/components/Settings/useUserAssignmentsPanelState.ts
+++ b/frontend-modern/src/components/Settings/useUserAssignmentsPanelState.ts
@@ -4,7 +4,6 @@ import { RBACAPI } from '@/api/rbac';
import { getOrgID } from '@/utils/apiClient';
import { eventBus } from '@/stores/events';
import type { Permission, Role, UserRoleAssignment } from '@/types/rbac';
-import { notificationStore } from '@/stores/notifications';
import { logger } from '@/utils/logger';
import {
getUserAssignmentsDeleteErrorMessage,
@@ -32,6 +31,8 @@ export function useUserAssignmentsPanelState(props: UserAssignmentsPanelProps =
const [permissionsError, setPermissionsError] = createSignal<string | null>(null);
const [formRoleIds, setFormRoleIds] = createSignal<string[]>([]);
const [loadError, setLoadError] = createSignal<string | null>(null);
+ const [actionError, setActionError] = createSignal<string | null>(null);
+ const [successNotice, setSuccessNotice] = createSignal<string | null>(null);
const [deletingUser, setDeletingUser] = createSignal(false);
const [userPendingDeletion, setUserPendingDeletion] = createSignal<UserRoleAssignment | null>(
null,
@@ -84,6 +85,7 @@ export function useUserAssignmentsPanelState(props: UserAssignmentsPanelProps =
setShowModal(false);
setEditingUser(null);
setFormRoleIds([]);
+ setActionError(null);
});
};
const closeModal = () => {
@@ -155,9 +157,9 @@ export function useUserAssignmentsPanelState(props: UserAssignmentsPanelProps =
if (!isCurrentRead()) return;
setLoadError(getUserAssignmentsLoadErrorMessage());
logger.error('Failed to load user assignments');
- notificationStore.error(getUserAssignmentsLoadErrorMessage());
} finally {
if (isCurrentRead()) {
+ controller.abort();
readController = undefined;
setLoading(false);
}
@@ -176,6 +178,7 @@ export function useUserAssignmentsPanelState(props: UserAssignmentsPanelProps =
setRoles([]);
setInventoryLoaded(false);
setSearchQuery('');
+ setSuccessNotice(null);
setLoadError(null);
setUserPendingDeletion(null);
setSaving(false);
@@ -249,6 +252,7 @@ export function useUserAssignmentsPanelState(props: UserAssignmentsPanelProps =
const openManageAccess = async (assignment: UserRoleAssignment) => {
if (!canEdit() || !isCurrentUser(assignment)) return;
clearEditor();
+ setSuccessNotice(null);
setUserPendingDeletion(null);
setEditingUser(assignment);
setFormRoleIds([...assignment.roleIds]);
@@ -258,6 +262,7 @@ export function useUserAssignmentsPanelState(props: UserAssignmentsPanelProps =
const openDeleteUser = (assignment: UserRoleAssignment) => {
if (!canEdit() || !isCurrentUser(assignment)) return;
clearEditor();
+ setSuccessNotice(null);
setUserPendingDeletion(assignment);
};
const closeDeleteUser = () => {
@@ -271,6 +276,8 @@ export function useUserAssignmentsPanelState(props: UserAssignmentsPanelProps =
const isCurrentMutation = () =>
contextIsCurrent() && version === contextVersion && mutationController === controller;
mutationController = controller;
+ setActionError(null);
+ setSuccessNotice(null);
if (kind === 'save') setSaving(true);
else setDeletingUser(true);
let saved = false;
@@ -286,17 +293,12 @@ export function useUserAssignmentsPanelState(props: UserAssignmentsPanelProps =
}
if (!isCurrentMutation()) return;
saved = true;
- notificationStore.success(
- kind === 'save'
- ? `Roles updated for ${user.username}`
- : `User access removed for ${getUserIdentityDisplayName(user)}`,
- );
} catch (err) {
if (!isCurrentMutation()) return;
logger.error(
kind === 'save' ? 'Failed to update user roles' : 'Failed to remove user access',
);
- notificationStore.error(
+ setActionError(
kind === 'save'
? getUserAssignmentsUpdateErrorMessage()
: getUserAssignmentsDeleteErrorMessage(err),
@@ -306,7 +308,16 @@ export function useUserAssignmentsPanelState(props: UserAssignmentsPanelProps =
mutationController = undefined;
setSaving(false);
setDeletingUser(false);
- if (saved) await loadData();
+ if (saved) {
+ await loadData();
+ if (contextIsCurrent() && version === contextVersion) {
+ setSuccessNotice(
+ kind === 'save'
+ ? `Roles updated for ${user.username}`
+ : `User access removed for ${getUserIdentityDisplayName(user)}`,
+ );
+ }
+ }
}
}
};
@@ -331,6 +342,8 @@ export function useUserAssignmentsPanelState(props: UserAssignmentsPanelProps =
roles().find((role) => role.id === roleId)?.name || roleId;
return {
+ actionError,
+ successNotice,
accessAllowed,
canEdit,
closeDeleteUser,