mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
add category related meta to application results (#77618)
This commit is contained in:
parent
04a5a4c0ca
commit
33f6025add
2 changed files with 36 additions and 1 deletions
|
@ -4,7 +4,12 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { AppNavLinkStatus, AppStatus, PublicAppInfo } from 'src/core/public';
|
||||
import {
|
||||
AppNavLinkStatus,
|
||||
AppStatus,
|
||||
PublicAppInfo,
|
||||
DEFAULT_APP_CATEGORIES,
|
||||
} from 'src/core/public';
|
||||
import { appToResult, getAppResults, scoreApp } from './get_app_results';
|
||||
|
||||
const createApp = (props: Partial<PublicAppInfo> = {}): PublicAppInfo => ({
|
||||
|
@ -70,6 +75,7 @@ describe('appToResult', () => {
|
|||
title: 'Foo',
|
||||
euiIconType: 'fooIcon',
|
||||
appRoute: '/app/foo',
|
||||
category: DEFAULT_APP_CATEGORIES.security,
|
||||
});
|
||||
expect(appToResult(app, 42)).toEqual({
|
||||
id: 'foo',
|
||||
|
@ -77,6 +83,31 @@ describe('appToResult', () => {
|
|||
type: 'application',
|
||||
icon: 'fooIcon',
|
||||
url: '/app/foo',
|
||||
meta: {
|
||||
categoryId: DEFAULT_APP_CATEGORIES.security.id,
|
||||
categoryLabel: DEFAULT_APP_CATEGORIES.security.label,
|
||||
},
|
||||
score: 42,
|
||||
});
|
||||
});
|
||||
|
||||
it('converts an app without category to a result', () => {
|
||||
const app = createApp({
|
||||
id: 'foo',
|
||||
title: 'Foo',
|
||||
euiIconType: 'fooIcon',
|
||||
appRoute: '/app/foo',
|
||||
});
|
||||
expect(appToResult(app, 42)).toEqual({
|
||||
id: 'foo',
|
||||
title: 'Foo',
|
||||
type: 'application',
|
||||
icon: 'fooIcon',
|
||||
url: '/app/foo',
|
||||
meta: {
|
||||
categoryId: null,
|
||||
categoryLabel: null,
|
||||
},
|
||||
score: 42,
|
||||
});
|
||||
});
|
||||
|
|
|
@ -50,6 +50,10 @@ export const appToResult = (app: PublicAppInfo, score: number): GlobalSearchProv
|
|||
type: 'application',
|
||||
icon: app.euiIconType,
|
||||
url: app.appRoute,
|
||||
meta: {
|
||||
categoryId: app.category?.id ?? null,
|
||||
categoryLabel: app.category?.label ?? null,
|
||||
},
|
||||
score,
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue