Skip to content

Commit

Permalink
[Workspace]Support search dev tools by its category name (#8920) (#8988)
Browse files Browse the repository at this point in the history
* support search dev tools by category name



* Changeset file for PR #8920 created/updated

* address review comments



---------



(cherry picked from commit 1c744d6)

Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 29, 2024
1 parent 56b8b19 commit b4b5d1a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/8920.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
feat:
- [workspace]support search dev tools by its category name ([#8920](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8920))
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ describe('DevtoolSearchCommand', () => {
expect(searchResult).toHaveLength(0);
});

it('searchForDevTools matches category', async () => {
const searchResult = await searchForDevTools('dev', {
devTools: devToolsFn,
title: 'Dev tools',
uiActionsApi: uiActionsApiFn,
});

// match all sub apps
expect(searchResult).toHaveLength(2);
});

it('searchForDevTools with match tool', async () => {
const searchResult = await searchForDevTools('console', {
devTools: devToolsFn,
Expand All @@ -56,7 +67,11 @@ describe('DevtoolSearchCommand', () => {
/>
</EuiFlexItem>
<EuiFlexItem>
Dev tools
<EuiHighlight
search="console"
>
Dev tools
</EuiHighlight>
</EuiFlexItem>
</EuiFlexGroup>,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,18 @@ export const searchForDevTools = async (
<EuiFlexItem>
<EuiIcon type="consoleApp" color="text" />
</EuiFlexItem>
<EuiFlexItem>{props.title}</EuiFlexItem>
<EuiFlexItem>
<EuiHighlight search={query}>{props.title}</EuiHighlight>
</EuiFlexItem>
</EuiFlexGroup>
);

return tools
.filter((tool) => tool.title.toLowerCase().includes(query.toLowerCase()))
const titleMatched = props.title.toLowerCase().includes(query.toLowerCase());
const matchedTools = titleMatched
? tools
: tools.filter((tool) => tool.title.toLowerCase().includes(query.toLowerCase()));

return matchedTools
.map((tool) => ({
breadcrumbs: [
{
Expand Down

0 comments on commit b4b5d1a

Please sign in to comment.