From 6460c07931b3a85ca5425417992df81c87e06cc4 Mon Sep 17 00:00:00 2001 From: Josh Dover Date: Mon, 30 Nov 2020 11:41:24 -0700 Subject: [PATCH] Rename to searchDeepLinks --- .../public/kibana-plugin-core-public.app.md | 2 +- ...plugin-core-public.app.searchdeeplinks.md} | 10 ++-- ...na-plugin-core-public.appsearchdeeplink.md | 24 +++++++++ .../kibana-plugin-core-public.appsublink.md | 26 ---------- ...a-plugin-core-public.appupdatablefields.md | 2 +- .../core/public/kibana-plugin-core-public.md | 4 +- ...kibana-plugin-core-public.publicappinfo.md | 4 +- ...core-public.publicappsearchdeeplinkinfo.md | 15 ++++++ ...plugin-core-public.publicappsublinkinfo.md | 15 ------ src/core/public/application/index.ts | 4 +- src/core/public/application/types.ts | 32 ++++++------ .../application/utils/get_app_info.test.ts | 14 ++--- .../public/application/utils/get_app_info.ts | 31 ++++++----- src/core/public/index.ts | 4 +- src/core/public/public.api.md | 31 +++++------ src/plugins/management/public/plugin.ts | 26 +++++----- .../public/providers/application.test.ts | 2 +- .../public/providers/get_app_results.test.ts | 16 +++--- .../public/providers/get_app_results.ts | 51 +++++++++++-------- 19 files changed, 163 insertions(+), 150 deletions(-) rename docs/development/core/public/{kibana-plugin-core-public.app.sublinks.md => kibana-plugin-core-public.app.searchdeeplinks.md} (57%) create mode 100644 docs/development/core/public/kibana-plugin-core-public.appsearchdeeplink.md delete mode 100644 docs/development/core/public/kibana-plugin-core-public.appsublink.md create mode 100644 docs/development/core/public/kibana-plugin-core-public.publicappsearchdeeplinkinfo.md delete mode 100644 docs/development/core/public/kibana-plugin-core-public.publicappsublinkinfo.md diff --git a/docs/development/core/public/kibana-plugin-core-public.app.md b/docs/development/core/public/kibana-plugin-core-public.app.md index c4fc7527e366a..c3117ee193f7c 100644 --- a/docs/development/core/public/kibana-plugin-core-public.app.md +++ b/docs/development/core/public/kibana-plugin-core-public.app.md @@ -27,8 +27,8 @@ export interface App | [mount](./kibana-plugin-core-public.app.mount.md) | AppMount<HistoryLocationState> | AppMountDeprecated<HistoryLocationState> | A mount function called when the user navigates to this app's route. May have signature of [AppMount](./kibana-plugin-core-public.appmount.md) or [AppMountDeprecated](./kibana-plugin-core-public.appmountdeprecated.md). | | [navLinkStatus](./kibana-plugin-core-public.app.navlinkstatus.md) | AppNavLinkStatus | The initial status of the application's navLink. Defaulting to visible if status is accessible and hidden if status is inaccessible See [AppNavLinkStatus](./kibana-plugin-core-public.appnavlinkstatus.md) | | [order](./kibana-plugin-core-public.app.order.md) | number | An ordinal used to sort nav links relative to one another for display. | +| [searchDeepLinks](./kibana-plugin-core-public.app.searchdeeplinks.md) | AppSearchDeepLink[] | Array of links that represent secondary in-app locations for the app.Used to populate navigational search results (where available). Can be updated using the [App.updater$](./kibana-plugin-core-public.app.updater_.md) observable. See for more details. | | [status](./kibana-plugin-core-public.app.status.md) | AppStatus | The initial status of the application. Defaulting to accessible | -| [subLinks](./kibana-plugin-core-public.app.sublinks.md) | AppSubLink[] | Array of links that represent secondary in-app locations for the given app.Can be updated using the [App.updater$](./kibana-plugin-core-public.app.updater_.md) observable. See [AppSubLink](./kibana-plugin-core-public.appsublink.md) for more details. | | [title](./kibana-plugin-core-public.app.title.md) | string | The title of the application. | | [tooltip](./kibana-plugin-core-public.app.tooltip.md) | string | A tooltip shown when hovering over app link. | | [updater$](./kibana-plugin-core-public.app.updater_.md) | Observable<AppUpdater> | An [AppUpdater](./kibana-plugin-core-public.appupdater.md) observable that can be used to update the application [AppUpdatableFields](./kibana-plugin-core-public.appupdatablefields.md) at runtime. | diff --git a/docs/development/core/public/kibana-plugin-core-public.app.sublinks.md b/docs/development/core/public/kibana-plugin-core-public.app.searchdeeplinks.md similarity index 57% rename from docs/development/core/public/kibana-plugin-core-public.app.sublinks.md rename to docs/development/core/public/kibana-plugin-core-public.app.searchdeeplinks.md index d44c1b6ddb66e..2e5d6b7f8b61d 100644 --- a/docs/development/core/public/kibana-plugin-core-public.app.sublinks.md +++ b/docs/development/core/public/kibana-plugin-core-public.app.searchdeeplinks.md @@ -1,15 +1,15 @@ -[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [App](./kibana-plugin-core-public.app.md) > [subLinks](./kibana-plugin-core-public.app.sublinks.md) +[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [App](./kibana-plugin-core-public.app.md) > [searchDeepLinks](./kibana-plugin-core-public.app.searchdeeplinks.md) -## App.subLinks property +## App.searchDeepLinks property -Array of links that represent secondary in-app locations for the given app. +Array of links that represent secondary in-app locations for the app. -Can be updated using the [App.updater$](./kibana-plugin-core-public.app.updater_.md) observable. See [AppSubLink](./kibana-plugin-core-public.appsublink.md) for more details. +Used to populate navigational search results (where available). Can be updated using the [App.updater$](./kibana-plugin-core-public.app.updater_.md) observable. See for more details. Signature: ```typescript -subLinks?: AppSubLink[]; +searchDeepLinks?: AppSearchDeepLink[]; ``` diff --git a/docs/development/core/public/kibana-plugin-core-public.appsearchdeeplink.md b/docs/development/core/public/kibana-plugin-core-public.appsearchdeeplink.md new file mode 100644 index 0000000000000..7e5ccf7d06ed1 --- /dev/null +++ b/docs/development/core/public/kibana-plugin-core-public.appsearchdeeplink.md @@ -0,0 +1,24 @@ + + +[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [AppSearchDeepLink](./kibana-plugin-core-public.appsearchdeeplink.md) + +## AppSearchDeepLink type + +Input type for registering secondary in-app locations for an application. + +Deep links must include at least one of `path` or `searchDeepLinks`. A deep link that does not have a `path` represents a topological level in the application's hierarchy, but does not have a destination URL that is user-accessible. + +Signature: + +```typescript +export declare type AppSearchDeepLink = { + id: string; + title: string; +} & ({ + path: string; + searchDeepLinks?: AppSearchDeepLink[]; +} | { + path?: string; + searchDeepLinks: AppSearchDeepLink[]; +}); +``` diff --git a/docs/development/core/public/kibana-plugin-core-public.appsublink.md b/docs/development/core/public/kibana-plugin-core-public.appsublink.md deleted file mode 100644 index f6b25491e97ee..0000000000000 --- a/docs/development/core/public/kibana-plugin-core-public.appsublink.md +++ /dev/null @@ -1,26 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [AppSubLink](./kibana-plugin-core-public.appsublink.md) - -## AppSubLink type - -Input type for registering secondary in-app locations for an application. - -Sublinks must include at least one of `path` or `subLinks`. A sublink that does not have a `path` represents a topological level in the application's hierarchy, but does not have a destination URL that is user-accessible. - -Used to populate navigational search results (where available). - -Signature: - -```typescript -export declare type AppSubLink = { - id: string; - title: string; -} & ({ - path: string; - subLinks?: AppSubLink[]; -} | { - path?: string; - subLinks: AppSubLink[]; -}); -``` diff --git a/docs/development/core/public/kibana-plugin-core-public.appupdatablefields.md b/docs/development/core/public/kibana-plugin-core-public.appupdatablefields.md index be4c3e7d2f76a..b6f404c3d11aa 100644 --- a/docs/development/core/public/kibana-plugin-core-public.appupdatablefields.md +++ b/docs/development/core/public/kibana-plugin-core-public.appupdatablefields.md @@ -9,5 +9,5 @@ Defines the list of fields that can be updated via an [AppUpdater](./kibana-plug Signature: ```typescript -export declare type AppUpdatableFields = Pick; +export declare type AppUpdatableFields = Pick; ``` diff --git a/docs/development/core/public/kibana-plugin-core-public.md b/docs/development/core/public/kibana-plugin-core-public.md index c2f5af90571a8..5f656b9ca510d 100644 --- a/docs/development/core/public/kibana-plugin-core-public.md +++ b/docs/development/core/public/kibana-plugin-core-public.md @@ -138,7 +138,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | [AppLeaveHandler](./kibana-plugin-core-public.appleavehandler.md) | A handler that will be executed before leaving the application, either when going to another application or when closing the browser tab or manually changing the url. Should return confirm to to prompt a message to the user before leaving the page, or default to keep the default behavior (doing nothing).See [AppMountParameters](./kibana-plugin-core-public.appmountparameters.md) for detailed usage examples. | | [AppMount](./kibana-plugin-core-public.appmount.md) | A mount function called when the user navigates to this app's route. | | [AppMountDeprecated](./kibana-plugin-core-public.appmountdeprecated.md) | A mount function called when the user navigates to this app's route. | -| [AppSubLink](./kibana-plugin-core-public.appsublink.md) | Input type for registering secondary in-app locations for an application.Sublinks must include at least one of path or subLinks. A sublink that does not have a path represents a topological level in the application's hierarchy, but does not have a destination URL that is user-accessible.Used to populate navigational search results (where available). | +| [AppSearchDeepLink](./kibana-plugin-core-public.appsearchdeeplink.md) | Input type for registering secondary in-app locations for an application.Deep links must include at least one of path or searchDeepLinks. A deep link that does not have a path represents a topological level in the application's hierarchy, but does not have a destination URL that is user-accessible. | | [AppUnmount](./kibana-plugin-core-public.appunmount.md) | A function called when an application should be unmounted from the page. This function should be synchronous. | | [AppUpdatableFields](./kibana-plugin-core-public.appupdatablefields.md) | Defines the list of fields that can be updated via an [AppUpdater](./kibana-plugin-core-public.appupdater.md). | | [AppUpdater](./kibana-plugin-core-public.appupdater.md) | Updater for applications. see [ApplicationSetup](./kibana-plugin-core-public.applicationsetup.md) | @@ -161,7 +161,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | [PluginInitializer](./kibana-plugin-core-public.plugininitializer.md) | The plugin export at the root of a plugin's public directory should conform to this interface. | | [PluginOpaqueId](./kibana-plugin-core-public.pluginopaqueid.md) | | | [PublicAppInfo](./kibana-plugin-core-public.publicappinfo.md) | Public information about a registered [application](./kibana-plugin-core-public.app.md) | -| [PublicAppSubLinkInfo](./kibana-plugin-core-public.publicappsublinkinfo.md) | Public information about a registered app's [subLinks](./kibana-plugin-core-public.appsublink.md) | +| [PublicAppSearchDeepLinkInfo](./kibana-plugin-core-public.publicappsearchdeeplinkinfo.md) | Public information about a registered app's [searchDeepLinks](./kibana-plugin-core-public.appsearchdeeplink.md) | | [PublicUiSettingsParams](./kibana-plugin-core-public.publicuisettingsparams.md) | A sub-set of [UiSettingsParams](./kibana-plugin-core-public.uisettingsparams.md) exposed to the client-side. | | [SavedObjectAttribute](./kibana-plugin-core-public.savedobjectattribute.md) | Type definition for a Saved Object attribute value | | [SavedObjectAttributeSingle](./kibana-plugin-core-public.savedobjectattributesingle.md) | Don't use this type, it's simply a helper type for [SavedObjectAttribute](./kibana-plugin-core-public.savedobjectattribute.md) | diff --git a/docs/development/core/public/kibana-plugin-core-public.publicappinfo.md b/docs/development/core/public/kibana-plugin-core-public.publicappinfo.md index d18c9b3081c7d..d56b0ac58cd9b 100644 --- a/docs/development/core/public/kibana-plugin-core-public.publicappinfo.md +++ b/docs/development/core/public/kibana-plugin-core-public.publicappinfo.md @@ -9,10 +9,10 @@ Public information about a registered [application](./kibana-plugin-core-public. Signature: ```typescript -export declare type PublicAppInfo = Omit & { +export declare type PublicAppInfo = Omit & { status: AppStatus; navLinkStatus: AppNavLinkStatus; appRoute: string; - subLinks: PublicAppSubLinkInfo[]; + searchDeepLinks: PublicAppSearchDeepLinkInfo[]; }; ``` diff --git a/docs/development/core/public/kibana-plugin-core-public.publicappsearchdeeplinkinfo.md b/docs/development/core/public/kibana-plugin-core-public.publicappsearchdeeplinkinfo.md new file mode 100644 index 0000000000000..9814f0408d047 --- /dev/null +++ b/docs/development/core/public/kibana-plugin-core-public.publicappsearchdeeplinkinfo.md @@ -0,0 +1,15 @@ + + +[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [PublicAppSearchDeepLinkInfo](./kibana-plugin-core-public.publicappsearchdeeplinkinfo.md) + +## PublicAppSearchDeepLinkInfo type + +Public information about a registered app's [searchDeepLinks](./kibana-plugin-core-public.appsearchdeeplink.md) + +Signature: + +```typescript +export declare type PublicAppSearchDeepLinkInfo = Omit & { + searchDeepLinks: PublicAppSearchDeepLinkInfo[]; +}; +``` diff --git a/docs/development/core/public/kibana-plugin-core-public.publicappsublinkinfo.md b/docs/development/core/public/kibana-plugin-core-public.publicappsublinkinfo.md deleted file mode 100644 index 0d2052b213b09..0000000000000 --- a/docs/development/core/public/kibana-plugin-core-public.publicappsublinkinfo.md +++ /dev/null @@ -1,15 +0,0 @@ - - -[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [PublicAppSubLinkInfo](./kibana-plugin-core-public.publicappsublinkinfo.md) - -## PublicAppSubLinkInfo type - -Public information about a registered app's [subLinks](./kibana-plugin-core-public.appsublink.md) - -Signature: - -```typescript -export declare type PublicAppSubLinkInfo = Omit & { - subLinks: PublicAppSubLinkInfo[]; -}; -``` diff --git a/src/core/public/application/index.ts b/src/core/public/application/index.ts index b9df52311f287..b39aa70c888fe 100644 --- a/src/core/public/application/index.ts +++ b/src/core/public/application/index.ts @@ -31,7 +31,7 @@ export { AppNavLinkStatus, AppUpdatableFields, AppUpdater, - AppSubLink, + AppSearchDeepLink, ApplicationSetup, ApplicationStart, AppLeaveHandler, @@ -41,7 +41,7 @@ export { AppLeaveConfirmAction, NavigateToAppOptions, PublicAppInfo, - PublicAppSubLinkInfo, + PublicAppSearchDeepLinkInfo, // Internal types InternalApplicationSetup, InternalApplicationStart, diff --git a/src/core/public/application/types.ts b/src/core/public/application/types.ts index 579989735a5c8..9b80afa114c03 100644 --- a/src/core/public/application/types.ts +++ b/src/core/public/application/types.ts @@ -83,7 +83,7 @@ export enum AppNavLinkStatus { */ export type AppUpdatableFields = Pick< App, - 'status' | 'navLinkStatus' | 'tooltip' | 'defaultPath' | 'subLinks' + 'status' | 'navLinkStatus' | 'tooltip' | 'defaultPath' | 'searchDeepLinks' >; /** @@ -237,49 +237,49 @@ export interface App { exactRoute?: boolean; /** - * Array of links that represent secondary in-app locations for the given app. + * Array of links that represent secondary in-app locations for the app. * + * Used to populate navigational search results (where available). * Can be updated using the {@link App.updater$} observable. See {@link AppSubLink} for more details. */ - subLinks?: AppSubLink[]; + searchDeepLinks?: AppSearchDeepLink[]; } /** * Input type for registering secondary in-app locations for an application. * - * Sublinks must include at least one of `path` or `subLinks`. A sublink that does not have a `path` represents a - * topological level in the application's hierarchy, but does not have a destination URL that is user-accessible. - * - * Used to populate navigational search results (where available). + * Deep links must include at least one of `path` or `searchDeepLinks`. A deep link that does not have a `path` + * represents a topological level in the application's hierarchy, but does not have a destination URL that is + * user-accessible. * @public */ -export type AppSubLink = { +export type AppSearchDeepLink = { /** Identifier to represent this sublink, should be unique for this application */ id: string; - /** Title to label represent this sublink */ + /** Title to label represent this deep link */ title: string; } & ( | { /** URL path to access this link, relative to the application's appRoute. */ path: string; /** Optional array of links that are 'underneath' this section in the hierarchy */ - subLinks?: AppSubLink[]; + searchDeepLinks?: AppSearchDeepLink[]; } | { /** Optional path to access this section. Omit if this part of the hierarchy does not have a page URL. */ path?: string; /** Array links that are 'underneath' this section in this hierarchy. */ - subLinks: AppSubLink[]; + searchDeepLinks: AppSearchDeepLink[]; } ); /** - * Public information about a registered app's {@link AppSubLink | subLinks} + * Public information about a registered app's {@link AppSearchDeepLink | searchDeepLinks} * * @public */ -export type PublicAppSubLinkInfo = Omit & { - subLinks: PublicAppSubLinkInfo[]; +export type PublicAppSearchDeepLinkInfo = Omit & { + searchDeepLinks: PublicAppSearchDeepLinkInfo[]; }; /** @@ -287,12 +287,12 @@ export type PublicAppSubLinkInfo = Omit & { * * @public */ -export type PublicAppInfo = Omit & { +export type PublicAppInfo = Omit & { // remove optional on fields populated with default values status: AppStatus; navLinkStatus: AppNavLinkStatus; appRoute: string; - subLinks: PublicAppSubLinkInfo[]; + searchDeepLinks: PublicAppSearchDeepLinkInfo[]; }; /** diff --git a/src/core/public/application/utils/get_app_info.test.ts b/src/core/public/application/utils/get_app_info.test.ts index aa19251c379fc..ee0bd4f1eadfa 100644 --- a/src/core/public/application/utils/get_app_info.test.ts +++ b/src/core/public/application/utils/get_app_info.test.ts @@ -43,17 +43,17 @@ describe('getAppInfo', () => { status: AppStatus.accessible, navLinkStatus: AppNavLinkStatus.visible, appRoute: `/app/some-id`, - subLinks: [], + searchDeepLinks: [], }); }); - it('populates default values for nested subLinks', () => { + it('populates default values for nested searchDeepLinks', () => { const app = createApp({ - subLinks: [ + searchDeepLinks: [ { id: 'sub-id', title: 'sub-title', - subLinks: [{ id: 'sub-sub-id', title: 'sub-sub-title', path: '/sub-sub' }], + searchDeepLinks: [{ id: 'sub-sub-id', title: 'sub-sub-title', path: '/sub-sub' }], }, ], }); @@ -65,16 +65,16 @@ describe('getAppInfo', () => { status: AppStatus.accessible, navLinkStatus: AppNavLinkStatus.visible, appRoute: `/app/some-id`, - subLinks: [ + searchDeepLinks: [ { id: 'sub-id', title: 'sub-title', - subLinks: [ + searchDeepLinks: [ { id: 'sub-sub-id', title: 'sub-sub-title', path: '/sub-sub', - subLinks: [], // default empty array added + searchDeepLinks: [], // default empty array added }, ], }, diff --git a/src/core/public/application/utils/get_app_info.ts b/src/core/public/application/utils/get_app_info.ts index 3dbb88e7fa69c..7316080816da7 100644 --- a/src/core/public/application/utils/get_app_info.ts +++ b/src/core/public/application/utils/get_app_info.ts @@ -21,9 +21,9 @@ import { App, AppNavLinkStatus, AppStatus, - AppSubLink, + AppSearchDeepLink, PublicAppInfo, - PublicAppSubLinkInfo, + PublicAppSearchDeepLinkInfo, } from '../types'; export function getAppInfo(app: App): PublicAppInfo { @@ -39,21 +39,26 @@ export function getAppInfo(app: App): PublicAppInfo { status: app.status!, navLinkStatus, appRoute: app.appRoute!, - subLinks: getSubLinkInfos(app, app.subLinks), + searchDeepLinks: getSearchDeepLinkInfos(app, app.searchDeepLinks), }; } -function getSubLinkInfos(app: App, subLinks?: AppSubLink[]): PublicAppSubLinkInfo[] { - if (!subLinks) { +function getSearchDeepLinkInfos( + app: App, + searchDeepLinks?: AppSearchDeepLink[] +): PublicAppSearchDeepLinkInfo[] { + if (!searchDeepLinks) { return []; } - return subLinks.map((rawSubLink) => { - return { - id: rawSubLink.id, - title: rawSubLink.title, - path: rawSubLink.path, - subLinks: getSubLinkInfos(app, rawSubLink.subLinks), - }; - }); + return searchDeepLinks.map( + (rawDeepLink): PublicAppSearchDeepLinkInfo => { + return { + id: rawDeepLink.id, + title: rawDeepLink.title, + path: rawDeepLink.path, + searchDeepLinks: getSearchDeepLinkInfos(app, rawDeepLink.searchDeepLinks), + }; + } + ); } diff --git a/src/core/public/index.ts b/src/core/public/index.ts index e925e7a4ba501..557529fc94dc4 100644 --- a/src/core/public/index.ts +++ b/src/core/public/index.ts @@ -109,9 +109,9 @@ export { AppNavLinkStatus, AppUpdatableFields, AppUpdater, - AppSubLink, + AppSearchDeepLink, PublicAppInfo, - PublicAppSubLinkInfo, + PublicAppSearchDeepLinkInfo, ScopedHistory, NavigateToAppOptions, } from './application'; diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md index 085c7833bfe6a..aaea8f2f7c3fd 100644 --- a/src/core/public/public.api.md +++ b/src/core/public/public.api.md @@ -59,8 +59,9 @@ export interface App { mount: AppMount | AppMountDeprecated; navLinkStatus?: AppNavLinkStatus; order?: number; + // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "AppSubLink" + searchDeepLinks?: AppSearchDeepLink[]; status?: AppStatus; - subLinks?: AppSubLink[]; title: string; tooltip?: string; updater$?: Observable; @@ -177,28 +178,28 @@ export enum AppNavLinkStatus { } // @public -export enum AppStatus { - accessible = 0, - inaccessible = 1 -} - -// @public -export type AppSubLink = { +export type AppSearchDeepLink = { id: string; title: string; } & ({ path: string; - subLinks?: AppSubLink[]; + searchDeepLinks?: AppSearchDeepLink[]; } | { path?: string; - subLinks: AppSubLink[]; + searchDeepLinks: AppSearchDeepLink[]; }); +// @public +export enum AppStatus { + accessible = 0, + inaccessible = 1 +} + // @public export type AppUnmount = () => void; // @public -export type AppUpdatableFields = Pick; +export type AppUpdatableFields = Pick; // @public export type AppUpdater = (app: App) => Partial | undefined; @@ -980,16 +981,16 @@ export interface PluginInitializerContext export type PluginOpaqueId = symbol; // @public -export type PublicAppInfo = Omit & { +export type PublicAppInfo = Omit & { status: AppStatus; navLinkStatus: AppNavLinkStatus; appRoute: string; - subLinks: PublicAppSubLinkInfo[]; + searchDeepLinks: PublicAppSearchDeepLinkInfo[]; }; // @public -export type PublicAppSubLinkInfo = Omit & { - subLinks: PublicAppSubLinkInfo[]; +export type PublicAppSearchDeepLinkInfo = Omit & { + searchDeepLinks: PublicAppSearchDeepLinkInfo[]; }; // @public diff --git a/src/plugins/management/public/plugin.ts b/src/plugins/management/public/plugin.ts index c4bd89b3e1eff..bf03c649fa6b4 100644 --- a/src/plugins/management/public/plugin.ts +++ b/src/plugins/management/public/plugin.ts @@ -31,7 +31,7 @@ import { AppUpdater, AppStatus, AppNavLinkStatus, - AppSubLink, + AppSearchDeepLink, } from '../../../core/public'; import { MANAGEMENT_APP_ID } from '../common/contants'; @@ -49,20 +49,20 @@ export class ManagementPlugin implements Plugin(() => { - const subLinks: AppSubLink[] = Object.values(this.managementSections.definedSections).map( - (section: ManagementSection) => ({ - id: section.id, - title: section.title, - subLinks: section.getAppsEnabled().map((mgmtApp) => ({ - id: mgmtApp.id, - title: mgmtApp.title, - path: mgmtApp.basePath, - })), - }) - ); + const deepLinks: AppSearchDeepLink[] = Object.values( + this.managementSections.definedSections + ).map((section: ManagementSection) => ({ + id: section.id, + title: section.title, + searchDeepLinks: section.getAppsEnabled().map((mgmtApp) => ({ + id: mgmtApp.id, + title: mgmtApp.title, + path: mgmtApp.basePath, + })), + })); return { - subLinks, + searchDeepLinks: deepLinks, }; }); diff --git a/x-pack/plugins/global_search_providers/public/providers/application.test.ts b/x-pack/plugins/global_search_providers/public/providers/application.test.ts index a85c38ce2d39c..7beed42de4c4f 100644 --- a/x-pack/plugins/global_search_providers/public/providers/application.test.ts +++ b/x-pack/plugins/global_search_providers/public/providers/application.test.ts @@ -28,7 +28,7 @@ const createApp = (props: Partial = {}): PublicAppInfo => ({ status: AppStatus.accessible, navLinkStatus: AppNavLinkStatus.visible, chromeless: false, - subLinks: [], + searchDeepLinks: [], ...props, }); diff --git a/x-pack/plugins/global_search_providers/public/providers/get_app_results.test.ts b/x-pack/plugins/global_search_providers/public/providers/get_app_results.test.ts index 9dca61ec331f5..33fd358f61aca 100644 --- a/x-pack/plugins/global_search_providers/public/providers/get_app_results.test.ts +++ b/x-pack/plugins/global_search_providers/public/providers/get_app_results.test.ts @@ -19,7 +19,7 @@ const createApp = (props: Partial = {}): PublicAppInfo => ({ status: AppStatus.accessible, navLinkStatus: AppNavLinkStatus.visible, chromeless: false, - subLinks: [], + searchDeepLinks: [], ...props, }); @@ -43,16 +43,18 @@ describe('getAppResults', () => { expect(results[0]).toEqual(expect.objectContaining({ id: 'dashboard', score: 100 })); }); - it('creates multiple links for apps with sublinks', () => { + it('creates multiple links for apps with searchDeepLinks', () => { const apps = [ createApp({ - subLinks: [ - { id: 'sub1', title: 'Sub1', path: '/sub1', subLinks: [] }, + searchDeepLinks: [ + { id: 'sub1', title: 'Sub1', path: '/sub1', searchDeepLinks: [] }, { id: 'sub2', title: 'Sub2', path: '/sub2', - subLinks: [{ id: 'sub2sub1', title: 'Sub2Sub1', path: '/sub2/sub1', subLinks: [] }], + searchDeepLinks: [ + { id: 'sub2sub1', title: 'Sub2Sub1', path: '/sub2/sub1', searchDeepLinks: [] }, + ], }, ], }), @@ -69,10 +71,10 @@ describe('getAppResults', () => { ]); }); - it('only includes sublinks when search term is non-empty', () => { + it('only includes searchDeepLinks when search term is non-empty', () => { const apps = [ createApp({ - subLinks: [{ id: 'sub1', title: 'Sub1', path: '/sub1', subLinks: [] }], + searchDeepLinks: [{ id: 'sub1', title: 'Sub1', path: '/sub1', searchDeepLinks: [] }], }), ]; diff --git a/x-pack/plugins/global_search_providers/public/providers/get_app_results.ts b/x-pack/plugins/global_search_providers/public/providers/get_app_results.ts index bf381e035e514..01e6e87f30c94 100644 --- a/x-pack/plugins/global_search_providers/public/providers/get_app_results.ts +++ b/x-pack/plugins/global_search_providers/public/providers/get_app_results.ts @@ -5,10 +5,10 @@ */ import levenshtein from 'js-levenshtein'; -import { PublicAppInfo, PublicAppSubLinkInfo } from 'src/core/public'; +import { PublicAppInfo, PublicAppSearchDeepLinkInfo } from 'src/core/public'; import { GlobalSearchProviderResult } from '../../../global_search/public'; -/** Type used internally to represent an application unrolled into its separate sublinks */ +/** Type used internally to represent an application unrolled into its separate searchDeepLinks */ export interface AppLink { id: string; app: PublicAppInfo; @@ -22,10 +22,12 @@ export const getAppResults = ( ): GlobalSearchProviderResult[] => { return ( apps - // Unroll all sublinks - .flatMap((app) => flattenSubLinks(app)) - // Only include sublinks if there is a search term - .filter((appLink) => term.length > 0 || appLink.subLinkTitles.length === 0) + // Unroll all searchDeepLinks, only if there is a search term + .flatMap((app) => + term.length > 0 + ? flattenDeepLinks(app) + : [{ id: app.id, app, path: app.appRoute, subLinkTitles: [] }] + ) .map((appLink) => ({ appLink, score: scoreApp(term, appLink), @@ -82,8 +84,11 @@ export const appToResult = (appLink: AppLink, score: number): GlobalSearchProvid }; }; -const flattenSubLinks = (app: PublicAppInfo, subLink?: PublicAppSubLinkInfo): AppLink[] => { - if (!subLink) { +const flattenDeepLinks = ( + app: PublicAppInfo, + deepLink?: PublicAppSearchDeepLinkInfo +): AppLink[] => { + if (!deepLink) { return [ { id: app.id, @@ -91,25 +96,27 @@ const flattenSubLinks = (app: PublicAppInfo, subLink?: PublicAppSubLinkInfo): Ap path: app.appRoute, subLinkTitles: [], }, - ...app.subLinks.flatMap((appSubLink) => flattenSubLinks(app, appSubLink)), + ...app.searchDeepLinks.flatMap((appDeepLink) => flattenDeepLinks(app, appDeepLink)), ]; } - const appLink: AppLink = { - id: `${app.id}-${subLink.id}`, - app, - subLinkTitles: [subLink.title], - path: `${app.appRoute}${subLink.path}`, - }; - return [ - ...(subLink.path ? [appLink] : []), - ...subLink.subLinks - .flatMap((subSubLink) => flattenSubLinks(app, subSubLink)) - .map((subAppLink) => ({ - ...subAppLink, + ...(deepLink.path + ? [ + { + id: `${app.id}-${deepLink.id}`, + app, + subLinkTitles: [deepLink.title], + path: `${app.appRoute}${deepLink.path}`, + }, + ] + : []), + ...deepLink.searchDeepLinks + .flatMap((deepDeepLink) => flattenDeepLinks(app, deepDeepLink)) + .map((deepAppLink) => ({ + ...deepAppLink, // shift current sublink title into array of sub-sublink titles - subLinkTitles: [subLink.title, ...subAppLink.subLinkTitles], + subLinkTitles: [deepLink.title, ...deepAppLink.subLinkTitles], })), ]; };