feat: adding permissions checks related to course section and units - #3200
feat: adding permissions checks related to course section and units#3200jacobo-dominguez-wgu wants to merge 1 commit into
Conversation
|
Thanks for the pull request, @jacobo-dominguez-wgu! This repository is currently maintained by 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 approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo 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:
🔘 Get a green buildIf 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 PRYour 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:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3200 +/- ##
==========================================
+ Coverage 95.88% 95.92% +0.04%
==========================================
Files 1397 1397
Lines 33554 33597 +43
Branches 7893 7666 -227
==========================================
+ Hits 32172 32228 +56
- Misses 1323 1325 +2
+ Partials 59 44 -15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I have tested all the scenarios and it works as expected. |
|
Please ping me to review once the other PR(s) is merged and this is ready :) |
Description
Continuation of #3196. That PR added permission checks to the course outline home page; this one extends the same authorization model to the course section and unit (internal) pages.
It conditionally renders, hides, or disables the editable and publishable elements on the section/unit pages so that users only interact with the actions their role permits, applying "read-only" states or removing modification/publish actions as defined by the design.
Concretely, on the unit and section pages the following are now gated:
edit_course_content — when the user lacks this permission, content-editing affordances become read-only or hidden, including:
publish_course_content — when the user lacks this permission, the Publish action in the unit sidebar footer is hidden.
Permissions are resolved through the shared CourseAuthoringProvider (useCourseAuthoringContext), which now exposes canEditCourseContent and canPublishCourseContent via useCourseUserPermissions, consistent with #3196.
AI usage notice: used Claude Opus 4.8 through kiro to assist on the modification and creation of unit tests.
Permission Matrix
courses.view_coursecourses.create_coursecourses.publish_course_contentcourses.edit_course_contentImportant
The publish and content edition options specific to the xblocks will be handled in a different pr.

Impacted user roles: Course Author / Course Editor and Course Auditor (and any role mapped to the permissions above).
Supporting information
Continuation of #3196 (course outline home page).
Partially closes openedx/openedx-authz#383.
Needs openedx/openedx-authz#384
Figma: «link»
Note: permissions related to Tags are handled in a separate ticket (openedx/openedx-authz#314).
Testing instructions
Depends on openedx/openedx-authz#384.
Requirements
Enable the
authz.enable_course_authoringwaffle flag.You can set course_auditor or course_editor role to a user using the API
<lms_url>/api-docs/#/authz/authz_v1_roles_users_updatePayload example:
Test case 1 — course_auditor
These elements must not be visible:

These elements must be visible but disabled (read-only, not clickable)

Test case 2 — course_editor
Test case 3 — other roles (staff, superuser, course_admin, course_staff)
Also verify that with the authz.enable_course_authoring flag disabled, everything behaves exactly as before (all permissions fall back to granted).
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:
.ts,.tsx).propTypesanddefaultPropsin any new or modified code.src/testUtils.tsx(specificallyinitializeMocks)apiHooks.tsin this repo for examples.messages.tsfiles have adescriptionfor translators to use.../in import paths. To import from parent folders, use@src, e.g.import { initializeMocks } from '@src/testUtils';instead offrom '../../../../testUtils'Warning
Will be in draft status until the 403 problem is fixed openedx/openedx-authz#384