Skip to content

Add the permissions step to the create custom role wizard - #295

Merged
jacobo-dominguez-wgu merged 7 commits into
masterfrom
jacobo/create-role-wizard-2
Dec 4, 2026
Merged

jacobo-dominguez-wgu merged 7 commits into
masterfrom
jacobo/create-role-wizard-2

Conversation

@jacobo-dominguez-wgu

@jacobo-dominguez-wgu jacobo-dominguez-wgu commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds the second step of the create custom role wizard: a permissions matrix where the user picks what the new role grants. Selecting a permission turns on and locks everything it depends on, using the dependency lists the roles catalog now returns (openedx/openedx-authz#658).

Closes openedx/openedx-authz#572.
Design figma
Requires openedx/openedx-authz#560 and openedx/openedx-authz#574

Changes

  • Permissions matrix (PermissionsEditor):
    • Permissions are grouped into collapsible categories from the catalog API. Permissions without a category go under "Other".
    • Each row is a labeled switch with its description.
    • Each category header shows an "x of y permissions selected" count and a Select all / Deselect all button.
  • Toolbar:
    • Search matches permission names and descriptions. It opens the matching categories, hides the rest, and announces the result count to screen readers.
    • Expand all / Collapse all is disabled while a search holds categories open.
    • Select all only acts on the rows the search shows, so it never changes hidden permissions.
  • Summary panel: a sticky side panel shows the total selected, a per-category "x/y" tally and the "Scope is assigned later" note.
  • Dependencies:
    • The Permission type gets dependsOn and allDependsOn from the catalog API. Both default to [] when the backend leaves them out.
    • Selecting a permission turns on and locks everything in its allDependsOn.
    • A locked row shows a label beside its name. It reads Auto-enabled · Required by "…" when the user didn't choose that permission, and Required by "…" when they did, by hand or through a cloned role.
    • A chosen permission stays on when the permission that needed it is turned off. One that was only auto-enabled is released.
  • Selection state (usePermissionSelection):
    • The wizard owns the selection, so it survives Back and Next and edits to the name.
    • The selection restarts when the resource type or the cloned role changes.
    • Cloning a role starts with its permissions selected.
  • Create button: the permissions step's Create button is disabled until at least one permission is selected.
  • SearchFilter: takes an optional className (default mw-xs) so the matrix search can be wider than the table control bars' search.

Notes for reviewers

  • Create button: it isn't wired to the API yet (TODO(#573)). Creating the role is in the follow-up PR stacked on this one.
  • Size: the diff is about 1,300 lines, most of it new components and their tests.
  • Folder merge: moving roles-permissions/ and role-detail/ into a single feature folder, as discussed in review and Proposal - feature based code organization #247, is deferred to its own refactor PR.
  • Out-of-catalog dependencies: these count as granted, but have no row in the matrix.
  • Filter: the filter from the issue was dropped by product decision.

Testing

Automated

  • tsc and eslint pass.
  • Unit, component and wizard tests cover selection, dependencies, search, Select all, summary, clone and Back/Next.

Manual

Open Create Custom Role, enter a name and click Next.

  • Permissions are grouped by category, and each category opens and closes.
  • Turning a permission on or off updates the category's "x of y" count and the summary total.
  • Select all / Deselect all turns the whole category on or off.
  • Expand all / Collapse all opens or closes every category.
  • Search shows only matching permissions, with their categories open. Expand all is disabled while searching.
  • Select all while searching only turns on the permissions shown.
  • Turning on a permission with dependencies turns them on and locks them, with Auto-enabled · Required by "…" beside the name. Turning it off releases them.
  • A permission turned on by hand, then required by another, shows only Required by "…" and stays on when the other is turned off.
  • Cloning a role starts with its permissions selected. Those it shares with a new dependent show Required by "…", not "Auto-enabled".
  • The selection survives Back and Next and changes to the name.
  • Changing the resource type starts the selection over.
  • Create is disabled until a permission is selected.
  • Every switch can be reached and toggled with the keyboard, and a locked switch reads its "Required by" label.

Demo

Screen.Recording.2026-12-04.at.10.28.00.AM.mov

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Nov 25, 2026
@openedx-webhooks

openedx-webhooks commented Nov 25, 2026 •

Copy link
Copy Markdown

Thanks for the pull request, @jacobo-dominguez-wgu!

This repository is currently maintained by @openedx/committers-frontend.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Nov 25, 2026
@jacobo-dominguez-wgu
jacobo-dominguez-wgu force-pushed the jacobo/create-role-wizard-2 branch 2 times, most recently from c6baf50 to 682e8a5 Compare November 25, 2026 18:48
@codecov

codecov Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.22%. Comparing base (5e6f3ce) to head (1ec35f7).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #295      +/-   ##
==========================================
+ Coverage   99.16%   99.22%   +0.05%     
==========================================
  Files         103      110       +7     
  Lines        1923     2062     +139     
  Branches      620      658      +38     
==========================================
+ Hits         1907     2046     +139     
  Misses         16       16              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rodmgwgu rodmgwgu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking pretty good so far, I'm posting my findings so far. Thanks!

@jacobo-dominguez-wgu
jacobo-dominguez-wgu force-pushed the jacobo/create-role-wizard-2 branch 2 times, most recently from c6517b8 to a3c22c5 Compare November 27, 2026 22:52
@jacobo-dominguez-wgu
jacobo-dominguez-wgu force-pushed the jacobo/create-role-wizard-2 branch from a3c22c5 to 3ad02d3 Compare December 1, 2026 22:04
* Second step of the create custom role wizard: the permissions of the role as a matrix of
* collapsible categories, beside a summary of what is enabled.
*/
const PermissionsStep = ({ categories, permissions, selection }: PermissionsStepProps) => {

@diana-villalvazo-wgu diana-villalvazo-wgu Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this component will be reused on role detail/permissions tab should we move it outside roles-permissions folder? and probably rename it to PermissionsList since in role detail is no longer a "step"🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, it shouldn't be called a "step" once role detail uses it, so PermissionsList sounds good, but instead of moving it to the root components folder I would go with merging ../authz-module/roles-permissions/ and ../authz-module/role-detail/ into single folder ../authz-module/roles/ (name TBD):

authz-module/
└── roles/                      # ← roles-permissions + role-detail (name TBD)
    ├── index.ts                # RolesPermissionsTable, CreateCustomRole, role-detail tabs
    ├── RolesPermissionsTable.tsx
    ├── components/             # atoms shared inside the feature, no index.ts
    ├── permissions-list/       # PermissionsList + matrix pieces + selection hook, with index.ts
    ├── create-role/            # CreateCustomRole, NameAndResourceStep, customRoleDraft
    ├── role-detail/            # members/, permissions/ (RolePermissionEditor uses permissions-list)
    └── messages.ts

Creating, viewing and editing a role's permissions look like one feature to me, and this way we follow the feature-based organization proposal in #247.

Thoughts @dcoa, @diana-villalvazo-wgu?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good to me 👍 great proposal

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's great! My only comment is that I think PermissionEditor is more appropriate than PermissionList, as the component allows users to add and remove permissions from a role rather than just view them (That applies for both the modal and the tab, correct?).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed the component to PermissionEditor and created a follow up ticket two merge the folders #306.

@jacobo-dominguez-wgu
jacobo-dominguez-wgu force-pushed the jacobo/create-role-wizard-2 branch from 3ad02d3 to b106b03 Compare December 2, 2026 20:22
@mphilbrick211 mphilbrick211 added the mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). label Dec 2, 2026
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Dec 2, 2026
Base automatically changed from jacobo/create-role-wizard-1 to master December 3, 2026 15:32
@jacobo-dominguez-wgu
jacobo-dominguez-wgu force-pushed the jacobo/create-role-wizard-2 branch from b106b03 to a33f37e Compare December 3, 2026 15:32
@jacobo-dominguez-wgu
jacobo-dominguez-wgu force-pushed the jacobo/create-role-wizard-2 branch from a33f37e to edc7078 Compare December 3, 2026 20:32
@jacobo-dominguez-wgu
jacobo-dominguez-wgu force-pushed the jacobo/create-role-wizard-2 branch from edc7078 to 0f2fbb4 Compare December 3, 2026 20:47
@jacobo-dominguez-wgu

Copy link
Copy Markdown
Contributor Author

The permission dependencies is implemented now

Screen.Recording.2026-12-03.at.3.50.40.PM.mov

@jacobo-dominguez-wgu
jacobo-dominguez-wgu marked this pull request as ready for review December 3, 2026 21:53
@rodmgwgu

rodmgwgu commented Dec 3, 2026

Copy link
Copy Markdown

The permission dependencies is implemented now

Screen.Recording.2026-12-03.at.3.50.40.PM.mov

Thanks for the video Jacobo, I'm seeing one inconsistency with the design, the "Auto-enabled" message doesn't match the position and style shown in figma, see:

Screenshot 2026-12-03 at 3 59 30 p m

@rodmgwgu rodmgwgu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates, I haven't reviewed everything yet, but I'm posting the findings I have so far.

Also, could you update the PR description to reflect the current state please?

Thanks!

@rodmgwgu rodmgwgu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran this in my local and, other than my previous comments, works great, Great work!

@jacobo-dominguez-wgu
jacobo-dominguez-wgu force-pushed the jacobo/create-role-wizard-2 branch from d5867b9 to ccfe6da Compare December 4, 2026 16:14
@jacobo-dominguez-wgu

Copy link
Copy Markdown
Contributor Author

Thanks for the updates, I haven't reviewed everything yet, but I'm posting the findings I have so far.

Also, could you update the PR description to reflect the current state please?

Thanks!

Thank you, I did address your comments and update the description.

@rodmgwgu rodmgwgu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for attending all my comments!, re-ran it in my local and all works as expected.

@diana-villalvazo-wgu diana-villalvazo-wgu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


return (
<div className="py-4">
<Row className="mx-0">

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of having a div wrapping the row why don't add the classname on the row?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No reason, removed on the next pr of the stack #297

@jacobo-dominguez-wgu
jacobo-dominguez-wgu merged commit 1da44c5 into master Dec 4, 2026
6 checks passed
@jacobo-dominguez-wgu
jacobo-dominguez-wgu deleted the jacobo/create-role-wizard-2 branch December 4, 2026 19:01
@github-project-automation github-project-automation Bot moved this from Waiting on Author to Done in Contributions Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Frontend: Create Custom Role wizard Permissions page

6 participants