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 2 commits 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. DetailsWhere 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.93% 95.94% +0.01%
==========================================
Files 1397 1397
Lines 33603 33657 +54
Branches 7687 7710 +23
==========================================
+ Hits 32237 32293 +56
+ Misses 1323 1321 -2
Partials 43 43 ☔ 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 :) |
|
Dependency pr is merged openedx/openedx-platform#38986. This one is ready for review @bradenmacdonald |
a422c46 to
5e312c5
Compare
|
I just noticed a small bug from part 1 . I thought was not related to our changes but it actually is. When we hide the actions for the outline unit card, the footer is overflowing, as you can see in the following image
The solution is remove the frontend-app-authoring/src/course-outline/outline-level.ts Lines 79 to 107 in 2c14cef And add the class in className={classNames(levelConfig.contentClass, {
// `item-children` pulls the content 2.75rem to the right so it spans
// under the drag handle column. Without the handle there is no column
// to fill, and the negative margin would overflow the card.
'item-children': isDraggable,
})}Can we implement it as part of the current PR? |
@dcoa Sure, it is implemented. Can you check again? |
| 1: { | ||
| name: 'subsection', | ||
| contentClass: 'subsection-card__content item-children', | ||
| contentClass: 'subsection-card__content', |
There was a problem hiding this comment.
Thank you for removing the class here, could you please do the same in unit (the second object in the array)?
There was a problem hiding this comment.
Thank you I dont have any extra comments
177802b to
31b21c2
Compare
BryanttV
left a comment
There was a problem hiding this comment.
Tested on my local and it works as expected, thanks!
|
@jacobo-dominguez-wgu, sorry, while running some other tests, I noticed that the "Publish Changes" button is still visible to a Course Editor and Course Auditor, here:
Could we fix that?
|


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