Skip to content

feat(authz): duplicate a role from the roles table and the role detail page - #307

Draft
rodmgwgu wants to merge 3 commits into
openedx:diana/permissions-tabfrom
WGU-Open-edX:feat/duplicate-role
Draft

rodmgwgu wants to merge 3 commits into
openedx:diana/permissions-tabfrom
WGU-Open-edX:feat/duplicate-role

Conversation

@rodmgwgu

@rodmgwgu rodmgwgu commented Dec 4, 2026 •

Copy link
Copy Markdown

Closes openedx/openedx-authz#583

Stacked on #305 (which is on #297 and #295).

Problem

The "Duplicate" item in the roles table row menu, the "Duplicate" item in the custom role detail menu, and the "Duplicate Role" button on a built-in role's detail page were not yet connected to anything.

Approach

Per ADR 0036, there is no duplicate endpoint. Duplicate opens the create custom role wizard with "Clone from role" selected and the source role preselected. The name starts empty and is required, because the role ID is derived from it and never changes (ADR 0035).

  • CreateCustomRoleWizard takes an optional initialSourceRole, which seeds the draft in clone mode, and an optional onCreated callback.
  • Roles table: the row's Duplicate item opens the wizard, through RoleAssignmentContext. It is disabled for users who cannot manage roles. After create, the user stays on the table, as with Create Custom Role.
  • Role detail page: the custom role menu item and the built-in role button open the wizard. After create, the new role's detail page opens.
  • The Role name field is focused when the wizard opens, for both Create and Duplicate.
  • The user can still switch to "Start from scratch". The request is the normal create call (name, resource type, permissions), so the copy has no assignments and no link to the source role.

Backend: uses the create and name validation endpoints from openedx-authz, which are already released.

Manual testing instructions

As a user who can manage roles:

  1. Open Roles and Permissions. In a built-in role's row menu, click Duplicate. The wizard opens with "Clone from role" and the role selected, and the empty Role name field focused.
  2. Enter a name, click Next. The permissions step starts with the source role's permissions. Click Create. The success toast shows and the new role is in the table.
  3. Open a custom role's detail page, open the ⋮ menu, click Duplicate, and create it. The new role's detail page opens.
  4. Open a built-in role's detail page and click Duplicate Role. The wizard opens on that role.
  5. As a user who cannot manage roles, the row's Duplicate item is disabled and the detail page shows no Duplicate action.

Rollback plan

Revert this PR. Frontend only; no stored data.

Retro compatibility

DuplicateRoleButton now requires an onClick prop; its only caller is updated. The wizard's new props are optional.

AI Usage

🤖 This change was made with assistance from Kiro, with human guidance on the decisions and validation against ADR 0035 and ADR 0036.


Merge checklist:

…l page

Duplicate opens the create custom role wizard in clone mode with the role
preselected. The name starts empty and the copy is saved with the normal
create call (ADR 0036). From the detail page, the new role opens once created.

Closes openedx/openedx-authz#583
@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 4, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @rodmgwgu!

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 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.32%. Comparing base (460567b) to head (9df1eeb).

Additional details and impacted files
@@                  Coverage Diff                   @@
##           diana/permissions-tab     #307   +/-   ##
======================================================
  Coverage                  99.31%   99.32%           
======================================================
  Files                        110      110           
  Lines                       2197     2215   +18     
  Branches                     705      711    +6     
======================================================
+ Hits                        2182     2200   +18     
  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.

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.

2 participants