Skip to content

Commit

Permalink
[GS] Allows apps to register searchable keywords for Global Search (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
TinaHeiligers authored Dec 18, 2020
1 parent ca24e11 commit 3a6e2a3
Show file tree
Hide file tree
Showing 24 changed files with 555 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ export interface App<HistoryLocationState = unknown>
| [exactRoute](./kibana-plugin-core-public.app.exactroute.md) | <code>boolean</code> | If set to true, the application's route will only be checked against an exact match. Defaults to <code>false</code>. |
| [icon](./kibana-plugin-core-public.app.icon.md) | <code>string</code> | A URL to an image file used as an icon. Used as a fallback if <code>euiIconType</code> is not provided. |
| [id](./kibana-plugin-core-public.app.id.md) | <code>string</code> | The unique identifier of the application |
| [meta](./kibana-plugin-core-public.app.meta.md) | <code>AppMeta</code> | Meta data for an application that represent additional information for the app. See [AppMeta](./kibana-plugin-core-public.appmeta.md) |
| [mount](./kibana-plugin-core-public.app.mount.md) | <code>AppMount&lt;HistoryLocationState&gt; &#124; AppMountDeprecated&lt;HistoryLocationState&gt;</code> | 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) | <code>AppNavLinkStatus</code> | The initial status of the application's navLink. Defaulting to <code>visible</code> if <code>status</code> is <code>accessible</code> and <code>hidden</code> if status is <code>inaccessible</code> See [AppNavLinkStatus](./kibana-plugin-core-public.appnavlinkstatus.md) |
| [order](./kibana-plugin-core-public.app.order.md) | <code>number</code> | An ordinal used to sort nav links relative to one another for display. |
| [searchDeepLinks](./kibana-plugin-core-public.app.searchdeeplinks.md) | <code>AppSearchDeepLink[]</code> | Array of links that represent secondary in-app locations for the app. |
| [status](./kibana-plugin-core-public.app.status.md) | <code>AppStatus</code> | The initial status of the application. Defaulting to <code>accessible</code> |
| [title](./kibana-plugin-core-public.app.title.md) | <code>string</code> | The title of the application. |
| [tooltip](./kibana-plugin-core-public.app.tooltip.md) | <code>string</code> | A tooltip shown when hovering over app link. |
Expand Down
43 changes: 43 additions & 0 deletions docs/development/core/public/kibana-plugin-core-public.app.meta.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-public](./kibana-plugin-core-public.md) &gt; [App](./kibana-plugin-core-public.app.md) &gt; [meta](./kibana-plugin-core-public.app.meta.md)

## App.meta property

Meta data for an application that represent additional information for the app. See [AppMeta](./kibana-plugin-core-public.appmeta.md)

<b>Signature:</b>

```typescript
meta?: AppMeta;
```

## Remarks

Used to populate navigational search results (where available). Can be updated using the [App.updater$](./kibana-plugin-core-public.app.updater_.md) observable. See [PublicAppSearchDeepLinkInfo](./kibana-plugin-core-public.publicappsearchdeeplinkinfo.md) for more details.

## Example


```ts
core.application.register({
id: 'my_app',
title: 'Translated title',
meta: {
keywords: ['translated keyword1', 'translated keyword2'],
searchDeepLinks: [
{ id: 'sub1', title: 'Sub1', path: '/sub1', keywords: ['subpath1'] },
{
id: 'sub2',
title: 'Sub2',
searchDeepLinks: [
{ id: 'subsub', title: 'SubSub', path: '/sub2/sub', keywords: ['subpath2'] }
]
}
],
},
mount: () => { ... }
})

```

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-public](./kibana-plugin-core-public.md) &gt; [AppMeta](./kibana-plugin-core-public.appmeta.md) &gt; [keywords](./kibana-plugin-core-public.appmeta.keywords.md)

## AppMeta.keywords property

Keywords to represent this application

<b>Signature:</b>

```typescript
keywords?: string[];
```
23 changes: 23 additions & 0 deletions docs/development/core/public/kibana-plugin-core-public.appmeta.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-public](./kibana-plugin-core-public.md) &gt; [AppMeta](./kibana-plugin-core-public.appmeta.md)

## AppMeta interface

Input type for meta data for an application.

Meta fields include `keywords` and `searchDeepLinks` Keywords is an array of string with which to associate the app, must include at least one unique string as an array. `searchDeepLinks` is an array of links that represent secondary in-app locations for the app.

<b>Signature:</b>

