feat(authz): add tag management permissions within course scope - #3224
feat(authz): add tag management permissions within course scope#3224dcoa wants to merge 6 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. 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. |
71db3e1 to
a36bb28
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3224 +/- ##
==========================================
+ Coverage 95.93% 95.95% +0.02%
==========================================
Files 1397 1397
Lines 33603 33683 +80
Branches 7687 7975 +288
==========================================
+ Hits 32237 32321 +84
+ Misses 1323 1319 -4
Partials 43 43 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| @@ -0,0 +1,77 @@ | |||
| import { fireEvent, initializeMocks, render, screen } from '@src/testUtils'; | |||
There was a problem hiding this comment.
Lets use userEvent instead of fireEvent for new tests
|
|
||
| beforeEach(() => { | ||
| initializeMocks(); | ||
| jest.mocked(useCourseUserPermissions).mockReturnValue({ |
There was a problem hiding this comment.
There are some testing utils that can be used to mock the permissions:
frontend-app-authoring/src/testUtils.tsx
Line 211 in 0c864d9
So you could do something like:
const mocks = initializeMocks();
validateUserPermissionsMock = mocks.validateUserPermissionsMock;
validateUserPermissionsMock.mockResolvedValue({
isLoading: false,
canManageTags: true,
isAuthzEnabled: false,
});There was a problem hiding this comment.
thank you for point this out, done!!
0f12284 to
6344ff5
Compare
|
Hi @dcoa, thanks! I was testing these changes and noticed that when I click 'Align', even though the tags are listed correctly, a message still pops up saying that taxonomies must be enabled (even when they already are). I'm seeing this happen with both the Course Auditor and Course Editor roles.
|
Yep @BryanttV , I mentioning and reporting the reason of this here openedx/openedx-authz#286. But in summary this is one of those cases when limits between one permission and the other gets diffuse, in this case tags and taxonomies (that is out of the scope for know because has not been implemented at the backend side). The reason why that message is displayed is because we are getting the tags but not the taxonomies. |


Description
Part of the integration of RBAC permission system to course authoring workflow. Adds the
courses.manage_tagspermission check to every place in Studio where a Course Roles can view or edit taxonomy tags on course content.Implemented changes
CardHeader.tsx): the tag-count badge and the "Manage tags" dropdown item arehidden when the user cannot manage tags.
OutlineAlignSidebar.tsx) and Unit align sidebar(
UnitAlignSidebar.tsx): passreadOnly={!canManageTags}down toAlignSidebar, which forwards it toContentTagsDrawer.AlignSidebargains an optionalreadOnlyprop (defaultfalse), so existing callers are unaffected.CourseInfoSidebar.tsx): the "Taxonomy Alignments" section renders noactions menu at all when the user cannot manage tags, instead of showing a "Manage tags" action
they cannot use.
Testing instructions
enable_authz_course_authoringwaffle flag.course_auditoras rolemanage_tags(Editor, Admin o Staff) and repeat steps 3: the manage tag button should be displayed and the user can add/remove tags.Other information
Design link
Closes openedx/openedx-authz#314
The refinement identify some UI bugs
Bug A —
canTagObjecthardcoded to false for otherTaxonomies (ContentTagsDrawerHelper.jsx). Thecan_tag_objectfield fromobject_tagswas available but unused.Bug B — The merge
useEffectinContentTagsDrawerHelper.jsxonly merged staged tags intofetchedTaxonomiesentries. When a taxonomy was in otherTaxonomies (taxonomy list empty), staged tags were discarded and never reached appliedContentTagsTree → "Add" appeared to work but nothing appeared on screen.Bug C — The tag selector
<Select>inContentTagsCollapsible.jsxwas gated only onisEditMode, not oncanTagObject. This showed an interactive selector for taxonomies where the user has no permission.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'