feat(metadata-editor): Add externally shared property to template instance#4450
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughUpdates dependency versions and extends metadata APIs to carry an Changes
Sequence DiagramsequenceDiagram
participant Client
participant MetadataAPI
participant TemplateStore
participant HydrationService
Client->>MetadataAPI: getTemplateForInstance(id, instance, templates)
MetadataAPI->>TemplateStore: lookup template in provided templates
alt found locally
TemplateStore-->>MetadataAPI: template (isExternallyOwned: false)
else not found
MetadataAPI->>TemplateStore: fetch cross-enterprise templates
TemplateStore-->>MetadataAPI: template[] (isExternallyOwned: true)
end
MetadataAPI-->>Client: { template, isExternallyOwned }
Client->>MetadataAPI: createTemplateInstance(instance, template, canEdit, isExternallyOwned)
alt isExternallyOwned == false
MetadataAPI->>HydrationService: hydrate taxonomy levels for template
HydrationService-->>MetadataAPI: hydrated template
else isExternallyOwned == true
MetadataAPI-->>MetadataAPI: skip hydration
end
MetadataAPI-->>Client: MetadataTemplateInstance { ..., isExternallyOwned }
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested Reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/api/Metadata.js (1)
462-485: Return shape is always non-null now; nullable?in the return type is stale.
getTemplateForInstancepreviously could returnundefined/null(for the raw template), but now it always returns an object ({ template, isExternallyOwned }). The?prefix in the return type (Line 466) is no longer accurate and could mislead callers into adding unnecessary null-checks on the wrapper object.Also, when
crossEnterpriseTemplatesis empty (Line 480),crossEnterpriseTemplateisundefinedyet gets wrapped as{ template: undefined, isExternallyOwned: true }. Callers handle this fine (they checkif (template)), but theisExternallyOwned: trueon a missing template is semantically odd. Consider returning{ template: undefined, isExternallyOwned: false }in that edge case, or guarding explicitly.♻️ Suggested cleanup
async getTemplateForInstance( id: string, instance: MetadataInstanceV2, templates: Array<MetadataTemplate>, - ): Promise<?{ template: MetadataTemplate, isExternallyOwned: boolean }> { + ): Promise<{ template: ?MetadataTemplate, isExternallyOwned: boolean }> {🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/api/Metadata.js` around lines 462 - 485, Update getTemplateForInstance: remove the nullable marker from the return type since the function always returns an object, and change the cross-enterprise branch to handle an empty crossEnterpriseTemplates result by returning { template: undefined, isExternallyOwned: false } (or guard and only set isExternallyOwned: true when crossEnterpriseTemplate is truthy). Specifically adjust the signature (remove the leading ?), and in the block that sets crossEnterpriseTemplate from crossEnterpriseTemplates[0] only mark isExternallyOwned true when crossEnterpriseTemplate exists; otherwise return isExternallyOwned false.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.vscode/settings.json:
- Around line 10-14: Remove the personal VS Code color customizations from the
shared settings by deleting the "workbench.colorCustomizations" block (including
"activityBar.background", "titleBar.activeBackground", and
"titleBar.activeForeground") from the settings JSON; if these colors are needed
for your local setup, move them into your user or workspace-specific settings
instead so they are not committed to the repository.
---
Nitpick comments:
In `@src/api/Metadata.js`:
- Around line 462-485: Update getTemplateForInstance: remove the nullable marker
from the return type since the function always returns an object, and change the
cross-enterprise branch to handle an empty crossEnterpriseTemplates result by
returning { template: undefined, isExternallyOwned: false } (or guard and only
set isExternallyOwned: true when crossEnterpriseTemplate is truthy).
Specifically adjust the signature (remove the leading ?), and in the block that
sets crossEnterpriseTemplate from crossEnterpriseTemplates[0] only mark
isExternallyOwned true when crossEnterpriseTemplate exists; otherwise return
isExternallyOwned false.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (5)
.vscode/settings.jsonpackage.jsonsrc/api/Metadata.jssrc/api/__tests__/Metadata.test.jssrc/common/types/metadata.js
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
src/api/Metadata.js (3)
454-466:⚠️ Potential issue | 🟡 MinorJSDoc
@returntag is stale after the return-shape changeThe return type annotation in Flow (line 466) is correct, but the prose JSDoc still says
@return {Object|undefined} template for metadata instance— it should describe the new{ template, isExternallyOwned }shape.📝 Suggested doc update
- * `@return` {Object|undefined} template for metadata instance + * `@return` {{ template: MetadataTemplate, isExternallyOwned: boolean }|undefined} resolved template with ownership flag, or undefined if not found🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/api/Metadata.js` around lines 454 - 466, Update the JSDoc for getTemplateForInstance to reflect the new return shape instead of "Object|undefined": change the `@return` description to indicate it returns an object with keys "template" (MetadataTemplate) and "isExternallyOwned" (boolean), or null/undefined when no match is found; ensure the prose matches the Flow return type Promise<?{ template: MetadataTemplate, isExternallyOwned: boolean }> and briefly describe each field.
317-330:⚠️ Potential issue | 🟡 MinorJSDoc missing
@paramfor the newisExternallyOwnedparameterThe existing
@paramblock documents only three parameters; the new 4thisExternallyOwnedparameter is undocumented.📝 Suggested doc update
* `@param` {string} id - file id * `@param` {string} scope - metadata scope * `@param` {string|void} [instanceId] - metadata instance id + * `@param` {boolean} [isExternallyOwned] - whether the template belongs to a different enterprise; skips taxonomy hydration when true * `@return` {Object} array of metadata templates🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/api/Metadata.js` around lines 317 - 330, The JSDoc for getTemplates is missing documentation for the new boolean parameter isExternallyOwned; update the comment block for getTemplates to add a `@param` entry describing isExternallyOwned (type boolean), its purpose (e.g., whether the templates are for externally owned files), and its default value (false), and ensure the `@param` order matches the function signature so tools and readers see accurate parameter docs.
528-540:⚠️ Potential issue | 🟡 MinorJSDoc missing
@paramforisExternallyOwned📝 Suggested doc update
* `@param` {Object} instance - metadata instance * `@param` {Object} template - metadata template * `@param` {boolean} canEdit - can user edit item + * `@param` {boolean} [isExternallyOwned] - whether the template is owned by a different enterprise * `@return` {Object} metadata template instance🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/api/Metadata.js` around lines 528 - 540, The JSDoc for createTemplateInstance is missing a `@param` entry for isExternallyOwned; update the comment block above the createTemplateInstance function to add a line like "@param {boolean} isExternallyOwned - whether the metadata is owned externally (defaults to false)" so the parameter is documented alongside instance, template, and canEdit.
🧹 Nitpick comments (1)
src/api/Metadata.js (1)
518-521: Redundant inner.templatetruthiness check (same pattern at line 614)Per the Flow return type
?{ template: MetadataTemplate, isExternallyOwned: boolean },result.templateis always non-nullable whenresultitself is non-null. Theresult.templateguard is therefore redundant.🧹 Optional simplification (applies to line 614 as well)
- if (result && result.template) { - editors.push(this.createEditor(instance, result.template, canEdit)); + if (result) { + editors.push(this.createEditor(instance, result.template, canEdit));🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/api/Metadata.js` around lines 518 - 521, Remove the redundant truthiness check on result.template: since getTemplateForInstance returns ?{ template: MetadataTemplate, isExternallyOwned: boolean }, once result is truthy its template is non-null, so change the conditional in the block using getTemplateForInstance (the one that builds editors with createEditor) to only check result (e.g., if (result) editors.push(this.createEditor(instance, result.template, canEdit))); apply the same simplification to the other identical occurrence that currently checks result && result.template.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/api/Metadata.js`:
- Around line 454-466: Update the JSDoc for getTemplateForInstance to reflect
the new return shape instead of "Object|undefined": change the `@return`
description to indicate it returns an object with keys "template"
(MetadataTemplate) and "isExternallyOwned" (boolean), or null/undefined when no
match is found; ensure the prose matches the Flow return type Promise<?{
template: MetadataTemplate, isExternallyOwned: boolean }> and briefly describe
each field.
- Around line 317-330: The JSDoc for getTemplates is missing documentation for
the new boolean parameter isExternallyOwned; update the comment block for
getTemplates to add a `@param` entry describing isExternallyOwned (type boolean),
its purpose (e.g., whether the templates are for externally owned files), and
its default value (false), and ensure the `@param` order matches the function
signature so tools and readers see accurate parameter docs.
- Around line 528-540: The JSDoc for createTemplateInstance is missing a `@param`
entry for isExternallyOwned; update the comment block above the
createTemplateInstance function to add a line like "@param {boolean}
isExternallyOwned - whether the metadata is owned externally (defaults to
false)" so the parameter is documented alongside instance, template, and
canEdit.
---
Nitpick comments:
In `@src/api/Metadata.js`:
- Around line 518-521: Remove the redundant truthiness check on result.template:
since getTemplateForInstance returns ?{ template: MetadataTemplate,
isExternallyOwned: boolean }, once result is truthy its template is non-null, so
change the conditional in the block using getTemplateForInstance (the one that
builds editors with createEditor) to only check result (e.g., if (result)
editors.push(this.createEditor(instance, result.template, canEdit))); apply the
same simplification to the other identical occurrence that currently checks
result && result.template.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/api/Metadata.jssrc/api/__tests__/Metadata.test.js
🚧 Files skipped from review as they are similar to previous changes (1)
- src/api/tests/Metadata.test.js
d7c98ef to
ce8ecfd
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/api/__tests__/Metadata.test.js (1)
834-842:⚠️ Potential issue | 🟡 MinorMissing assertion for the new
isExternallyOwnedargument increateTemplateInstancecallsThe test verifies the first two call arguments but omits the third (
canEdit) and fourth (isExternallyOwned). Since propagatingisExternallyOwnedfromgetTemplateForInstanceintocreateTemplateInstanceis the core behavior of this PR, skipping this assertion means a future regression (e.g., dropping the 4th argument) would go undetected.✅ Proposed fix — add assertions for all four arguments
expect(metadata.createTemplateInstance.mock.calls[0][0]).toBe(instances[0]); expect(metadata.createTemplateInstance.mock.calls[0][1]).toBe('template1'); + expect(metadata.createTemplateInstance.mock.calls[0][2]).toBe(true); // canEdit + expect(metadata.createTemplateInstance.mock.calls[0][3]).toBe(false); // isExternallyOwned expect(metadata.createTemplateInstance.mock.calls[1][0]).toBe(instances[1]); expect(metadata.createTemplateInstance.mock.calls[1][1]).toBe('template2'); + expect(metadata.createTemplateInstance.mock.calls[1][2]).toBe(true); + expect(metadata.createTemplateInstance.mock.calls[1][3]).toBe(false); expect(metadata.createTemplateInstance.mock.calls[2][0]).toBe(instances[2]); expect(metadata.createTemplateInstance.mock.calls[2][1]).toBe('template3'); + expect(metadata.createTemplateInstance.mock.calls[2][2]).toBe(true); + expect(metadata.createTemplateInstance.mock.calls[2][3]).toBe(false); expect(metadata.createTemplateInstance.mock.calls[3][0]).toBe(instances[3]); expect(metadata.createTemplateInstance.mock.calls[3][1]).toBe('template4'); + expect(metadata.createTemplateInstance.mock.calls[3][2]).toBe(true); + expect(metadata.createTemplateInstance.mock.calls[3][3]).toBe(false);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/api/__tests__/Metadata.test.js` around lines 834 - 842, The test currently asserts only the first two args of metadata.createTemplateInstance calls but misses the third (canEdit) and fourth (isExternallyOwned); update the assertions for each of the four mock.calls (indices 0–3) to also verify mock.calls[i][2] equals the expected canEdit value and mock.calls[i][3] equals the expected isExternallyOwned value returned by getTemplateForInstance so the test confirms propagation of isExternallyOwned into createTemplateInstance.
🧹 Nitpick comments (2)
src/api/__tests__/Metadata.test.js (2)
388-448: No test verifying thatgetTaxonomyLevelsForTemplatesis skipped whenisExternallyOwned: trueThe new conditional hydration in
getTemplates(theisExternallyOwned ? templates : await this.getTaxonomyLevelsForTemplates(...)branch) is exercised indirectly viagetTemplateForInstance, but has no direct unit test.✅ Proposed additional test
+ test('should skip taxonomy hydration when isExternallyOwned is true', async () => { + const templatesFromServer = [{ id: 1, hidden: false }]; + metadata.getMetadataTemplateUrlForScope = jest.fn().mockReturnValueOnce('template_url'); + metadata.getTaxonomyLevelsForTemplates = jest.fn(); + metadata.xhr.get = jest.fn().mockReturnValueOnce({ data: { entries: templatesFromServer } }); + + const templates = await metadata.getTemplates('id', 'enterprise', undefined, true); + + expect(templates).toEqual(templatesFromServer); + expect(metadata.getTaxonomyLevelsForTemplates).not.toHaveBeenCalled(); + });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/api/__tests__/Metadata.test.js` around lines 388 - 448, Add a unit test for getTemplates that covers the isExternallyOwned branch: stub metadata.getMetadataTemplateUrlForScope (or getMetadataTemplateUrlForInstance as appropriate), mock metadata.xhr.get to return entries with a template object that includes isExternallyOwned: true, and assert that metadata.getTaxonomyLevelsForTemplates is NOT called and the returned templates equal the raw entries (not hydrated). Reference getTemplates and getTaxonomyLevelsForTemplates to locate where to add the test and use metadata.xhr.get and metadata.getMetadataTemplateUrlForScope/getMetadataTemplateUrlForInstance in the setup.
175-274: Missing test coverage forisExternallyOwned: trueincreateTemplateInstanceBoth tests only exercise the default
isExternallyOwned: falsepath. The non-default case (explicitly passingtrue) is untested, leaving the new feature's primary flag uncovered at the unit level.✅ Proposed additional test
+ test('should return Metadata Template Instance with isExternallyOwned: true', () => { + expect( + metadata.createTemplateInstance( + { $id: '321', $template: '', $canEdit: false, testField: 'val' }, + { displayName: 'External', fields: [], id: 'extId', templateKey: 'extTpl', scope: 'enterprise' }, + false, + true, // isExternallyOwned + ), + ).toEqual( + expect.objectContaining({ + isExternallyOwned: true, + canEdit: false, + }), + ); + });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/api/__tests__/Metadata.test.js` around lines 175 - 274, Add a unit test covering the non-default external ownership path for createTemplateInstance: call metadata.createTemplateInstance with the same template and instance inputs but set the parameter that toggles external ownership to true (so the function receives the explicit "externally owned" flag), and assert the returned object includes isExternallyOwned: true in its top-level properties; place the new test alongside the existing createTemplateInstance tests and mirror the existing expectations for fields/displayName/id/scope/templateKey while only changing the isExternallyOwned assertion.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/api/__tests__/Metadata.test.js`:
- Around line 740-744: The mock for getTemplateForInstance incorrectly returns
an object with template: undefined for the "not-found" case; change the final
mockResolvedValueOnce to return undefined (not { template: undefined, ... }) so
it matches the real function contract (getTemplateForInstance returns undefined
when no template is found). Make the same change in the other test suite where
getTemplateInstances is mocked to ensure both mocks return undefined for the
not-found case.
---
Outside diff comments:
In `@src/api/__tests__/Metadata.test.js`:
- Around line 834-842: The test currently asserts only the first two args of
metadata.createTemplateInstance calls but misses the third (canEdit) and fourth
(isExternallyOwned); update the assertions for each of the four mock.calls
(indices 0–3) to also verify mock.calls[i][2] equals the expected canEdit value
and mock.calls[i][3] equals the expected isExternallyOwned value returned by
getTemplateForInstance so the test confirms propagation of isExternallyOwned
into createTemplateInstance.
---
Nitpick comments:
In `@src/api/__tests__/Metadata.test.js`:
- Around line 388-448: Add a unit test for getTemplates that covers the
isExternallyOwned branch: stub metadata.getMetadataTemplateUrlForScope (or
getMetadataTemplateUrlForInstance as appropriate), mock metadata.xhr.get to
return entries with a template object that includes isExternallyOwned: true, and
assert that metadata.getTaxonomyLevelsForTemplates is NOT called and the
returned templates equal the raw entries (not hydrated). Reference getTemplates
and getTaxonomyLevelsForTemplates to locate where to add the test and use
metadata.xhr.get and
metadata.getMetadataTemplateUrlForScope/getMetadataTemplateUrlForInstance in the
setup.
- Around line 175-274: Add a unit test covering the non-default external
ownership path for createTemplateInstance: call metadata.createTemplateInstance
with the same template and instance inputs but set the parameter that toggles
external ownership to true (so the function receives the explicit "externally
owned" flag), and assert the returned object includes isExternallyOwned: true in
its top-level properties; place the new test alongside the existing
createTemplateInstance tests and mirror the existing expectations for
fields/displayName/id/scope/templateKey while only changing the
isExternallyOwned assertion.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
yarn.lockis excluded by!**/yarn.lock,!**/*.lock
📒 Files selected for processing (4)
package.jsonsrc/api/Metadata.jssrc/api/__tests__/Metadata.test.jssrc/common/types/metadata.js
🚧 Files skipped from review as they are similar to previous changes (2)
- package.json
- src/common/types/metadata.js
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
src/api/Metadata.js (2)
540-582: Consider overridingcanEdittofalsewhenisExternallyOwnedistrue.The current logic allows a returned instance to have
{ canEdit: true, isExternallyOwned: true }simultaneously. Every downstream consumer must then check both flags to determine editability. ForcingcanEdit: falsehere removes the ambiguity and provides defence-in-depth.♻️ Suggested change
return { isExternallyOwned, - canEdit: instance.$canEdit && canEdit, + canEdit: !isExternallyOwned && instance.$canEdit && canEdit, displayName: template.displayName,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/api/Metadata.js` around lines 540 - 582, The returned object can currently have canEdit true while isExternallyOwned is true; modify the return construction so that canEdit is forced to false when the isExternallyOwned parameter is true (e.g., set canEdit: isExternallyOwned ? false : (instance.$canEdit && canEdit)) so downstream code need only check canEdit; update the return object in the function that builds the MetadataTemplateInstance (the block that currently returns { isExternallyOwned, canEdit: instance.$canEdit && canEdit, ... }) to implement this override.
614-618:isExternallyOwnedpropagation is correct.
result.isExternallyOwnedis cleanly threaded intocreateTemplateInstance. Same minor redundancy as ingetEditors:result.templatecheck insideif (result)is unnecessary sincetemplateis non-optional in the return type (mirror of the `` comment above).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/api/Metadata.js` around lines 614 - 618, The conditional redundantly checks result.template even though getTemplateForInstance's return type guarantees a non-optional template; update the call site in Metadata.js (around getTemplateForInstance and createTemplateInstance usage) to only check for result (i.e., remove the "&& result.template" part) and directly use result.template when calling createTemplateInstance; apply the same cleanup pattern where you saw a similar redundant template presence check in getEditors so the code relies on the non-optional return contract instead of double-checking template.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/api/Metadata.js`:
- Around line 477-485: Add a defensive check for instanceId (derived from
instance.$id) before making the cross-enterprise fetch: if instanceId is falsy,
skip calling getTemplates(id, scope, instanceId, true) (and return undefined or
continue without marking externally owned) instead of invoking
getMetadataTemplateUrlForScope via getTemplates with a missing instanceId;
specifically, guard the block that calls getTemplates and only perform the
cross-enterprise lookup when instanceId is present so
getMetadataTemplateUrlForScope(scope) is not accidentally used for a foreign
enterprise.
- Around line 519-521: In the getEditors method, remove the redundant inner
check of result.template since getTemplateForInstance returns a truthy result
with a non-optional template; after awaiting getTemplateForInstance(id,
instance, templates) simply check if (result) and then call
editors.push(this.createEditor(instance, result.template, canEdit)); ensure you
do not add or change handling of isExternallyOwned (the legacy path
intentionally omits it) and keep references to getTemplateForInstance and
createEditor unchanged.
---
Nitpick comments:
In `@src/api/Metadata.js`:
- Around line 540-582: The returned object can currently have canEdit true while
isExternallyOwned is true; modify the return construction so that canEdit is
forced to false when the isExternallyOwned parameter is true (e.g., set canEdit:
isExternallyOwned ? false : (instance.$canEdit && canEdit)) so downstream code
need only check canEdit; update the return object in the function that builds
the MetadataTemplateInstance (the block that currently returns {
isExternallyOwned, canEdit: instance.$canEdit && canEdit, ... }) to implement
this override.
- Around line 614-618: The conditional redundantly checks result.template even
though getTemplateForInstance's return type guarantees a non-optional template;
update the call site in Metadata.js (around getTemplateForInstance and
createTemplateInstance usage) to only check for result (i.e., remove the "&&
result.template" part) and directly use result.template when calling
createTemplateInstance; apply the same cleanup pattern where you saw a similar
redundant template presence check in getEditors so the code relies on the
non-optional return contract instead of double-checking template.
jfox-box
left a comment
There was a problem hiding this comment.
LGTM, but some minor comments.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/api/Metadata.js`:
- Around line 467-483: The code can return { template: undefined,
isExternallyOwned: true } when getTemplates(id, scope, instanceId, true) yields
an empty array; update the branch that handles cross-enterprise lookup to check
crossEnterpriseTemplates.length (or crossEnterpriseTemplate truthiness) and
return undefined if no template was found, otherwise return { template:
crossEnterpriseTemplate, isExternallyOwned: true } so callers never receive an
object with template === undefined; reference the variables getTemplates,
crossEnterpriseTemplates, crossEnterpriseTemplate, template and
isExternallyOwned when making the guard.
9e00d70 to
c99ed79
Compare
666433a to
ca44dd4
Compare
ca44dd4 to
d973747
Compare
Merge Queue StatusRule:
This pull request spent 6 seconds in the queue, with no time running CI. Required conditions to merge
|
Description
Adds support for externally owned metadata: when a file is shared or collaborated across enterprises, some metadata instances can use a template from another enterprise. This change exposes that information so consumers can show read-only UI or tooltips (e.g. for taxonomy fields) instead of allowing edits.
Changes made
getTemplateForInstance()now returns{ template, isExternallyOwned }instead of the template only.isExternallyOwnedistruewhen the template was resolved from a different enterprise (e.g. via instance-scoped template fetch).getTemplates()accepts an optional 4th parameterisExternallyOwned. Whentrue, taxonomy levels are not hydrated for the returned templates (they are not editable in that context).createTemplateInstance()accepts an optional 4th parameterisExternallyOwnedand includesisExternallyOwned(andtype) in the returned template instance.getTemplateInstances()passes throughisExternallyOwnedfromgetTemplateForInstanceinto each created template instance.MetadataTemplateInstancetype and tests updated for the new shape and property.Type of change
Testing done
Metadata.test.jsforgetTemplateForInstance,getEditors,getTemplateInstances, andcreateTemplateInstance.Summary by CodeRabbit
New Features
Chores
Tests