Skip to content

fix: hide remove role button for users without permissions#142

Merged
jacobo-dominguez-wgu merged 2 commits intoopenedx:masterfrom
WGU-Open-edX:fix/remove-role-permissions
Apr 24, 2026
Merged

fix: hide remove role button for users without permissions#142
jacobo-dominguez-wgu merged 2 commits intoopenedx:masterfrom
WGU-Open-edX:fix/remove-role-permissions

Conversation

@jacobo-dominguez-wgu
Copy link
Copy Markdown
Contributor

@jacobo-dominguez-wgu jacobo-dominguez-wgu commented Apr 23, 2026

Description

Adding permission check for team management manage_library_team or manage_course_team to disable or enable delete role button.

Also added query invalidation for user with all the query settings when a role is removed.

UPDATE:

  • Added missing tooltip for displaying a message on the delete button for own admin roles.
  • Fixing bug on delete button disabled when removing filters, returning to previous table page or after getting back from role assignation wizard.

It closes #141

image

How to test it

Test 1

  1. Login with a user with admin role over a resource (course or library, example Library Admin for lib:myOrg:myLib)
  2. Go to http://apps.local.openedx.io:2025/admin-console/authz
  3. On the team members list, select a team member with any role assigned on the same resource your current user (Example a user with any role assigned for lib:myOrg:myLib)
  4. Click on the Eye icon button to go to the audit user page for that team member.
  5. On the audit page, the row for the role assigned on the same resource should display the delete role button as enabled.

Test 2

  1. Login with a user without admin role assigned.
  2. Go to http://apps.local.openedx.io:2025/admin-console/authz
  3. On the team members list, select a team member and go to the audit page user by clicking the Eye icon button on the actions column.
  4. On the audit page, all the delete role buttons should be disabled.

@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 Apr 23, 2026
@openedx-webhooks
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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.36%. Comparing base (2b3b480) to head (a256525).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #142      +/-   ##
==========================================
+ Coverage   97.34%   97.36%   +0.02%     
==========================================
  Files          89       89              
  Lines        2106     2129      +23     
  Branches      457      501      +44     
==========================================
+ Hits         2050     2073      +23     
  Misses         53       53              
  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.

action,
scope,
};
const { data: hasPermission, isLoading } = useValidateUserPermissions([permission]);
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 works, but doing it item-by-item is not very efficient.

Do you see anyway we could do it in bulk? like using useValidateUserPermissions on a parent component that has knowledge of all the items currently displayed on the table? useValidateUserPermissions supports querying permissions in bulk, this results in a single request instead of one per item.

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.

Sure, moved to a parent component to create a bulk request.

Comment thread src/authz-module/audit-user/index.tsx Outdated
const deletePermissions = useMemo(() => {
const uniqueScopes = [...new Set(userAssignments.map(assignment => assignment.scope))];
const permissions = uniqueScopes.map(scope => {
const action = scope.startsWith('lib') ? CONTENT_LIBRARY_PERMISSIONS.MANAGE_LIBRARY_TEAM : CONTENT_COURSE_PERMISSIONS.MANAGE_COURSE_TEAM;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Let's extract this into a dedicated function, so we can easily extend it when more scopes are added.

Copy link
Copy Markdown

@rodmgwgu rodmgwgu left a comment

Choose a reason for hiding this comment

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

Tested and works great!, just added a nit comment, thanks!

@jacobo-dominguez-wgu jacobo-dominguez-wgu force-pushed the fix/remove-role-permissions branch from 1334afd to df73f14 Compare April 24, 2026 16:05
@jacobo-dominguez-wgu
Copy link
Copy Markdown
Contributor Author

Tested and works great!, just added a nit comment, thanks!

Added the missing tooltip and fixed the issue on wrong delete button disabled when removing filters, returning to previous table page or after getting back from role assignation wizard.

@rodmgwgu Could you check again?

@jacobo-dominguez-wgu jacobo-dominguez-wgu force-pushed the fix/remove-role-permissions branch from bea844b to a256525 Compare April 24, 2026 20:29
Copy link
Copy Markdown

@rodmgwgu rodmgwgu left a comment

Choose a reason for hiding this comment

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

Tested and everything is working great now, thanks!

@jacobo-dominguez-wgu jacobo-dominguez-wgu merged commit adf92ef into openedx:master Apr 24, 2026
6 checks passed
@github-project-automation github-project-automation Bot moved this from Needs Triage to Done in Contributions Apr 24, 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). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Hide delete button according to team management permissions

3 participants