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 96.03% 96.05% +0.01%
==========================================
Files 1407 1407
Lines 34287 34346 +59
Branches 7882 7896 +14
==========================================
+ Hits 32928 32991 +63
+ Misses 1318 1314 -4
Partials 41 41 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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 now 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. |
|
Thanks for the explanation, @dcoa. For now, we can handle it this way on the frontend; we're already evaluating a solution on the backend. |
bradenmacdonald
left a comment
There was a problem hiding this comment.
Looks great! Thanks for all the cleanups and typescript conversions. I'm just a little concerned about how many different Tag/Taxonomy types we had, so I asked Claude to help us consolidate it and it gave some good advice:
| export type TagTree = { | ||
| [key: string]: { | ||
| children: TagTree; | ||
| canChangeObjecttag: boolean; | ||
| canDeleteObjecttag: boolean; | ||
| explicit: boolean; | ||
| isCopied: boolean; | ||
| }; | ||
| }; |
There was a problem hiding this comment.
| export type TagTree = { | |
| [key: string]: { | |
| children: TagTree; | |
| canChangeObjecttag: boolean; | |
| canDeleteObjecttag: boolean; | |
| explicit: boolean; | |
| isCopied: boolean; | |
| }; | |
| }; | |
| export type TagTree = Record<string, TagTreeEntry>; |
|
|
||
| /** | ||
| * A tag as shown in the tags drawer. Tags fetched from the server carry more fields | ||
| * (see `Tag`), but tags the user has staged in the drawer are only known by these. | ||
| */ | ||
| export interface DrawerTag { | ||
| value: string; | ||
| lineage: string[]; | ||
| canDeleteObjecttag: boolean; | ||
| /** Only known for tags fetched from the server; not set on tags staged in the drawer. */ | ||
| canChangeObjecttag?: boolean; | ||
| /** Only known for tags fetched from the server; not set on tags staged in the drawer. */ | ||
| isCopied?: boolean; | ||
| } |
There was a problem hiding this comment.
| /** | |
| * A tag as shown in the tags drawer. Tags fetched from the server carry more fields | |
| * (see `Tag`), but tags the user has staged in the drawer are only known by these. | |
| */ | |
| export interface DrawerTag { | |
| value: string; | |
| lineage: string[]; | |
| canDeleteObjecttag: boolean; | |
| /** Only known for tags fetched from the server; not set on tags staged in the drawer. */ | |
| canChangeObjecttag?: boolean; | |
| /** Only known for tags fetched from the server; not set on tags staged in the drawer. */ | |
| isCopied?: boolean; | |
| } |
This DrawerTag is unnecessary. It exists because getLeafTags in ContentTagsCollapsibleHelper.jsx:53 builds staged tags with only three of the five Tag fields. Adding canChangeObjecttag: true and isCopied: false there makes staged tags real Tag objects, and this can be simplified significantly.
--- a/src/content-tags-drawer/ContentTagsCollapsibleHelper.jsx
+++ b/src/content-tags-drawer/ContentTagsCollapsibleHelper.jsx
@@ -37,7 +37,7 @@ const sortKeysAlphabetically = (tree) => {
* tags selected in the staged tags tree
*
* @param {object} tree - tree to extract the leaf tags from
- * @returns {StagedTagData[]} array of leaf (explicit) tags of provided tree
+ * @returns {ContentTagData[]} array of leaf (explicit) tags of provided tree
*/
const getLeafTags = (tree) => {
const leafTags = [];
@@ -48,9 +48,11 @@ const getLeafTags = (tree) => {
if (Object.keys(child.children).length === 0) {
leafTags.push({
value: key,
- // Always true because this is a new added tag,
- // so the user can delete.
+ // Always true/false because this is a new added tag,
+ // so the user can change/delete it and it is not a copy.
+ canChangeObjecttag: true,
canDeleteObjecttag: true,
+ isCopied: false,
lineage: child.lineage,
});
} else {Or see open-craft@287e74a
Note: DrawerTaxonomy is still useful.
| /** | ||
| * A taxonomy that is applied to the content but is not in the taxonomy list the user | ||
| * can see, so it is rebuilt from the tags applied to the content. | ||
| */ | ||
| export interface OtherTaxonomy extends | ||
| DrawerTaxonomy, | ||
| Pick< | ||
| TaxonomyData, | ||
| 'exportId' | 'enabled' | 'visibleToAuthors' | 'canChangeTaxonomy' | 'canDeleteTaxonomy' | ||
| > | ||
| {} |
There was a problem hiding this comment.
OtherTaxonomy also seems unnecessary. Its extra fields are hardcoded at ContentTagsDrawerHelper.ts:120-128 and nothing ever reads them. Can we drop the hardcoded fields and just use plain DrawerTaxonomy type for the other taxonomies?
e.g. open-craft@287e74a
| @@ -94,12 +103,12 @@ export const useCreateContentTagsDrawerContext = (contentId, canTagObject, fetch | |||
| const taxonomiesList = taxonomyListData.results.map((taxonomy) => ({ | |||
| ...taxonomy, | |||
| canTagObject: taxonomy.canTagObject && canTagObject, | |||
There was a problem hiding this comment.
There is a bug here: this useMemo depends on canTagObject but doesn't declare it as a dependency.
That was harmless before because every caller passed a static
readOnly. NowreadOnly={!canManageTags}comes fromuseCourseUserPermissions, which reports every permission asfalsewhile it loads. If the taxonomy list and content tags are already cached (the tags snippet in the sidebar uses the same queries), the memo runs once withcanTagObject=falseand never recomputes when the permission resolves. The user sees the "Manage tags" button, clicks it, and gets no "Add a tag" selector on any taxonomy.
There was a problem hiding this comment.
TagsInTaxonomy is now unnecessary. Its only remaining use is the sort helper's parameter, which can become a generic constrained to DrawerTaxonomy.
6a3a430 to
e61044a
Compare
|
Thank you @bradenmacdonald, I addressed the types comments |


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'