Skip to content

Permissions tab - #305

Draft
diana-villalvazo-wgu wants to merge 11 commits into
jacobo/create-role-wizard-3from
diana/permissions-tab
Draft

diana-villalvazo-wgu wants to merge 11 commits into
jacobo/create-role-wizard-3from
diana/permissions-tab

Conversation

@diana-villalvazo-wgu

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

Copy link
Copy Markdown
Contributor

Description

The Permissions tab on the role detail page now shows the role's permissions. It uses the same matrix as the create custom role wizard: collapsible categories, search, expand/collapse all, and the PermissionsSummary beside them. The matrix is limited to the role's scope type and starts from the permissions the role grants.

Custom roles can be edited.

  • Dependencies are locked, as in the wizard.
  • Once the selection differs from the role's permissions, a warning alert sticks to the bottom of the screen with Save changes and Cancel.
  • If the selection goes back to the role's permissions, the alert goes away.
  • Save changes sends PATCH /api/authz/v1/roles/<role_id>/ (openedx-authz ADR 0036). The request carries every permission now granted, chosen or required, in catalog order.
  • A success toast confirms the save, and the catalog is refreshed so the role detail page and the roles table show the new permissions.
  • Cancel restores the role's permissions and keeps the open categories open.

Standard roles are read-only. The matrix lists only the permissions the role grants, with no switches and no Select all, and leaves out the categories where the role grants nothing. Search, expand/collapse all and the summary still work.

Errors are handled as in CreateCustomRole:

  • 400, 403 and 404 show our own message, because the server's message isn't translated. They don't offer Retry, since resending the same permissions changes nothing.
  • Any other failure is logged and shows the usual message from ERROR_TOAST_MAP, with a Retry that sends the same changes again.
  • The error appears in a dismissible danger alert above the changes alert, and focus moves to it. The changes stay on screen, so they can be fixed, retried or cancelled.

Changes

catalog:

  • New updateCustomRolePermissions API function. It sends only permissions, with the role id encoded in the URL, and returns the role camel-cased.
  • New useUpdateCustomRolePermissions hook. It refreshes the catalog on success, like useCreateCustomRole.
  • Both are exported from the catalog barrel.

RolePermissionsEditor.tsx:

  • Reuses PermissionsStep and usePermissionSelection from the create custom role wizard.
  • Takes the categories and permissions from the catalog of the role's scope type (role.scopeTypes[0]). It renders nothing when the catalog has no part for that scope type.
  • Passes isReadOnly to PermissionsEditor for standard roles.
  • Save changes and Cancel are disabled while saving.
  • RoleDetailPage renders < EditRolePermissions role={role} /> in the Permissions tab.

Permissions matrix (roles-permissions/components)

  • PermissionsEditor takes an optional isReadOnly prop. It defaults to false, so the create custom role wizard works as before. When it's set, the matrix only lists the granted permissions and passes isReadOnly down.
  • PermissionCategorySection hides Select all when read-only.
  • PermissionRow hides the switch and the lock note when read-only.

Renames

  • RolesPermissions → RoleComparison, the matrix shown in the Comparison tab. This keeps it from being confused with RolesPermissionsTable and EditRolePermissions once role-detail and roles-permissions are unified.

Screenshots

View only for standard roles:
Screenshot 2026-12-03 at 4 32 36 p m

Edit mode for custom roles:
Screenshot 2026-12-03 at 4 28 01 p m

After a permissions change:
Screenshot 2026-12-03 at 4 28 23 p m

Support Info

Closes openedx/openedx-authz#577

LLM Usage

Built with assistance from Claude.

@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 Dec 2, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @diana-villalvazo-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.

🔘 Update the status of your PR

Your PR is currently marked as a draft. After completing the steps above, update its status by clicking "Ready for Review", or removing "WIP" from the title, as appropriate.


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.

@codecov

codecov Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.31%. Comparing base (0db356c) to head (460567b).

Additional details and impacted files
@@                       Coverage Diff                       @@
##           jacobo/create-role-wizard-3     #305      +/-   ##
===============================================================
+ Coverage                        99.29%   99.31%   +0.02%     
===============================================================
  Files                              110      110              
  Lines                             2125     2197      +72     
  Branches                           629      705      +76     
===============================================================
+ Hits                              2110     2182      +72     
  Misses                              15       15              

☔ 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.

openedx/openedx-authz#577 asks for a confirm when navigating away with unsaved changes. I don't see that here, so leaving the page drops the edits without warning. Can we add it?

Also, can you update the PR description to reflect latest changes please?

Thanks!

},
'authz.custom.role.changes.description': {
id: 'authz.custom.role.changes.description',
defaultMessage: 'Your changes will not take effect until you save your progress. Take care with key and value formatting, as validation is not implemented.',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think we should remove the part that says "Take care with key and value formatting, as validation is not implemented", seems this was a leftover from an early prototype that got to the design

categories={scopeCatalog.categories}
permissions={permissions}
selection={selection}
isReadOnly={!isCustomRole(role)}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This only checks that the role is custom, so a user who can view the role but isn't staff or superuser gets the switches and Save changes, and only finds out with a 403 on save. Can we also make it read-only when useCanManageRoles() is false, like the Duplicate and Delete actions on the page? A test for that case would be good too.

[scopeType, initialPermissions],
);
// The selection restarts from the seed whenever this id changes, so Cancel changes it.
const selection = usePermissionSelection(seed, `${role.role}#${resetCount}`, permissions);

@rodmgwgu rodmgwgu Dec 4, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: usePermissionSelection names and documents the first param (seed) as cloneSourceRole, but here it's a seed. Can we rename it to something like seedKey and update its JSDoc, so it reads right for both callers?

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). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

Frontend: Role detail Permissions tab (custom roles, editable)

4 participants