Load role permissions when opening the Edit Role dialog #17

Merged
padreug merged 2 commits from fix/edit-role-permissions-loading into main 2026-05-17 12:56:07 +00:00
Owner

Summary

The Edit Role dialog reads from rolePermissionsForView / roleUsersForView, but editRole(role) only ever populated the form fields and showed the dialog — those arrays were left at whatever state the rest of the page had set them to. Result: opening Edit Role for a role with existing permissions showed "No permissions assigned to this role yet", and the list only "appeared" because adding a permission triggered a refresh.

Mirror viewRole's pattern: clear both arrays, GET /admin/roles/{id}, populate from the response, then show the dialog after $nextTick. Also reset both arrays in closeRoleDialog so leftover state doesn't survive a close → open-Create round trip (defensive — Create flow doesn't read them today, but keeps the two close handlers symmetrical).

Closes #14

Test plan

  • Open Edit Role for a role with existing permissions — list of permissions appears immediately (no longer needs to add one to "reveal" them).
  • Open Edit Role for a role with zero permissions — shows the empty state, no leftover data from a previously edited role.
  • Open Edit Role → Cancel → Create Role — Create dialog opens clean (no leftover users/permissions in state).
  • If GET /admin/roles/{id} fails, a negative notification shows and the dialog still opens (so the user can still update name/description).

🤖 Generated with Claude Code

## Summary The Edit Role dialog reads from `rolePermissionsForView` / `roleUsersForView`, but `editRole(role)` only ever populated the form fields and showed the dialog — those arrays were left at whatever state the rest of the page had set them to. Result: opening Edit Role for a role with existing permissions showed "No permissions assigned to this role yet", and the list only "appeared" because adding a permission triggered a refresh. Mirror `viewRole`'s pattern: clear both arrays, `GET /admin/roles/{id}`, populate from the response, then show the dialog after `$nextTick`. Also reset both arrays in `closeRoleDialog` so leftover state doesn't survive a close → open-Create round trip (defensive — Create flow doesn't read them today, but keeps the two close handlers symmetrical). Closes #14 ## Test plan - [x] Open Edit Role for a role with existing permissions — list of permissions appears immediately (no longer needs to add one to "reveal" them). - [x] Open Edit Role for a role with zero permissions — shows the empty state, no leftover data from a previously edited role. - [x] Open Edit Role → Cancel → Create Role — Create dialog opens clean (no leftover users/permissions in state). - [ ] If `GET /admin/roles/{id}` fails, a negative notification shows and the dialog still opens (so the user can still update name/description). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The dialog reads from rolePermissionsForView / roleUsersForView, but
editRole(role) only ever populated the form fields and showed the
dialog — those arrays were left at whatever state the rest of the page
had set them to. Result: opening Edit Role for a role with existing
permissions showed "No permissions assigned to this role yet", and the
list only "appeared" because adding a permission triggered a refresh.

Mirror viewRole's pattern: clear both arrays, GET /admin/roles/{id},
populate from the response, then show the dialog after $nextTick.

Closes #14
closeViewRoleDialog already clears rolePermissionsForView and
roleUsersForView; closeRoleDialog (used by both Edit and Create flows)
did not. With editRole now populating those arrays, leftover state
would otherwise survive a close → open-Create round trip. The Create
template branch doesn't read the arrays today (v-if guarded on
editingRole), so this is defensive — keeps the two close handlers
symmetrical and avoids future regressions if the Create branch ever
starts referencing them.
padreug deleted branch fix/edit-role-permissions-loading 2026-05-17 12:56:07 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
aiolabs/libra!17
No description provided.