feat(metadata-editor): wire new MetadataTaxonomyPicker into redesigned sidebar#4683
feat(metadata-editor): wire new MetadataTaxonomyPicker into redesigned sidebar#4683AnnaStepchenko wants to merge 2 commits into
Conversation
WalkthroughAdds a taxonomy items service factory ( ChangesMetadata Taxonomy Picker Service
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant MetadataSidebarRedesign
participant MetadataInstanceEditor
participant createTaxonomyItemsService
participant getMetadataOptions
MetadataSidebarRedesign->>MetadataSidebarRedesign: resolveTaxonomyFieldConfig(template)
MetadataSidebarRedesign->>createTaxonomyItemsService: build service (memoized)
MetadataSidebarRedesign->>MetadataInstanceEditor: pass isMetadataTaxonomyPickerEnabled, createTaxonomyItemsService
MetadataInstanceEditor->>createTaxonomyItemsService: getNodes(level, ancestorId) / searchNodes(query)
createTaxonomyItemsService->>getMetadataOptions: fetch options with level/ancestorId/marker
getMetadataOptions-->>createTaxonomyItemsService: entries, marker, total_result_count
createTaxonomyItemsService-->>MetadataInstanceEditor: TaxonomyNode[] / TaxonomySearchResult[]
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/elements/content-sidebar/__tests__/metadataTaxonomyFetcher.test.ts (1)
623-630: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert the positional
levelarg here to fully cover the "safe default" contract.This test verifies
optionshas nolevel, but does not assert the positionallevelargument (mock.calls[0][4]). GivengetNodesalways passes a computedchildLevelpositionally (seemetadataTaxonomyFetcher.ts), the unrestricted-browse guarantee isn't actually exercised. Adding an assertion onmock.calls[0][4]would catch the divergence fromsearchNodes.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/elements/content-sidebar/__tests__/metadataTaxonomyFetcher.test.ts` around lines 623 - 630, The safe-default test only checks the options object and misses the positional level argument passed by createTaxonomyItemsService/getNodes. Update the test in metadataTaxonomyFetcher.test.ts to also assert the fifth mock call argument (mock.calls[0][4]) for the expected unrestricted-browse childLevel behavior, so it covers the same contract that getNodes and searchNodes rely on.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/elements/content-sidebar/__tests__/metadataTaxonomyFetcher.test.ts`:
- Around line 623-630: The safe-default test only checks the options object and
misses the positional level argument passed by
createTaxonomyItemsService/getNodes. Update the test in
metadataTaxonomyFetcher.test.ts to also assert the fifth mock call argument
(mock.calls[0][4]) for the expected unrestricted-browse childLevel behavior, so
it covers the same contract that getNodes and searchNodes rely on.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5f2f1982-179b-40c7-b4a6-5912790a1336
📒 Files selected for processing (5)
src/elements/content-sidebar/MetadataInstanceEditor.tsxsrc/elements/content-sidebar/MetadataSidebarRedesign.tsxsrc/elements/content-sidebar/__tests__/metadataTaxonomyFetcher.test.tssrc/elements/content-sidebar/fetchers/metadataTaxonomyFetcher.tssrc/elements/content-sidebar/stories/tests/MetadataSidebarRedesign-visual.stories.tsx
Summary
Wires the new
MetadataTaxonomyPicker(from@box/metadata-taxonomy-picker, consumed via@box/metadata-editor) into the redesigned metadata sidebar behind a newmetadata.taxonomyPicker.enabledfeature flag. When the flag is off, the sidebar keeps rendering the legacyMultilevelTaxonomyField— no behavior change for existing consumers.What's in this PR
Fetcher —
src/elements/content-sidebar/fetchers/metadataTaxonomyFetcher.tscreateTaxonomyItemsServicefactory that returns per-fieldTaxonomyItemsServices (browse + search) backed by the existing/metadata_templates/.../optionsendpoint.optionsRules.selectableLevels:selectableLevelshas exactly one entry): loads that level directly (level=N, no ancestor) and marks every returned node as a leaf so no drill-down chevron renders.selectableLevels.length > 1): starts at level 1 and drills down on demand, tracking each returned node's level so it can requestparentLevel + 1withancestor=<parentId>.Sidebar wiring
MetadataSidebarRedesign.tsx— reads the newmetadata.taxonomyPicker.enabledflag, resolves the editing template's field config (levels+optionsRules.selectableLevels), memoizes acreateTaxonomyItemsServiceinstance, and threads it intoMetadataInstanceEditor.MetadataInstanceEditor.tsx— accepts the newisMetadataTaxonomyPickerEnabledandcreateTaxonomyItemsServiceprops and forwards them toMetadataInstanceForm(asisTaxonomyPickerEnabledandcreateTaxonomyItemsService).Summary by CodeRabbit
New Features
Bug Fixes
Tests