Skip to content

Conversation

@bra-i-am
Copy link
Contributor

@bra-i-am bra-i-am commented Oct 14, 2025

Warning

This PR depends on #6 because it manages the users' roles view

This pull request allows deleting users' roles from the users' roles view

Evidence

Screencast.from.15-10-25.17.53.05.webm

Testing instructions

  1. Create and set up a local environment (Tutor recommended)
  2. Run LMS and CMS, then clone the repo in the current branch and run the dev server npm run dev
  3. Add the URL to the CORS_WHITELIST in both LMS/CMS settings.py
# admin console MFE
CORS_ORIGIN_WHITELIST.append("http://apps.local.openedx.io:2025")
LOGIN_REDIRECT_WHITELIST.append("apps.local.openedx.io:2025")
CSRF_TRUSTED_ORIGINS.append("http://apps.local.openedx.io:2025")
  1. Go to the Studio and create a library
  2. Navigate to http://apps.local.openedx.io:2025/admin-console/authz/libraries/< your_library_id >
  3. Install the plugin https://github.com/openedx/openedx-authz by running tutor dev exec lms pip install git+https://github.com/openedx/openedx-authz
  4. Run the migrations tutor dev exec lms python manage.py lms migrate openedx_authz
  5. Load the default policies by running tutor dev exec lms python manage.py lms load_policies
  6. Go to http://local.openedx.io:8000/api-docs/#/authz/authz_v1_roles_users_update and add a role to any user different from the logged-in one, following the structure
{
  "role": "library_author", // Create another with "library_admin" to be able to filter
  "scope": "lib:OpenedX:testlib", // Id of the previously created library
  "users": [
    "admin"
    // more usernames or emails if wanted
  ]
}
  1. Navigate to http://apps.local.openedx.io:2025/admin-console/authz/libraries/< your_library_id >
  2. Click the Edit button at the end of the user row
  3. Click the button Add New Role, fill the form, and click save
  4. Repeat the previous step to have a user with a minimum of 2 assigned roles
  5. Now, click the trash icon of any of the previously assigned roles; you should see a proper toast
  6. Remove all the assigned roles by clicking the trash icons; you should see a proper toast

Additional Information

openedx/openedx-authz#45

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 14, 2025
@openedx-webhooks
Copy link

openedx-webhooks commented Oct 14, 2025

Thanks for the pull request, @bra-i-am!

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.


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 Oct 14, 2025
@bra-i-am bra-i-am changed the title Bc/implement delete role feat: allow deleting user's roles Oct 14, 2025
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Oct 15, 2025
@bra-i-am bra-i-am force-pushed the bc/implement-delete-role branch from 2dd55c8 to b1ea8ef Compare October 15, 2025 22:48
},
onError: (error) => {
// eslint-disable-next-line no-console
console.error('Failed to revoke user role:', error);
Copy link
Contributor

Choose a reason for hiding this comment

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

use the logger for frontend-platform instead

@bra-i-am bra-i-am changed the title feat: allow deleting user's roles feat: [FC-0099] allow deleting user's roles Oct 20, 2025
@dcoa dcoa force-pushed the bc/implement-delete-role branch from b1ea8ef to 95af7f8 Compare October 22, 2025 04:25
@codecov
Copy link

codecov bot commented Oct 22, 2025

Codecov Report

❌ Patch coverage is 97.87234% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.86%. Comparing base (50beaef) to head (de47612).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...-module/libraries-manager/LibrariesUserManager.tsx 95.45% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #13      +/-   ##
==========================================
+ Coverage   93.66%   93.86%   +0.20%     
==========================================
  Files          41       43       +2     
  Lines         710      799      +89     
  Branches      147      145       -2     
==========================================
+ Hits          665      750      +85     
- Misses         42       46       +4     
  Partials        3        3              

☔ View full report in Codecov by Sentry.
📢 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.

Copy link
Contributor

@jacobo-dominguez-wgu jacobo-dominguez-wgu left a comment

Choose a reason for hiding this comment

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

Tested on the sandbox and roles is correctly deleted, just a minor comment but it LGTM!

actions={
showDelete && <IconButton variant="danger" alt="Delete role action" src={Delete} />
handleDelete && (
<IconButton variant="danger" onClick={handleDelete} alt="Delete role action" src={Delete} />
Copy link
Contributor

Choose a reason for hiding this comment

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

The alt should be an intl messsage.

@MaferMazu MaferMazu moved this to In Progress in RBAC AuthZ Board Oct 22, 2025
@bra-i-am bra-i-am marked this pull request as ready for review October 22, 2025 21:03
@dcoa dcoa moved this from In Progress to Ready for review in RBAC AuthZ Board Oct 23, 2025
@dcoa dcoa force-pushed the bc/implement-delete-role branch 2 times, most recently from f377944 to 12e2558 Compare October 23, 2025 17:18
Copy link

@arbrandes arbrandes left a comment

Choose a reason for hiding this comment

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

The feature works and the code is mostly fine, thank you!

I would like to see us avoid getByTestId unless there's no other way, though. Also, there's that alt that requires internationalization.

const user = userEvent.setup();
renderComponent();

const deleteButton = screen.getByTestId('delete-role-Admin');

Choose a reason for hiding this comment

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

Can we please avoid getByTestId wherever possible? (See the docs.)

@dcoa dcoa force-pushed the bc/implement-delete-role branch 2 times, most recently from 3db08f1 to 582b141 Compare October 23, 2025 21:44
@dcoa dcoa force-pushed the bc/implement-delete-role branch from 582b141 to 64eb726 Compare October 23, 2025 21:50
@dcoa dcoa force-pushed the bc/implement-delete-role branch from 64eb726 to de47612 Compare October 23, 2025 22:09
@dcoa dcoa requested a review from arbrandes October 23, 2025 22:18
@dcoa
Copy link
Contributor

dcoa commented Oct 24, 2025

@arbrandes I addressed the comments

Copy link

@arbrandes arbrandes left a comment

Choose a reason for hiding this comment

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

Thank for addressing the review!

@arbrandes arbrandes merged commit 8dc3139 into openedx:master Oct 24, 2025
6 checks passed
@github-project-automation github-project-automation bot moved this from Ready for review to Done in RBAC AuthZ Board Oct 24, 2025
@github-project-automation github-project-automation bot moved this from Waiting on Author to Done in Contributions Oct 24, 2025
@arbrandes arbrandes mentioned this pull request Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: Done
Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants