feat: implement grading permissions and authorization hooks#2988
feat: implement grading permissions and authorization hooks#2988bra-i-am wants to merge 5 commits intoopenedx:masterfrom
Conversation
|
Thanks for the pull request, @bra-i-am! 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❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2988 +/- ##
========================================
Coverage 95.57% 95.57%
========================================
Files 1366 1368 +2
Lines 31507 31541 +34
Branches 7119 6903 -216
========================================
+ Hits 30113 30146 +33
- Misses 1344 1345 +1
Partials 50 50 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
f36766a to
72cb564
Compare
cbce6d4 to
ad49a12
Compare
Description
This PR implements AuthZ permission checks for the Settings → Grading page in Studio, enabling role-based UI control based on the
courses.view_grading_settingsandcourses.edit_grading_settingspermissions fromopenedx-authz.What changed
New shared authz utilities
src/authz/hooks.ts— NewuseUserPermissionsWithAuthzCourse(courseId, permissions)hook that abstracts the common pattern of checking theenableAuthzCourseAuthoringwaffle flag, fetching permissions when enabled, and defaulting all permissions totruewhen disabled.src/authz/permissionHelpers.ts— NewgetGradingPermissions(courseId)andgetFilesPermissions(courseId)helpers that return structured permission query objects.src/authz/constants.ts— AddedVIEW_GRADING_SETTINGSandEDIT_GRADING_SETTINGStoCOURSE_PERMISSIONS.Grading Settings page (
GradingSettings.jsx):courses.view_grading_settings→ renders<PermissionDeniedAlert />(full page block).courses.edit_grading_settings→ all edit controls are disabled (read-only view).isEditableprop propagated to all child components:GradingScale,GradingScaleSegment,GradingScaleHandle,AssignmentSection,AssignmentItem,AssignmentTypeName,DeadlineSection,CreditSection.Supporting information
openedx_authz.constants.permissions.COURSES_VIEW_GRADING_SETTINGS/COURSES_EDIT_GRADING_SETTINGSauthz.enable_course_authoring(CourseWaffleFlag, defaultfalse)Testing instructions
Prerequisites:
authz.enable_course_authoringset to Everyone.Test view permission denied:
Test view-only (read-only UI):
course_auditorrole to a user for the course viaPUT /api/authz/v1/roles/users/withscope=course-v1:Org%2BCourse%2BRun.Test full edit access:
course_editorrole to a user.Other information
GET /api/contentstore/v1/course_settings/*). That PR must be merged before this frontend change.useUserPermissionsWithAuthzCoursehook introduced here should be reused for future authz integrations across other Settings pages, following the pattern established in PR Adding permission validations from authz for files page #2941.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 — existing JSX child components were modified and retain their existing patterns. Full migration to TypeScript is out of scope for this PR.src/testUtils.tsx(specificallyinitializeMocks) — to be added in a follow-up.apiHooks.tsin this repo for examples.messages.tsfiles have adescriptionfor translators to use.../in import paths. To import from parent folders, use@src.