Skip to content

Adding permission validations from authz for Course Updates#2938

Open
jacobo-dominguez-wgu wants to merge 2 commits into
openedx:masterfrom
WGU-Open-edX:check-course-updates
Open

Adding permission validations from authz for Course Updates#2938
jacobo-dominguez-wgu wants to merge 2 commits into
openedx:masterfrom
WGU-Open-edX:check-course-updates

Conversation

@jacobo-dominguez-wgu
Copy link
Copy Markdown
Contributor

@jacobo-dominguez-wgu jacobo-dominguez-wgu commented Mar 11, 2026

Description

This pr add the permission validations for the Course Updates section on the Content menu from the header.
First this validates the enableAuthzCourseAuthoring waffle flag and if it is enabled it checks the permissions from authz over the course updates section.
These are the checks included:

  • Checks for the courses.view_course_updates permission to display or hide the Course Updates option on the header menu.
  • Checks for courses.manage_course_updates to display or hide the "+ New update" button and the edit and remove icon buttons for the available course updates and course handouts.

Resolves #2932

Supporting information

Depends on backend ticket openedx/openedx-authz#191

Testing instructions

Prerequisites

  • Access to a course in Studio
  • Ability to toggle the enableAuthzCourseAuthoring waffle flag
  • Access to the authz service to configure user permissions

Test Scenarios

1. Authz Disabled (Legacy Behavior)

Setup: Ensure enableAuthzCourseAuthoring waffle flag is disabled

Step Expected Result
Navigate to Course Updates page Page loads normally
Verify "New update" button Button is visible and enabled
Verify edit/delete buttons on existing updates All edit and delete buttons are visible
Verify handouts edit button Edit button is visible

2. Authz Enabled — User Has Full Permissions

Setup:

  • Enable enableAuthzCourseAuthoring waffle flag
  • Grant user both courses.view_course_updates and courses.manage_course_updates permissions
Step Expected Result
Navigate to Course Updates page Page loads normally
Verify "New update" button Button is visible and enabled
Verify edit/delete buttons on existing updates All edit and delete buttons are visible
Create a new update Update is created successfully
Edit an existing update Update is saved successfully
Delete an update Update is deleted successfully
Edit handouts Handouts are saved successfully

3. Authz Enabled — User Has View-Only Permissions

Setup:

  • Enable enableAuthzCourseAuthoring waffle flag
  • Grant user only courses.view_course_updates permission (no manage permission)
Step Expected Result
Navigate to Course Updates page Page loads normally, content is visible
Verify "New update" button Button is NOT visible
Verify edit buttons on existing updates Edit buttons are NOT visible
Verify delete buttons on existing updates Delete buttons are NOT visible
Verify handouts edit button Edit button is NOT visible
Verify updates content All existing updates and handouts content is readable

4. Authz Enabled — User Has No Permissions

Setup:

  • Enable enableAuthzCourseAuthoring waffle flag
  • Remove both courses.view_course_updates and courses.manage_course_updates permissions
Step Expected Result
Navigate to Course Updates page "Permission Denied" alert is displayed
Verify page content Course updates content is NOT visible
Verify "New update" button Button is NOT visible

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 Mar 11, 2026
@openedx-webhooks
Copy link
Copy Markdown

openedx-webhooks commented Mar 11, 2026

Thanks for the pull request, @jacobo-dominguez-wgu!

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.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Mar 11, 2026
@jacobo-dominguez-wgu jacobo-dominguez-wgu changed the title Adding permission validations from authz for course updates Adding permission validations from authz for Course Updates Mar 11, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.57%. Comparing base (36d42b0) to head (40add9e).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2938      +/-   ##
==========================================
+ Coverage   95.55%   95.57%   +0.02%     
==========================================
  Files        1393     1393              
  Lines       32992    33023      +31     
  Branches     7644     7659      +15     
==========================================
+ Hits        31524    31561      +37     
+ Misses       1413     1408       -5     
+ Partials       55       54       -1     

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

@mphilbrick211 mphilbrick211 added the mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). label Mar 11, 2026
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Mar 11, 2026
@MaferMazu
Copy link
Copy Markdown
Contributor

@jacobo-dominguez-wgu Is this ready for review?
The backend PR is already merged.

@jacobo-dominguez-wgu
Copy link
Copy Markdown
Contributor Author

@jacobo-dominguez-wgu Is this ready for review? The backend PR is already merged.

Yes, I will address the conflicts and mark it as ready.

@jacobo-dominguez-wgu jacobo-dominguez-wgu force-pushed the check-course-updates branch 3 times, most recently from dec3abf to 879f895 Compare May 11, 2026 22:28
@jacobo-dominguez-wgu jacobo-dominguez-wgu marked this pull request as ready for review May 11, 2026 22:41
@MaferMazu MaferMazu requested a review from bra-i-am May 14, 2026 15:45
Copy link
Copy Markdown
Contributor

@MaferMazu MaferMazu left a comment

Choose a reason for hiding this comment

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

@jacobo-dominguez-wgu thanks for this PR.
It works ✨
But I had a comment: when the user hasn't managed_course_updates, it doesn't show the options, but before that, it loads all the views.
I think it is easier if you see it:

Screencast.from.2026-05-14.12-52-25.webm

Also, I asked Gemini about major issues, and it told me the following:

  1. Hook Logic Error
    File: src/authz/hooks.ts

Lines: ~113-120 (within useUserPermissionsWithAuthzCourse)

Feedback:

"If isAuthzEnabled is false, isLoadingUserPermissions might remain true (or undefined), blocking the else if block. This will trigger a false PermissionDenied for all users when the waffle flag is disabled. Please move the true fallback logic outside of the loading check if authorization is disabled."

  1. Missing Loading State (UX)
    File: src/course-updates/CourseUpdates.tsx

Line: ~66 (before the first if)

Feedback:

"The isLoading state returned by the hook is not being validated. Currently, while the permissions API is fetching, the variables will be undefined, causing the component to briefly render the PermissionDeniedAlert before the actual content appears (flicker). Please add a loading guard here."

Being honest, I don't know much about this, or if any of these issues may be causing the weird loading in the interface. So please, feel free to judge this feedback.

@jacobo-dominguez-wgu jacobo-dominguez-wgu force-pushed the check-course-updates branch 3 times, most recently from e251a87 to 16ed82c Compare May 15, 2026 21:49
Copy link
Copy Markdown
Contributor

@bra-i-am bra-i-am left a comment

Choose a reason for hiding this comment

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

When the permissions validation is loading, the UI flashes the buttons, I can click them, and just when the permissions request finishes, the buttons are hidden:

Screencast.from.15-05-26.16.49.04.webm

I'd say it would be better if, while the permissions validation is loading, those buttons are hidden... or what do you opine?

Copy link
Copy Markdown
Contributor

@bra-i-am bra-i-am left a comment

Choose a reason for hiding this comment

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

Perfect! Thanks for addressing my comments ✨

@jacobo-dominguez-wgu
Copy link
Copy Markdown
Contributor Author

jacobo-dominguez-wgu commented May 15, 2026

flashes the buttons, I can click them, and just when the

Grabacion.de.pantalla.2026-05-15.a.la.s.4.27.58.p.m.mov

I have added a loading spinner to show while the permissions are loading so we do not display an incorrect UI.
Thanks for catching this!

…rPermissions

Remove the deprecated useUserPermissionsWithAuthzCourse hook and migrate all consumers to use useCourseUserPermissions, which provides a flatter API by spreading permission booleans directly into the return object.
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). mao-onboarding Reviewing this will help onboard devs from an Axim mission-aligned organization (MAO). 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 - RBAC Authz - Implement frontend check for Course Updates pages

5 participants