Skip to content

Add a new superuser ability page to admin - #4004

Merged
sethherr merged 5 commits into
mainfrom
sethherr/create-pr-v2
Jul 31, 2026
Merged

Add a new superuser ability page to admin#4004
sethherr merged 5 commits into
mainfrom
sethherr/create-pr-v2

Conversation

@sethherr

Copy link
Copy Markdown
Member

/admin/superuser_abilities/new — granting an ability was previously only possible from the user edit page (universal only) or the console. The index gets a button linking to it, carrying its user_id filter through so the form arrives prefilled.

  • The user is found by email, username or id through the existing User.friendly_find, held on a user_identifier accessor the way Membership holds user_email. Leaving controller and action blank makes it universal; kind stays derived.
  • set_calculated_attributes now writes blank controller_name/action_name as nil, so a form-created universal ability matches the find_or_create_by(controller_name: nil, action_name: nil) in Admin::UsersController instead of quietly becoming a second row.
  • Validates user_id — a typo'd address re-renders the form rather than creating an unowned universal ability. On the column rather than the association, so an ability outliving its soft-deleted user stays editable.

sethherr and others added 2 commits July 31, 2026 08:20
/admin/superuser_abilities/new grants an ability to a user found by
email, username or id, with the controller/action left blank for a
universal one. Linked from a button on the index, which carries the
user_id filter through so the form prefills.

The model normalizes blank controller_name/action_name to nil, so a
form-created universal ability matches the find_or_create_by in
Admin::UsersController, and validates user_id so a typo'd address
re-renders the form instead of creating an unowned universal ability.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sethherr

sethherr commented Jul 31, 2026

Copy link
Copy Markdown
Member Author

Screenshots

/admin/superuser_abilities

Desktop Mobile
main 👆 this branch 👇

/admin/superuser_abilities/new

Desktop Mobile

application.js lazy loads Stimulus controllers, so ui--modal's module can still
be in flight when Capybara clicks the trigger. The click is swallowed - the
handler is wired in connect - and nothing reopens it, so the wait for "Yes,
start over" times out on a dialog that never opens.

open_modal clicks again, the way a rider whose click did nothing would, until
the dialog reports itself open. Holding the modal_controller.js response back
by 3s reproduces the swallow on a single click and confirms the retry recovers.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sethherr
sethherr marked this pull request as ready for review July 31, 2026 21:03
sethherr and others added 2 commits July 31, 2026 14:04
Both landing pages carry the same swallowed-click race the register flow hit -
holding modal_controller.js back reproduces it on the hero and CTA triggers.

open_modal now takes the trigger rather than a button label and modal id: each
page has two triggers for one modal, so the id is the trigger's to name, and
locating it is the caller's (first for the hero, a scoped find for the CTA).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The three text fields go through the shared group rather than hand-rolled
Bootstrap label + form-control, so they pick up twlabel/twinput and the
required "*" / optional badge the rest of the app's forms carry. Help text
follows each field as the register steps write it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@sethherr
sethherr merged commit 68c9cc1 into main Jul 31, 2026
9 checks passed
@sethherr
sethherr deleted the sethherr/create-pr-v2 branch July 31, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant