diff --git a/changelogs/fragments/8920.yml b/changelogs/fragments/8920.yml new file mode 100644 index 000000000000..f25a3042d437 --- /dev/null +++ b/changelogs/fragments/8920.yml @@ -0,0 +1,2 @@ +feat: +- [workspace]support search dev tools by its category name ([#8920](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8920)) \ No newline at end of file diff --git a/src/plugins/dev_tools/public/global_search/search_devtool_command.test.tsx b/src/plugins/dev_tools/public/global_search/search_devtool_command.test.tsx index 883584e49e08..9a5ce520e8f1 100644 --- a/src/plugins/dev_tools/public/global_search/search_devtool_command.test.tsx +++ b/src/plugins/dev_tools/public/global_search/search_devtool_command.test.tsx @@ -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, @@ -56,7 +67,11 @@ describe('DevtoolSearchCommand', () => { /> - Dev tools + + Dev tools + , }, diff --git a/src/plugins/dev_tools/public/global_search/search_devtool_command.tsx b/src/plugins/dev_tools/public/global_search/search_devtool_command.tsx index 7bb8a9cb7238..03efbb751807 100644 --- a/src/plugins/dev_tools/public/global_search/search_devtool_command.tsx +++ b/src/plugins/dev_tools/public/global_search/search_devtool_command.tsx @@ -33,12 +33,18 @@ export const searchForDevTools = async ( - {props.title} + + {props.title} + ); - 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: [ {