```typescript
export interface AppMeta
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [keywords](./kibana-plugin-core-public.appmeta.keywords.md) | <code>string[]</code> | Keywords to represent this application |
| [searchDeepLinks](./kibana-plugin-core-public.appmeta.searchdeeplinks.md) | <code>AppSearchDeepLink[]</code> | Array of links that represent secondary in-app locations for the app. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-public](./kibana-plugin-core-public.md) &gt; [AppMeta](./kibana-plugin-core-public.appmeta.md) &gt; [searchDeepLinks](./kibana-plugin-core-public.appmeta.searchdeeplinks.md)

## AppMeta.searchDeepLinks property

Array of links that represent secondary in-app locations for the app.

<b>Signature:</b>

```typescript
searchDeepLinks?: AppSearchDeepLink[];
```
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ export declare type AppSearchDeepLink = {
} & ({
path: string;
searchDeepLinks?: AppSearchDeepLink[];
keywords?: string[];
} | {
path?: string;
searchDeepLinks: AppSearchDeepLink[];
keywords?: string[];
});
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Defines the list of fields that can be updated via an [AppUpdater](./kibana-plug
<b>Signature:</b>

```typescript
export declare type AppUpdatableFields = Pick<App, 'status' | 'navLinkStatus' | 'tooltip' | 'defaultPath' | 'searchDeepLinks'>;
export declare type AppUpdatableFields = Pick<App, 'status' | 'navLinkStatus' | 'tooltip' | 'defaultPath' | 'meta'>;
```
2 changes: 2 additions & 0 deletions docs/development/core/public/kibana-plugin-core-public.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [AppLeaveDefaultAction](./kibana-plugin-core-public.appleavedefaultaction.md) | Action to return from a [AppLeaveHandler](./kibana-plugin-core-public.appleavehandler.md) to execute the default behaviour when leaving the application.<!-- -->See |
| [ApplicationSetup](./kibana-plugin-core-public.applicationsetup.md) | |
| [ApplicationStart](./kibana-plugin-core-public.applicationstart.md) | |
| [AppMeta](./kibana-plugin-core-public.appmeta.md) | Input type for meta data for an application.<!-- -->Meta fields include <code>keywords</code> and <code>searchDeepLinks</code> Keywords is an array of string with which to associate the app, must include at least one unique string as an array. <code>searchDeepLinks</code> is an array of links that represent secondary in-app locations for the app. |
| [AppMountContext](./kibana-plugin-core-public.appmountcontext.md) | The context object received when applications are mounted to the DOM. Deprecated, use [CoreSetup.getStartServices](./kibana-plugin-core-public.coresetup.getstartservices.md)<!-- -->. |
| [AppMountParameters](./kibana-plugin-core-public.appmountparameters.md) | |
| [Capabilities](./kibana-plugin-core-public.capabilities.md) | The read-only set of capabilities available for the current UI session. Capabilities are simple key-value pairs of (string, boolean), where the string denotes the capability ID, and the boolean is a flag indicating if the capability is enabled or disabled. |
Expand Down Expand Up @@ -164,6 +165,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [PluginInitializer](./kibana-plugin-core-public.plugininitializer.md) | The <code>plugin</code> export at the root of a plugin's <code>public</code> 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) |
| [PublicAppMetaInfo](./kibana-plugin-core-public.publicappmetainfo.md) | Public information about a registered app's [keywords](./kibana-plugin-core-public.appmeta.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 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Public information about a registered [application](./kibana-plugin-core-public.
<b>Signature:</b>

```typescript
export declare type PublicAppInfo = Omit<App, 'mount' | 'updater$' | 'searchDeepLinks'> & {
export declare type PublicAppInfo = Omit<App, 'mount' | 'updater$' | 'meta'> & {
status: AppStatus;
navLinkStatus: AppNavLinkStatus;
appRoute: string;
searchDeepLinks: PublicAppSearchDeepLinkInfo[];
meta: PublicAppMetaInfo;
};
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-public](./kibana-plugin-core-public.md) &gt; [PublicAppMetaInfo](./kibana-plugin-core-public.publicappmetainfo.md)

## PublicAppMetaInfo type

Public information about a registered app's [keywords](./kibana-plugin-core-public.appmeta.md)

<b>Signature:</b>

