Skip to content

Roles: global role-capability editor on Settings → User Access (Frente B) - #487

Merged
rpgmem merged 2 commits into
developfrom
claude/role-capability-editor
Jun 3, 2026
Merged

Roles: global role-capability editor on Settings → User Access (Frente B)#487
rpgmem merged 2 commits into
developfrom
claude/role-capability-editor

Conversation

@rpgmem

@rpgmem rpgmem commented Jun 3, 2026

Copy link
Copy Markdown
Owner

What (Frente B) — closes #484

The global-scope half of the permissioning split: a role-capability editor on Settings → User Access. Pick an FFC role and toggle which catalog capabilities it grants — editing the role definition itself.

This is the counterpart to the per-user panel:

UX

  • Lives in the existing User Access tab (per your call — not a new tab), below the access-blocking form.
  • Reuses the same grouped-card / search / slug-chip UI as the per-user panel.
  • A role <select> with each role's member count; switching swaps the toggles to that role's caps (live).
  • A prominent banner: changes are global and retroactive, save as you toggle, and are logged.

Safety

  • Persistence is per-toggle via an isolated AJAX endpoint (wp_ajax_ffc_set_role_capWP_Role::add_cap/remove_cap) — separate from the User Access options form on the same tab, so the two saves never collide.
  • Restricted to FFC-managed roles (CapabilityManager::ffc_managed_role_labels()) and to cataloged caps — core/super roles and non-FFC caps are never touched.
  • cap- + nonce-gated, audit-logged.

Tests & gates

  • +8 PHPUnit (editable-role discovery excludes unregistered/core; role→caps map filters to catalog; render smoke; AJAX grant/remove + role-whitelist + cap-catalog + manage_options guards). A render test caught a real bug — AdminUI::get_toggle returns empty for an empty name, so the toggles weren't rendering; fixed.
  • +3 Vitest (role-picker swap, persist success shows "Saved" + syncs map, failure reverts).
  • Green: PHPUnit 4963 · Vitest 1113 · ESLint · Stylelint · WPCS · PHPStan 8. npm run build ran.

Targets develop; no FFC_VERSION bump. CHANGELOG [Unreleased] updated.

https://claude.ai/code/session_011ErkuJ7jnF9zkqCkGs3qKN


Generated by Claude Code

…e B)

The global-scope half of the permissioning split (#484): edit which FFC
capabilities each FFC role grants, from Settings → User Access. The
per-user panel assigns roles + fine-tunes one user; this editor changes
the role definition itself.

- RoleCapabilityEditor: pick an FFC role, toggle its cataloged caps. Reuses
  the CapabilityCatalog grouped-card / search / slug-chip UI; shows each
  role's member count + a prominent global/retroactive impact banner.
- Persistence is per-toggle via an isolated AJAX endpoint
  (wp_ajax_ffc_set_role_cap → WP_Role add_cap/remove_cap), separate from
  the User Access options form on the same tab. Restricted to
  CapabilityManager::ffc_managed_role_labels() and to cataloged caps —
  never touches core/super roles or non-FFC caps; cap- + nonce-gated;
  audit-logged.
- CapabilityManager::ffc_managed_role_labels() exposes the canonical FFC
  role set (extracted from relabel_ffc_roles).
- Rendered from the user-access tab view, outside the settings <form>.
- Tests: +8 PHPUnit (editable-role discovery, role→caps map, render smoke,
  AJAX grant/remove + role/cap/cap-guard), +3 Vitest (role-picker swap,
  persist success, failure revert).

Closes #484.
@rpgmem
rpgmem marked this pull request as ready for review June 3, 2026 15:32
@rpgmem
rpgmem enabled auto-merge (squash) June 3, 2026 15:33
WPCS 3.3.0 (CI) rejects a list<...> pseudo-type on a parameter docblock
("Expected type hint list<string>; found array"). Match the codebase's
array<...> param convention; the value passed is still a list<string>.
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