Skip to content

User permissions: redesigned grouped capability editor + catalog - #482

Merged
rpgmem merged 2 commits into
developfrom
claude/user-permissions-redesign
Jun 3, 2026
Merged

User permissions: redesigned grouped capability editor + catalog#482
rpgmem merged 2 commits into
developfrom
claude/user-permissions-redesign

Conversation

@rpgmem

@rpgmem rpgmem commented Jun 3, 2026

Copy link
Copy Markdown
Owner

Redesigned per-user capability editor (+ editable audience membership)

Rebuilds the FFC permissions section on the WordPress Edit user screen, answering the maintainer's UX ask ("the function is unclear and the admin can't easily understand/cite each capability individually") — and fixing a latent save bug found along the way.

The problems (before)

  • The form rendered 10 of ~26 capabilities, as bare labels with no way to tell which machine capability each mapped to.
  • Labels were inline __() strings with no central registry → nothing the admin could cite.
  • Latent bug: the save handler iterated all 26 caps while the form rendered 10, so every cap without a checkbox was silently remove_cap()'d on each save — e.g. opening + saving an ffc_user's profile would strip a per-user ffc_manage_recruitment grant.

The redesign

  • CapabilityCatalog — single source of truth: slug → {label, description, group, level} for all 26 caps. CI asserts it covers exactly CapabilityManager::get_all_capabilities(), so adding a registry cap without metadata fails the build.
  • Grouped card layout (Certificates · Appointments · Audiences · Administration–Modules · Administration–Recruitment); admin groups start collapsed.
  • Per row: description + copyable monospace slug chip + origin badge (User vs Role) so the admin can see whether a permission comes from the role or a per-user grant.
  • Live search (label + slug), Grant/Revoke-all presets, live per-group "granted" count.
  • Save fix: render and save both derive from the catalog, so the silent strip is gone.

Context & groups

  • Role → read-only context (per the maintainer's decision): role(s) shown for context; editing stays in WordPress' native role selector on the same screen.
  • Audiences → editable inline membership (the larger follow-up, now folded in): a checklist of every active audience, pre-checked for current memberships, synced on the same profile-form save. sync_audience_membership() whitelists the submission against the active set and diffs against the current memberships, applying the minimal add_member/remove_member calls. Only active audiences participate, so a membership in an inactive audience is never touched; if no audiences are active (the checklist wouldn't render) the sync is a no-op so it can't wipe membership on an unrelated save. Changes are audit-logged. A link through to the Audiences screen remains for bulk management.

Assets & tests

  • New ffc-user-permissions.css; ffc-user-capabilities.js rewritten (vanilla, no jQuery) for presets/search/collapse/copy/live-count. npm run build ran (min bundles in sync).
  • CapabilityCatalogTest (registry parity + metadata), updated AdminUserCapabilitiesTest (new markup, enqueue, the formerly-hidden admin caps now render, audience checklist render + membership add/remove/no-op save), new Vitest user-capabilities.test.js, retired the superseded tiny-scripts block.
  • Green: PHPUnit 4949 · Vitest 1107 · ESLint · Stylelint · WPCS · PHPStan 8.
  • Design mockup committed under docs/mockups/user-permissions-redesign.html.

Targets develop; no FFC_VERSION bump (belongs to the release PR). CHANGELOG under [Unreleased].

https://claude.ai/code/session_011ErkuJ7jnF9zkqCkGs3qKN

Rebuilds the per-user FFC capability section on the WordPress user-edit
screen as a grouped, card-based panel and fixes a latent save bug.

- New CapabilityCatalog: single source of truth mapping every cap slug to
  a label, description, domain group and level. CI asserts it covers
  exactly CapabilityManager::get_all_capabilities().
- Render: grouped collapsible cards (admin groups start collapsed), live
  search across label+slug, Grant/Revoke-all presets, copyable monospace
  slug chip per row, origin badge (User vs Role), live per-group count,
  and a read-only role + audiences context summary (role stays in WP's
  native selector; audiences link to the Audiences screen).
- Fix: the old form rendered ~10 of ~26 caps while save iterated all of
  them, so every cap without a checkbox was silently remove_cap()'d on
  save. Render and save now both derive from the catalog.
- Assets: new ffc-user-permissions.css; ffc-user-capabilities.js rewritten
  (vanilla, no jQuery) for presets/search/collapse/copy/live-count.
- Tests: CapabilityCatalogTest (registry parity + metadata), updated
  AdminUserCapabilitiesTest (new markup + enqueue), new Vitest suite, and
  retired the superseded tiny-scripts block.
- Includes the design mockup under docs/mockups/.
@rpgmem
rpgmem marked this pull request as ready for review June 3, 2026 10:27
@rpgmem
rpgmem enabled auto-merge (squash) June 3, 2026 10:27
Turns the read-only audiences summary into an inline editor: a checklist
of every active audience (pre-checked for current memberships), synced on
the same profile-form save.

- render_audience_membership(): lists active audiences as ffc_audience[]
  checkboxes with a color dot, pre-checked per membership; links to the
  Audiences screen.
- sync_audience_membership(): whitelists the submission against the active
  set, diffs against current active memberships, and applies the minimal
  add_member/remove_member calls. Only active audiences participate, so a
  membership in an inactive audience is never touched; if no audiences are
  active (checklist not rendered) it is a no-op, so it can't wipe on an
  unrelated save. Changes are audit-logged.
- CSS: audience checklist styles. Tests: +1 render, +3 save (add / remove
  on uncheck / no-op when none active).
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.

2 participants