```typescript
export declare type PublicAppMetaInfo = Omit<AppMeta, 'keywords' | 'searchDeepLinks'> & {
keywords: string[];
searchDeepLinks: PublicAppSearchDeepLinkInfo[];
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Public information about a registered app's [searchDeepLinks](./kibana-plugin-co
<b>Signature:</b>

```typescript
export declare type PublicAppSearchDeepLinkInfo = Omit<AppSearchDeepLink, 'searchDeepLinks'> & {
export declare type PublicAppSearchDeepLinkInfo = Omit<AppSearchDeepLink, 'searchDeepLinks' | 'keywords'> & {
searchDeepLinks: PublicAppSearchDeepLinkInfo[];
keywords: string[];
};
```
2 changes: 2 additions & 0 deletions src/core/public/application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export {
AppNavLinkStatus,
AppUpdatableFields,
AppUpdater,
AppMeta,
AppSearchDeepLink,
ApplicationSetup,
ApplicationStart,
Expand All @@ -41,6 +42,7 @@ export {
AppLeaveConfirmAction,
NavigateToAppOptions,
PublicAppInfo,
PublicAppMetaInfo,
PublicAppSearchDeepLinkInfo,
// Internal types
InternalApplicationSetup,
Expand Down
80 changes: 56 additions & 24 deletions src/core/public/application/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export enum AppNavLinkStatus {
*/
export type AppUpdatableFields = Pick<
App,
'status' | 'navLinkStatus' | 'tooltip' | 'defaultPath' | 'searchDeepLinks'
'status' | 'navLinkStatus' | 'tooltip' | 'defaultPath' | 'meta'
>;

/**
Expand Down Expand Up @@ -237,39 +237,76 @@ export interface App<HistoryLocationState = unknown> {
exactRoute?: boolean;

/**
* Array of links that represent secondary in-app locations for the app.
* Meta data for an application that represent additional information for the app.
* See {@link AppMeta}
*
* @remarks
* Used to populate navigational search results (where available).
* Can be updated using the {@link App.updater$} observable. See {@link AppSubLink} for more details.
* Can be updated using the {@link App.updater$} observable. See {@link PublicAppSearchDeepLinkInfo} for more details.
*
* @example
* The `path` property on deep links should not include the application's `appRoute`:
* ```ts
* core.application.register({
* id: 'my_app',
* title: 'My App',
* searchDeepLinks: [
* { id: 'sub1', title: 'Sub1', path: '/sub1' },
* title: 'Translated title',
* meta: {
* keywords: ['translated keyword1', 'translated keyword2'],
* searchDeepLinks: [
* { id: 'sub1', title: 'Sub1', path: '/sub1', keywords: ['subpath1'] },
* {
* id: 'sub2',
* title: 'Sub2',
* searchDeepLinks: [
* { id: 'subsub', title: 'SubSub', path: '/sub2/sub' }
* { id: 'subsub', title: 'SubSub', path: '/sub2/sub', keywords: ['subpath2'] }
* ]
* }
* ],
* mount: () => { ... },
* },
* mount: () => { ... }
* })
* ```
*
* Will produce deep links on these paths:
* - `/app/my_app/sub1`
* - `/app/my_app/sub2/sub`
*/
meta?: AppMeta;
}

/**
* Input type for meta data for an application.
*
* Meta fields include `keywords` and `searchDeepLinks`
* Keywords is an array of string with which to associate the app, must include at least one unique string as an array.
* `searchDeepLinks` is an array of links that represent secondary in-app locations for the app.
* @public
*/
export interface AppMeta {
/** Keywords to represent this application */
keywords?: string[];
/** Array of links that represent secondary in-app locations for the app. */
searchDeepLinks?: AppSearchDeepLink[];
}

/**
* Public information about a registered app's {@link AppMeta | keywords }
*
* @public
*/
export type PublicAppMetaInfo = Omit<AppMeta, 'keywords' | 'searchDeepLinks'> & {
keywords: string[];
searchDeepLinks: PublicAppSearchDeepLinkInfo[];
};

/**
* Public information about a registered app's {@link AppSearchDeepLink | searchDeepLinks}
*
* @public
*/
export type PublicAppSearchDeepLinkInfo = Omit<
AppSearchDeepLink,
'searchDeepLinks' | 'keywords'
> & {
searchDeepLinks: PublicAppSearchDeepLinkInfo[];
keywords: string[];
};

/**
* Input type for registering secondary in-app locations for an application.
*
Expand All @@ -289,35 +326,30 @@ export type AppSearchDeepLink = {
path: string;
/** Optional array of links that are 'underneath' this section in the hierarchy */
searchDeepLinks?: AppSearchDeepLink[];
/** Optional keywords to match with in deep links search for the page at the path */
keywords?: string[];
}
| {
/** 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. */
searchDeepLinks: AppSearchDeepLink[];
/** Optional keywords to match with in deep links search. Omit if this part of the hierarchy does not have a page URL. */
keywords?: string[];
}
);

/**
* Public information about a registered app's {@link AppSearchDeepLink | searchDeepLinks}
*
* @public
*/
export type PublicAppSearchDeepLinkInfo = Omit<AppSearchDeepLink, 'searchDeepLinks'> & {
searchDeepLinks: PublicAppSearchDeepLinkInfo[];
};

/**
* Public information about a registered {@link App | application}
*
* @public
*/
export type PublicAppInfo = Omit<App, 'mount' | 'updater$' | 'searchDeepLinks'> & {
export type PublicAppInfo = Omit<App, 'mount' | 'updater$' | 'meta'> & {
// remove optional on fields populated with default values
status: AppStatus;
navLinkStatus: AppNavLinkStatus;
appRoute: string;
searchDeepLinks: PublicAppSearchDeepLinkInfo[];
meta: PublicAppMetaInfo;
};

/**
Expand Down
Loading

0 comments on commit 3a6e2a3

Please sign in to comment.