Skip to content

Commit fdc0c60

Browse files
authored
Merge pull request #16 from lumapps/chore/search-custom-icon-source-uid
chore(search-thumbnail): add section about sourceUid data
2 parents fcd1faa + 1052c7b commit fdc0c60

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

docs/javascript/capabilities.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,7 @@ In addition, a `SearchThumbnail` component is available to be as close as possib
577577
- [Replace icons for a specific result type](./use-cases#replace-icons-for-a-specific-result-type)
578578
- [Replace icons with a custom svg](./use-cases#replace-icons-with-a-custom-svg)
579579
- [Replace icons of documents with a specific mimetype](./use-cases#replace-icons-of-documents-with-a-specific-mimetype)
580+
- [Replace icons of documents with a specific source id](./use-cases#replace-icons-of-documents-with-a-specific-source-id)
580581

581582

582583
### Search tab

docs/javascript/use-cases.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,3 +1044,31 @@ window.lumapps.customize(({ targets, components, render, placement }) => {
10441044
![Search result page with icons replaced by a custom svg](./assets/search-results-mimetype-custom-icon.png "Search result page with icons replaced by a custom svg")
10451045

10461046
![Quick search opened with icons replaced by a custom svg](./assets/quick-search-mimetype-custom-icon.png "Quick search opened with icons replaced by a custom svg")
1047+
1048+
### Replace icons of documents with a specific source id
1049+
1050+
Some search engines apply a specific source identifier (ex: Google Cloud Search) that could be useful to have for a more in depth customization. You can retrieve this information via the `sourceUid` attribute.
1051+
The following script uses the target `targets.SEARCH_RESULT_ICON` and the placement `placements.REPLACE` in order to replace the default icon used by documents with a specific source identifier by another mdi icon.
1052+
1053+
**Some notes to consider:**
1054+
* Promoted results may have different identifier as those that weren't promoted.
1055+
* Search history interactions that were added before the customization was applied may not have the `sourceUid` field available.
1056+
Users will have to manually remove them and/or re-select them in the search results to update the search history.
1057+
1058+
```js
1059+
window.lumapps.customize(({ targets, components, render, placement }) => {
1060+
const { SearchThumbnail } = components;
1061+
render({
1062+
placement: placement.REPLACE,
1063+
target: targets.SEARCH_RESULT_ICON,
1064+
toRenderWithContext: ({ currentProps, entityType, mimeType, sourceUid }) => {
1065+
const isMyCustomType = sourceUid === 'datasources/3a09903cb4cb4e3b42659d38599d0c37';
1066+
return SearchThumbnail({
1067+
...currentProps,
1068+
icon: isMyCustomType ? 'file-pdf' : currentProps.icon,
1069+
});
1070+
},
1071+
});
1072+
});
1073+
1074+
```

0 commit comments

Comments
 (0)