You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[P1] [bug] PrivilegesEditor per-DB edits discarded on selectedDb switch #441
[P1] [bug] PrivilegesEditor per-DB diff state silently discarded when user switches selectedDb — easy to lose unsaved work
Context
The selectedDbuseEffect (UserManagement.tsx:650-682) overwrites currentDbPrivs and editedDbPrivs whenever the user changes the dropdown. editedDbPrivs is only kept in component state, not in any per-DB structure.
Problem
Per docs/audits/admin.md F13.
User toggles 5 privileges on db1, doesn't Apply, switches to db2. editedDbPrivs for db1 is lost. Returning to db1 reloads fresh from SHOW GRANTS and the user must redo edits.
Edit 3 privileges on db1, switch to db2, switch back to db1 — the 3 toggled privileges are still highlighted yellow. Apply sends changes for both DBs in one batch.
Proposed fix
Scope M. Maintain a Map<dbName, { current, edited }> keyed by DB name. Apply iterates over all dirty DBs and emits REVOKE/GRANT for each. Switching DBs with dirty edited != current shows confirm dialog.
Acceptance
Per-DB edits persist across switches; Apply handles all dirty DBs.
Done in #524. Privileges are keyed by database, so switching away and back returns to the pending edit; Apply emits statements for every changed database rather than only the visible one; Reset clears them all; and databases with unapplied changes are marked in the dropdown and named above it.
The tests were run against the unfixed code and fail there. They also scope their queries to the database section — the global privilege checkboxes come first in the DOM, so an unscoped selector toggles a global privilege, which survives a database switch regardless and would have passed no matter what.
Activity
fix(admin): keep privilege edits per database, and admit unknown user…
EVWorth commentedon Aug 29, 2026
Done in #524. Privileges are keyed by database, so switching away and back returns to the pending edit; Apply emits statements for every changed database rather than only the visible one; Reset clears them all; and databases with unapplied changes are marked in the dropdown and named above it.
The tests were run against the unfixed code and fail there. They also scope their queries to the database section — the global privilege checkboxes come first in the DOM, so an unscoped selector toggles a global privilege, which survives a database switch regardless and would have passed no matter what.