Skip to content

feat(authz): add read only permissions alert - #3193

Open
dcoa wants to merge 8 commits into
openedx:masterfrom
eduNEXT:bc/change-course-update-view
Open

feat(authz): add read only permissions alert#3193
dcoa wants to merge 8 commits into
openedx:masterfrom
eduNEXT:bc/change-course-update-view

Conversation

@dcoa

@dcoa dcoa commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Description

This PR is the continuation of the effort to implement the new Authz system into Course Authoring. The PR is focused on displaying a View Only Alert for Course Auditors/Course Editors.

Implemented changes

  • Create a new component ViewOnlyPermissionsAlert (src/generic/ViewOnlyPermissionsAlert.tsx) with the option to override the default message via children.
  • Implement the Alert in Grading, Schedule and Details, and Course Updates pages.
  • Course Editors do not have permissions over the Course Schedule but can edit the rest of the page. We use the same Alert with a section-scoped message. The two alerts never stack: the section-scoped alert shows only when the user can edit details but not schedule; when they can edit neither, the page-level alert stands in for it.
  • Disable Invite Students button for Course Auditors (view only permissions).
  • Add a banner prop to the shared SubHeader component. In this way we are able to locate the Alert right behind the main title in Grading (and in a future PR in Advanced Settings).
  • Hide, rather than disable, the actionable controls a read-only user cannot use (New assignment type and Delete in Grading, the first-update button in Course Updates).

Supporting information

Testing instructions

  1. Enable the authz.enable_course_authoring waffle flag.
  2. Grand course_auditor to a user by the API <lms_url>/api-docs/#/authz/authz_v1_roles_users_update
  3. As a user with view-only (Course Auditor) access to a course, visit:
  • Grading — expect the lock alert under the page header; New assignment type and per-assignment Delete buttons are absent, all inputs disabled.
  • Course Updates — expect the alert under the header; the add-update button is absent.
  • Schedule & Details — expect a single page-level alert; no save button appears. Invite button disabled.
  1. Grand course_editor to a user by the API <lms_url>/api-docs/#/authz/authz_v1_roles_users_update
  2. As a Course Editor (can edit details, not schedule), visit Schedule & Details — expect the section-scoped alert inside the Schedule section only, with the rest of the page still editable, and no page-level alert.
  3. As a user with full edit permissions (Course Admin/ Course Staff), confirm no alert renders anywhere and all controls behave as before.

Grading Page

image

Schedule and Details

Course Auditor

image

Course Editor

image

Course Updates

image

Best Practices Checklist

We're trying to move away from some deprecated patterns in this codebase. Please
check if your PR meets these recommendations before asking for a review:

  • Any new files are using TypeScript (.ts, .tsx).
  • Avoid propTypes and defaultProps in any new or modified code.
  • Tests should use the helpers in src/testUtils.tsx (specifically initializeMocks)
  • Do not add new fields to the Redux state/store. Use React Context to share state among multiple components.
  • Use React Query to load data from REST APIs. See any apiHooks.ts in this repo for examples.
  • All new i18n messages in messages.ts files have a description for translators to use.
  • Avoid using ../ in import paths. To import from parent folders, use @src, e.g. import { initializeMocks } from '@src/testUtils'; instead of from '../../../../testUtils'

@openedx-webhooks

openedx-webhooks commented Aug 10, 2026

Copy link
Copy Markdown

Thanks for the pull request, @dcoa!

This repository is currently maintained by @bradenmacdonald.

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.

@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 Aug 10, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Aug 10, 2026
@codecov

codecov Bot commented Aug 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.89%. Comparing base (67cee5c) to head (f28415e).
⚠️ Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3193   +/-   ##
=======================================
  Coverage   95.88%   95.89%           
=======================================
  Files        1397     1397           
  Lines       33554    33583   +29     
  Branches     7893     7913   +20     
=======================================
+ Hits        32172    32203   +31     
+ Misses       1323     1321    -2     
  Partials       59       59           

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

@dcoa dcoa added the create-sandbox open-craft-grove should create a sandbox environment from this PR label Aug 10, 2026
@dcoa
dcoa force-pushed the bc/change-course-update-view branch from db1148d to bf3502f Compare August 10, 2026 06:17
@dcoa
dcoa marked this pull request as ready for review August 10, 2026 06:52
@dcoa
dcoa requested review from a team, bradenmacdonald and mariajgrimaldi and removed request for a team August 10, 2026 06:52
@dcoa
dcoa force-pushed the bc/change-course-update-view branch from f652937 to 8051d8f Compare August 10, 2026 07:21
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Aug 11, 2026
@dcoa
dcoa force-pushed the bc/change-course-update-view branch from 8051d8f to 1637fae Compare August 12, 2026 00:42

@BryanttV BryanttV 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.

LGTM! I tested this on my local, and all 3 modified pages work as expected using users with the Course Editor and Course Auditor roles.

@dcoa, could we complete the coverage?

@bradenmacdonald

Copy link
Copy Markdown
Contributor
  • Grant course_auditor to a user by the API <lms_url>/api-docs/#/authz/authz_v1_roles_users_update

I'm trying to test this PR. Can you please give a detailed example of how to do that? BTW I also encountered a bug with the API docs and had to fix it before I could access that page.

Why can't I use http://apps.local.openedx.io:2025/admin-console/authz/assign-role to assign "Course Auditor"? It shows the role there, but it's disabled.

@dcoa

dcoa commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

@bradenmacdonald Sorry for the inconvenience with the test instructions, in terms of how to assign a role, you can use the follow as an example of body request ( you can also access the API endpoint directly using http://local.openedx.io:8000/api/authz/v1/roles/users/) :

{
  "role": "course_auditor", // other supported roles are course_editor, course_staff, course_admin
  "scope": "course-v1:testing+CT01+CT01-2024", // course_id
  "users": [
    "dcoa" // username or email, comma-separated
  ]
}

Then you should receive a 200 response with a message confirming that the assignment was successful.

Why can't I use http://apps.local.openedx.io:2025/admin-console/authz/assign-role to assign "Course Auditor"? It shows the role there, but it's disabled.

The roles were not enabled in the Admin Console because they were not yet available/fully supported in Verawood release. The decision was to first implement them in the Authoring UI and ensure that permission validation was working correctly. Once that validation was guaranteed, the roles could be safely enabled in the Admin Console. (as is visible in the issue logs openedx/openedx-authz#285)

If you like to use the UI I just have a draft PR for it, the change is very simple openedx/frontend-app-admin-console#209

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). create-sandbox open-craft-grove should create a sandbox environment from this PR open-source-contribution PR author is not from Axim or 2U

Projects

Status: Ready for Review

Development

Successfully merging this pull request may close these issues.

Task - implement grading permissions Task - implement schedule and details granular permissions Task - Course updates and handouts

6 participants