feat(authz): add permission validation for advanced settings and certificate pages - #3206
feat(authz): add permission validation for advanced settings and certificate pages#3206dcoa wants to merge 5 commits into
Conversation
|
Thanks for the pull request, @dcoa! 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 #3206 +/- ##
=======================================
Coverage 95.92% 95.93%
=======================================
Files 1397 1397
Lines 33581 33600 +19
Branches 7947 7946 -1
=======================================
+ Hits 32214 32233 +19
Misses 1308 1308
Partials 59 59 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
7499a56 to
5532876
Compare
5532876 to
5dc0f32
Compare
Description
This PR is the continuation of the effort to implement the new Authz system into Course Authoring. The PR is focused on hiding actions according to user permissions.
Specifically, it splits the Advanced Settings and Certificates pages into a view level and a manage level:
courses.view_advanced_settingsandcourses.view_certificatespermissions tosrc/authz/constants.ts, and exposes them throughgetAdvancedSettingsPermissions()/getCertificatesPermissions().HelpSidebar, and the course outlineCourseInfoSidebar) now gate the Advanced Settings and Certificates links on theview_*permission instead ofmanage_*, so users with read-only access can still reach the pages.canViewAdvancedSettings(PermissionDeniedAlertotherwise). Withoutmanage_advanced_settingsthe page renders aViewOnlyPermissionsAlertbanner and everySettingCardfield isdisabled.CertificatesProvider(src/certificates/context.tsx) so they're resolved once and consumed anywhere in the tree. Page access is gated bycanViewCertificates; withoutmanage_certificatesthe page shows theViewOnlyPermissionsAlertbanner and hides the write actions: the Activate/Deactivate button, the Set up certificate button on the empty state, the edit/delete actions on the certificate details card, and the edit action on each signatory. The Preview button stays available to read-only users.Important
Depends on openedx/openedx-platform#39008 and openedx/openedx-platform#39007
Impacted user roles: Course Auditor / Course Editor — i.e. anyone whose role grants
view_advanced_settingsorview_certificateswithout the matchingmanage_*. Users with themanage_*permissions ( Course Staff / Course Admin) are unaffected. This only takes effect when theenable_authz_course_authoringwaffle flag is on; with the flag off, the legacy behavior is preserved.It closes openedx/openedx-authz#316
Testing instructions
enable_authz_course_authoringwaffle flag.courses.view_advanced_settingsandcourses.view_certificatesbut not the correspondingmanage_*permissions, and log in as that user.course_auditoras roleENABLE_CERTIFICATE_PAGE=true) and verify:manage_advanced_settings/manage_certificatesand repeat steps 5–6: no "view only" alert, all fields editable, and every action button present and working as before.Advanced Settings
** Certificates**
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'