diff --git a/x-pack/plugins/enterprise_search/public/assets/source_icons/index.svg b/x-pack/plugins/enterprise_search/public/assets/source_icons/index.svg new file mode 100644 index 0000000000000..6af8b7e92afe9 --- /dev/null +++ b/x-pack/plugins/enterprise_search/public/assets/source_icons/index.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/x-pack/plugins/enterprise_search/server/plugin.ts b/x-pack/plugins/enterprise_search/server/plugin.ts index c63952d8b543f..8d493c0a4d59b 100644 --- a/x-pack/plugins/enterprise_search/server/plugin.ts +++ b/x-pack/plugins/enterprise_search/server/plugin.ts @@ -344,7 +344,7 @@ export class EnterpriseSearchPlugin implements Plugin { if (globalSearch) { globalSearch.registerResultProvider(getSearchResultProvider(http.basePath, config)); - globalSearch.registerResultProvider(getIndicesSearchResultProvider()); + globalSearch.registerResultProvider(getIndicesSearchResultProvider(http.basePath)); } } diff --git a/x-pack/plugins/enterprise_search/server/utils/indices_search_result_provider.test.ts b/x-pack/plugins/enterprise_search/server/utils/indices_search_result_provider.test.ts index 719db07d0b94b..facae46be72a4 100644 --- a/x-pack/plugins/enterprise_search/server/utils/indices_search_result_provider.test.ts +++ b/x-pack/plugins/enterprise_search/server/utils/indices_search_result_provider.test.ts @@ -14,7 +14,11 @@ import { ENTERPRISE_SEARCH_CONTENT_PLUGIN } from '../../common/constants'; import { getIndicesSearchResultProvider } from './indices_search_result_provider'; describe('Enterprise Search - indices search provider', () => { - const indicesSearchResultProvider = getIndicesSearchResultProvider(); + const basePathMock = { + prepend: (input: string) => `/kbn${input}`, + } as any; + + const indicesSearchResultProvider = getIndicesSearchResultProvider(basePathMock); const regularIndexResponse = { 'search-github-api': { @@ -50,6 +54,7 @@ describe('Enterprise Search - indices search provider', () => { path: `${ENTERPRISE_SEARCH_CONTENT_PLUGIN.URL}/search_indices/search-github-api`, prependBasePath: true, }, + icon: '/kbn/plugins/enterpriseSearch/assets/source_icons/index.svg', }; const msftIndex = { @@ -61,6 +66,7 @@ describe('Enterprise Search - indices search provider', () => { path: `${ENTERPRISE_SEARCH_CONTENT_PLUGIN.URL}/search_indices/search-msft-sql-index`, prependBasePath: true, }, + icon: '/kbn/plugins/enterpriseSearch/assets/source_icons/index.svg', }; beforeEach(() => {}); diff --git a/x-pack/plugins/enterprise_search/server/utils/indices_search_result_provider.ts b/x-pack/plugins/enterprise_search/server/utils/indices_search_result_provider.ts index 0cb6faf64b4c0..c826be87fcdfc 100644 --- a/x-pack/plugins/enterprise_search/server/utils/indices_search_result_provider.ts +++ b/x-pack/plugins/enterprise_search/server/utils/indices_search_result_provider.ts @@ -7,6 +7,7 @@ import { from, takeUntil } from 'rxjs'; +import { IBasePath } from '@kbn/core-http-server'; import { GlobalSearchProviderResult, GlobalSearchResultProvider, @@ -17,7 +18,7 @@ import { ENTERPRISE_SEARCH_CONTENT_PLUGIN } from '../../common/constants'; import { getIndexData } from '../lib/indices/utils/get_index_data'; -export function getIndicesSearchResultProvider(): GlobalSearchResultProvider { +export function getIndicesSearchResultProvider(basePath: IBasePath): GlobalSearchResultProvider { return { find: ({ term, types, tags }, { aborted$, client, maxResults }) => { if (!client || !term || tags || (types && !types.includes('indices'))) { @@ -44,6 +45,7 @@ export function getIndicesSearchResultProvider(): GlobalSearchResultProvider { return { id: indexName, title: indexName, + icon: basePath.prepend('/plugins/enterpriseSearch/assets/source_icons/index.svg'), type: i18n.translate('xpack.enterpriseSearch.searchIndexProvider.type.name', { defaultMessage: 'Index', }), diff --git a/x-pack/plugins/global_search_bar/public/lib/result_to_option.test.ts b/x-pack/plugins/global_search_bar/public/lib/result_to_option.test.ts index d60453ca37d85..92589202cd16a 100644 --- a/x-pack/plugins/global_search_bar/public/lib/result_to_option.test.ts +++ b/x-pack/plugins/global_search_bar/public/lib/result_to_option.test.ts @@ -52,6 +52,15 @@ describe('resultToOption', () => { ); }); + it('uses icon for `index` type', () => { + const input = createSearchResult({ type: 'index', icon: 'index-icon' }); + expect(resultToOption(input, [])).toEqual( + expect.objectContaining({ + icon: { type: 'index-icon' }, + }) + ); + }); + it('does not use icon for other types', () => { const input = createSearchResult({ type: 'dashboard', icon: 'dash-icon' }); expect(resultToOption(input, [])).toEqual( diff --git a/x-pack/plugins/global_search_bar/public/lib/result_to_option.tsx b/x-pack/plugins/global_search_bar/public/lib/result_to_option.tsx index 88fa86edbd395..555434a85404f 100644 --- a/x-pack/plugins/global_search_bar/public/lib/result_to_option.tsx +++ b/x-pack/plugins/global_search_bar/public/lib/result_to_option.tsx @@ -25,7 +25,8 @@ export const resultToOption = ( type === 'application' || type === 'integration' || type.toLowerCase() === 'enterprise search' || - type.toLowerCase() === 'search'; + type.toLowerCase() === 'search' || + type.toLowerCase() === 'index'; const option: EuiSelectableTemplateSitewideOption = { key: id, label: title,