Skip to content

[P1] [bug] PrivilegesEditor per-DB edits discarded on selectedDb switch #441

Closed

Description

@EVWorth

[P1] [bug] PrivilegesEditor per-DB diff state silently discarded when user switches selectedDb — easy to lose unsaved work

Context

The selectedDb useEffect (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.

Files

  • src/components/admin/UserManagement.tsx:650-682, 709-713, 873-882

Repro (if applicable)

Static analysis only.

Expected

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.

Needs human verify

Yes

Labels: audit, area/admin, severity/p1, kind/bug

Activity

  1. added
    audit
    severity/p1
    kind/bug
    area/admin
    on Jul 31, 2026
  2. EVWorth commented on Aug 29, 2026

    @EVWorth
    OwnerAuthor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/adminauditkind/bugseverity/p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions