Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
"@box/frontend": "^11.0.1",
"@box/item-icon": "^0.27.1",
"@box/languages": "^1.0.0",
"@box/metadata-editor": "^1.5.3",
"@box/metadata-editor": "^1.18.0",
"@box/metadata-filter": "^1.41.3",
"@box/metadata-view": "^1.10.0",
"@box/react-virtualized": "^9.22.3-rc-box.10",
Expand Down Expand Up @@ -296,13 +296,13 @@
"webpack-dev-server": "^5.2.1"
},
"peerDependencies": {
"@box/blueprint-web": "^12.98.0",
"@box/blueprint-web": "^12.104.1",
"@box/blueprint-web-assets": "^4.80.4",
"@box/box-ai-agent-selector": "^0.53.0",
"@box/box-ai-content-answers": "^0.139.0",
"@box/box-item-type-selector": "^0.73.1",
"@box/cldr-data": ">=34.2.0",
"@box/combobox-with-api": "^1.3.11",
"@box/combobox-with-api": "^1.18.0",
"@box/copy-input": "^1.5.3",
"@box/item-icon": "^0.27.1",
"@box/metadata-editor": "^1.5.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,54 @@ describe('useSidebarMetadataFetcher', () => {
]);
});

test('should map taxonomy field suggestions with value and displayValue', async () => {
const taxonomyTemplate = {
canEdit: true,
id: 'metadata_template_taxonomy',
fields: [
{
key: 'taxonomyField',
type: 'taxonomy' as MetadataTemplateFieldType,
hidden: false,
},
],
scope: 'global',
templateKey: 'taxonomyTemplateKey',
};

const mockTaxonomySuggestions = {
taxonomyField: [
{ id: 'taxonomy-id-1', displayName: 'Taxonomy Item 1' },
{ id: 'taxonomy-id-2', displayName: 'Taxonomy Item 2' },
],
};

mockAPI.getMetadata.mockImplementation((file, successCallback) => {
successCallback({
editors: [],
templates: [taxonomyTemplate],
templateInstances: [],
});
});
mockAPI.extractStructured.mockResolvedValue(mockTaxonomySuggestions);

const { result } = setupHook();

await waitFor(() => expect(result.current.templates).toEqual([taxonomyTemplate]));

const suggestions = await result.current.extractSuggestions('taxonomyTemplateKey', 'global');

expect(suggestions).toEqual([
{
...taxonomyTemplate.fields[0],
aiSuggestion: [
{ value: 'taxonomy-id-1', displayValue: 'Taxonomy Item 1' },
{ value: 'taxonomy-id-2', displayValue: 'Taxonomy Item 2' },
],
},
]);
});

test('should handle user correctable error during suggestions extraction', async () => {
mockAPI.extractStructured.mockRejectedValue({ response: mockRateLimitError });

Expand Down
13 changes: 11 additions & 2 deletions src/elements/content-sidebar/hooks/useSidebarMetadataFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,19 @@ function useSidebarMetadataFetcher(

return fields.map(field => {
const value = answer[field.key];
// TODO: @box/metadadata-editor does not support AI suggestions, enable once supported
if (!value || field.type === 'taxonomy') {

if (!value) {
return field;
}
if (field.type === 'taxonomy') {
return {
...field,
aiSuggestion: value.map(item => ({
value: item.id,
displayValue: item.displayName,
})),
};
}
return {
...field,
aiSuggestion: value,
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1512,10 +1512,10 @@
resolved "https://registry.yarnpkg.com/@box/languages/-/languages-1.1.2.tgz#cd4266b3da62da18560d881e10b429653186be29"
integrity sha512-d64TGosx+KRmrLZj4CIyLp42LUiEbgBJ8n8cviMQwTJmfU0g+UwZqLjmQZR1j+Q9D64yV4xHzY9K1t5nInWWeQ==

"@box/metadata-editor@^1.5.3":
version "1.5.3"
resolved "https://registry.yarnpkg.com/@box/metadata-editor/-/metadata-editor-1.5.3.tgz#75eba5fb48697ce4f9e1428e8c7187fcac9c834b"
integrity sha512-49CaS2R8xnSlFKWjVscmx+YZJRV8NjYzzTKRMmw51f0Rs3I0VxRdxo0O+FThC6AtqRPE+3gvpLRMhXJlbTVL/w==
"@box/metadata-editor@^1.18.0":
version "1.19.0"
resolved "https://registry.yarnpkg.com/@box/metadata-editor/-/metadata-editor-1.19.0.tgz#832b63be022dc3ef0482776378fbfdaaaa7e3a87"
integrity sha512-JtI+2PbRYxX8YW2PN+E9sMeJaAX25v24PTk5upbNN/vohTjpEuy8TWeZMziLT1UBwPtJ83NXqLY3F+6P2EC4aw==

"@box/metadata-filter@^1.41.3":
version "1.41.3"
Expand Down Expand Up @@ -14400,7 +14400,7 @@ node-fetch@^2.6.12, node-fetch@^2.6.7:
dependencies:
whatwg-url "^5.0.0"

node-forge@1.3.2, node-forge@^1:
node-forge@^1:
version "1.3.2"
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-1.3.2.tgz#d0d2659a26eef778bf84d73e7f55c08144ee7750"
integrity sha512-6xKiQ+cph9KImrRh0VsjH2d8/GXA4FIMlgU4B757iI1ApvcyA9VlouP0yZJha01V+huImO+kKMU7ih+2+E14fw==
Expand Down