Skip to content

feat: add checkbox for platform-wide scope assigment#197

Open
dcoa wants to merge 2 commits into
openedx:masterfrom
eduNEXT:dcoa/wizard-fix
Open

feat: add checkbox for platform-wide scope assigment#197
dcoa wants to merge 2 commits into
openedx:masterfrom
eduNEXT:dcoa/wizard-fix

Conversation

@dcoa

@dcoa dcoa commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Description

This PR enables platform-scoped permission assignment for libraries and courses. The permission system determines whether a user has Manage Team permissions across all courses (courses-v1:*) or all libraries (lib:*) on the platform. If the user has the required platform-wide permissions, the UI displays a checkbox that allows them to grant the same platform-scoped permission level to another user.

image

This changes complement the wizard UI, now that the backend support the option openedx/openedx-authz#343.

Testing instructions

  • Use the current branch.

  • Open admin console with a regular user with manage team permissions, such as course admin or library admin.

  • Click assign role and fill the form. The option should not be displayed in the scope list.

  • Open the console with a Django admin or staff.

  • Follow the assign role process. A checkbox All <scope> in Platform should be displayed. Select it and save.

  • A confirmation toast should be displayed. And a new row in the table should appear for the selected user and the wildcard in scopes: courses (courses-v1:*) or libraries (lib:*)

@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 Jul 22, 2026
@openedx-webhooks

openedx-webhooks commented Jul 22, 2026

Copy link
Copy Markdown

Thanks for the pull request, @dcoa!

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 Jul 22, 2026
@dcoa
dcoa marked this pull request as ready for review July 22, 2026 11:22
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.72%. Comparing base (dafae7d) to head (928048b).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #197      +/-   ##
==========================================
+ Coverage   97.66%   97.72%   +0.06%     
==========================================
  Files          68       68              
  Lines        1668     1674       +6     
  Branches      441      441              
==========================================
+ Hits         1629     1636       +7     
+ Misses         39       38       -1     

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

@bra-i-am

Copy link
Copy Markdown
Contributor

Testing behavior

  • With a regular user: the option should not be displayed in the scope list
  • With an admin user: a checkbox All <scope> in Platform should be displayed
  • When selected and saved, a confirmation toast is displayed
  • A new row in the table should appear for the selected user and the wildcard in scopes: courses (courses-v1:*) or libraries (lib:*)

  1. Despite having course-v1:*, in the Step 1 of the wizard I can't select any course role

    Screencast.from.23-07-26.10.38.50.webm

@bra-i-am bra-i-am 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.

Thanks for this PR. I have one comment about the behavior and a recommendation about the code. Everything else is great!

Comment thread src/authz-module/constants.ts Outdated
library: 'lib:*',
};

export const getPlatformAggregateScopeKey = (contextType: string): string => {

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.

I think the contextType can be guarded by typings; something like this could work

Suggested change
export const getPlatformAggregateScopeKey = (contextType: string): string => {
export const getPlatformAggregateScopeKey = (contextType: keyof typeof PLATFORM_AGGREGATE_SCOPE_KEYS): string => {

This will also fix the typing from scope at
const scope = PLATFORM_AGGREGATE_SCOPE_KEYS[contextType];
below

@dcoa dcoa Jul 24, 2026

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 made some changes about it 928048b

@dcoa

dcoa commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author
1. Despite having `course-v1:*`, in the `Step 1` of the wizard I can't select any course role

That behavior is correct. The user has been assigned the Course Staff role, which has the View Team permission but not the Manage Team permission.

image

const { data: orgPerms } = useValidateUserPermissions(orgPermissionRequests);
const { data: perms } = useValidateUserPermissions(permissionRequests);

const hasPlatformPermission = !!contextType && (perms?.[0]?.allowed ?? false);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is perms?.[0] safe enough? How do we always ensure this order?

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.

4 participants