Skip to content

feat(authz): implement permission validation in library update page - #3202

Draft
dcoa wants to merge 5 commits into
openedx:masterfrom
eduNEXT:dcoa/libraries-view
Draft

feat(authz): implement permission validation in library update page#3202
dcoa wants to merge 5 commits into
openedx:masterfrom
eduNEXT:dcoa/libraries-view

Conversation

@dcoa

@dcoa dcoa commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Description

This PR continues the authz implementation by adding validations in Library Updates page, where Course Auditor should have read only permissions. Mainwhile other roles (Editor, Staff and Admin) has full manage access.

Supporting information

It closes openedx/openedx-authz#319
Design link

Changes

Navigation

  • src/header/hooks.tsx — the "Libraries" content-menu entry is gated on canViewLibraryUpdates instead of canManageLibraryUpdates.

Libraries page (src/course-libraries/)

  • CourseLibraries.tsxPermissionDeniedAlert is now driven by canViewLibraryUpdates;
    the "Review Updates" header action only renders with canManageLibraryUpdates, and
    readOnly is threaded down to ReviewTabContent and OutOfSyncAlert.
  • OutOfSyncAlert.tsx — new readOnly prop that swaps the alert title for a wording that
    doesn't promise an action the user can't take ("Review updates to see what changed" instead
    of "…to accept or ignore changes"). The Review button stays, since reviewing is read-only.
  • ReviewTabContent.tsx — per-item actions were extracted into a renderActions callback;
    under readOnly only "Review" is rendered, while "Ignore" and "Update" are omitted.

Course outline (src/course-outline/page-alerts/PageAlerts.jsx)

  • Fetches the library-updates permissions and passes readOnly to OutOfSyncAlert. The alert
    is withheld while permissions are loading so it never flashes the read-only wording before
    settling on the manage wording.

Preview changes modal (src/course-unit/preview-changes/index.tsx)

  • Derives the course key from the downstream block id and checks
    canManageLibraryUpdates. For read-only users the accept/ignore (and the
    update/keep variants for text blocks with local changes) buttons are disabled and wrapped
    in an OverlayTrigger popover explaining why. The two button variants were hoisted into
    acceptButton / ignoreButton locals so the enabled and read-only footers share them.

Testing instructions

  1. Enable the enable_authz_course_authoring waffle flag.
  2. Assign a user the Course Auditor role, and log in as that user:
  3. Open the course outline and verify:
    • The top alert does not mention accept/reject changes.
    • The user can open the review modal but the actions accept/ignore changes are disabled.
    • When hover over the actions a popover explains the user can not execute the actions.
  4. Navigate to Library Updates and verify
    • The user see a read only alert
    • Both tabs are still enabled.
    • The user can review but not perform any action over the library changes.
    • The user can open the review modal but the actions accept/ignore changes are disabled.
  5. Course Staff, Admin and Editor should be able to perform actions.

Course outline - Course Auditor
image

Library Updates - Course Auditor

image

Out of sync Alert - Enabled roles

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

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.

🔘 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 Aug 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.93%. Comparing base (16e19f1) to head (dcb7089).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3202      +/-   ##
==========================================
+ Coverage   95.92%   95.93%   +0.01%     
==========================================
  Files        1397     1397              
  Lines       33581    33619      +38     
  Branches     7947     7955       +8     
==========================================
+ Hits        32214    32254      +40     
+ Misses       1308     1307       -1     
+ Partials       59       58       -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.

@dcoa
dcoa force-pushed the dcoa/libraries-view branch 4 times, most recently from 3ddbedb to 763a073 Compare August 25, 2026 05:13
@dcoa
dcoa force-pushed the dcoa/libraries-view branch from 763a073 to 1011aab Compare August 25, 2026 05:56
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Aug 26, 2026
BryanttV added a commit to eduNEXT/frontend-app-authoring that referenced this pull request Aug 27, 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: Waiting on Author

Development

Successfully merging this pull request may close these issues.

Task - implement library updates

3 participants