Skip to content

Commit

Permalink
Add ApplicationService app status management (#50223)
Browse files Browse the repository at this point in the history
* add unimplemented registerAppStatusUpdater & remove observers for apps and legacyApps

* adapt NavLinksService to use new application observables

* merge availableApps$ and availableLegacyApps$

* updating core docs

* adapt the navLink updating methods

* filters the inaccessible apps from availableApps$

* restrict access to navigateToApp depending on app status

* fixes due to merge

* add statusUpdater$ to AppBase

* export new types

* disable navlink depending on app status

* update generated doc

* update snapshots for disabled prop

* Address josh review

* Address review comments

* fix merge conflicts

* adapt changes due to merge

* update generated doc

* add comment and fix navlink url for custom url apps

* add AppNavLinkStatus type to split app/navlink states

* fix typo

* review comments and improvements

* add functional tests

* update generated docs and migration guide

* fix wrong type cast on AppsMenuProvider.readLinks

* properly type return of navigateToApp
  • Loading branch information
pgayvallet authored Jan 12, 2020
1 parent 794bb02 commit aeebedf
Show file tree
Hide file tree
Showing 75 changed files with 1,798 additions and 581 deletions.
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-public](./kibana-plugin-public.md) &gt; [AppBase](./kibana-plugin-public.appbase.md) &gt; [chromeless](./kibana-plugin-public.appbase.chromeless.md)

## AppBase.chromeless property

Hide the UI chrome when the application is mounted. Defaults to `false`<!-- -->. Takes precedence over chrome service visibility settings.

<b>Signature:</b>

```typescript
chromeless?: boolean;
```
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## AppBase.id property

The unique identifier of the application

<b>Signature:</b>

```typescript
Expand Down
8 changes: 6 additions & 2 deletions docs/development/core/public/kibana-plugin-public.appbase.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ export interface AppBase
| Property | Type | Description |
| --- | --- | --- |
| [capabilities](./kibana-plugin-public.appbase.capabilities.md) | <code>Partial&lt;Capabilities&gt;</code> | Custom capabilities defined by the app. |
| [chromeless](./kibana-plugin-public.appbase.chromeless.md) | <code>boolean</code> | Hide the UI chrome when the application is mounted. Defaults to <code>false</code>. Takes precedence over chrome service visibility settings. |
| [euiIconType](./kibana-plugin-public.appbase.euiicontype.md) | <code>string</code> | A EUI iconType that will be used for the app's icon. This icon takes precendence over the <code>icon</code> property. |
| [icon](./kibana-plugin-public.appbase.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-public.appbase.id.md) | <code>string</code> | |
| [id](./kibana-plugin-public.appbase.id.md) | <code>string</code> | The unique identifier of the application |
| [navLinkStatus](./kibana-plugin-public.appbase.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-public.appnavlinkstatus.md) |
| [order](./kibana-plugin-public.appbase.order.md) | <code>number</code> | An ordinal used to sort nav links relative to one another for display. |
| [status](./kibana-plugin-public.appbase.status.md) | <code>AppStatus</code> | The initial status of the application. Defaulting to <code>accessible</code> |
| [title](./kibana-plugin-public.appbase.title.md) | <code>string</code> | The title of the application. |
| [tooltip$](./kibana-plugin-public.appbase.tooltip_.md) | <code>Observable&lt;string&gt;</code> | An observable for a tooltip shown when hovering over app link. |
| [tooltip](./kibana-plugin-public.appbase.tooltip.md) | <code>string</code> | A tooltip shown when hovering over app link. |
| [updater$](./kibana-plugin-public.appbase.updater_.md) | <code>Observable&lt;AppUpdater&gt;</code> | An [AppUpdater](./kibana-plugin-public.appupdater.md) observable that can be used to update the application [AppUpdatableFields](./kibana-plugin-public.appupdatablefields.md) at runtime. |

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-public](./kibana-plugin-public.md) &gt; [AppBase](./kibana-plugin-public.appbase.md) &gt; [navLinkStatus](./kibana-plugin-public.appbase.navlinkstatus.md)

## AppBase.navLinkStatus property

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-public.appnavlinkstatus.md)

<b>Signature:</b>

```typescript
navLinkStatus?: AppNavLinkStatus;
```
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [AppBase](./kibana-plugin-public.appbase.md) &gt; [tooltip$](./kibana-plugin-public.appbase.tooltip_.md)
[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [AppBase](./kibana-plugin-public.appbase.md) &gt; [status](./kibana-plugin-public.appbase.status.md)

## AppBase.tooltip$ property
## AppBase.status property

An observable for a tooltip shown when hovering over app link.
The initial status of the application. Defaulting to `accessible`

<b>Signature:</b>

```typescript
tooltip$?: Observable<string>;
status?: AppStatus;
```
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-public](./kibana-plugin-public.md) &gt; [AppBase](./kibana-plugin-public.appbase.md) &gt; [tooltip](./kibana-plugin-public.appbase.tooltip.md)

## AppBase.tooltip property

A tooltip shown when hovering over app link.

<b>Signature:</b>

```typescript
tooltip?: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [AppBase](./kibana-plugin-public.appbase.md) &gt; [updater$](./kibana-plugin-public.appbase.updater_.md)

## AppBase.updater$ property

An [AppUpdater](./kibana-plugin-public.appupdater.md) observable that can be used to update the application [AppUpdatableFields](./kibana-plugin-public.appupdatablefields.md) at runtime.

<b>Signature:</b>

```typescript
updater$?: Observable<AppUpdater>;
```

## Example

How to update an application navLink at runtime

```ts
// inside your plugin's setup function
export class MyPlugin implements Plugin {
private appUpdater = new BehaviorSubject<AppUpdater>(() => ({}));

setup({ application }) {
application.register({
id: 'my-app',
title: 'My App',
updater$: this.appUpdater,
async mount(params) {
const { renderApp } = await import('./application');
return renderApp(params);
},
});
}

start() {
// later, when the navlink needs to be updated
appUpdater.next(() => {
navLinkStatus: AppNavLinkStatus.disabled,
})
}

```
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ export interface ApplicationSetup
| Method | Description |
| --- | --- |
| [register(app)](./kibana-plugin-public.applicationsetup.register.md) | Register an mountable application to the system. |
| [registerAppUpdater(appUpdater$)](./kibana-plugin-public.applicationsetup.registerappupdater.md) | Register an application updater that can be used to change the [AppUpdatableFields](./kibana-plugin-public.appupdatablefields.md) fields of all applications at runtime.<!-- -->This is meant to be used by plugins that needs to updates the whole list of applications. To only updates a specific application, use the <code>updater$</code> property of the registered application instead. |
| [registerMountContext(contextName, provider)](./kibana-plugin-public.applicationsetup.registermountcontext.md) | Register a context provider for application mounting. Will only be available to applications that depend on the plugin that registered this context. Deprecated, use [CoreSetup.getStartServices()](./kibana-plugin-public.coresetup.getstartservices.md)<!-- -->. |

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

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [ApplicationSetup](./kibana-plugin-public.applicationsetup.md) &gt; [registerAppUpdater](./kibana-plugin-public.applicationsetup.registerappupdater.md)

## ApplicationSetup.registerAppUpdater() method

Register an application updater that can be used to change the [AppUpdatableFields](./kibana-plugin-public.appupdatablefields.md) fields of all applications at runtime.

This is meant to be used by plugins that needs to updates the whole list of applications. To only updates a specific application, use the `updater$` property of the registered application instead.

<b>Signature:</b>

```typescript
registerAppUpdater(appUpdater$: Observable<AppUpdater>): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| appUpdater$ | <code>Observable&lt;AppUpdater&gt;</code> | |

<b>Returns:</b>

`void`

## Example

How to register an application updater that disables some applications:

```ts
// inside your plugin's setup function
export class MyPlugin implements Plugin {
setup({ application }) {
application.registerAppUpdater(
new BehaviorSubject<AppUpdater>(app => {
if (myPluginApi.shouldDisable(app))
return {
status: AppStatus.inaccessible,
};
})
);
}
}

```

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-public](./kibana-plugin-public.md) &gt; [AppNavLinkStatus](./kibana-plugin-public.appnavlinkstatus.md)

## AppNavLinkStatus enum

Status of the application's navLink.

<b>Signature:</b>

```typescript
export declare enum AppNavLinkStatus
```

## Enumeration Members

| Member | Value | Description |
| --- | --- | --- |
| default | <code>0</code> | The application navLink will be <code>visible</code> if the application's [AppStatus](./kibana-plugin-public.appstatus.md) is set to <code>accessible</code> and <code>hidden</code> if the application status is set to <code>inaccessible</code>. |
| disabled | <code>2</code> | The application navLink is visible but inactive and not clickable in the navigation bar. |
| hidden | <code>3</code> | The application navLink does not appear in the navigation bar. |
| visible | <code>1</code> | The application navLink is visible and clickable in the navigation bar. |

21 changes: 21 additions & 0 deletions docs/development/core/public/kibana-plugin-public.appstatus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [AppStatus](./kibana-plugin-public.appstatus.md)

## AppStatus enum

Accessibility status of an application.

<b>Signature:</b>

```typescript
export declare enum AppStatus
```

## Enumeration Members

| Member | Value | Description |
| --- | --- | --- |
| accessible | <code>0</code> | Application is accessible. |
| inaccessible | <code>1</code> | Application is not accessible. |

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-public](./kibana-plugin-public.md) &gt; [AppUpdatableFields](./kibana-plugin-public.appupdatablefields.md)

## AppUpdatableFields type

Defines the list of fields that can be updated via an [AppUpdater](./kibana-plugin-public.appupdater.md)<!-- -->.

<b>Signature:</b>

```typescript
export declare type AppUpdatableFields = Pick<AppBase, 'status' | 'navLinkStatus' | 'tooltip'>;
```
13 changes: 13 additions & 0 deletions docs/development/core/public/kibana-plugin-public.appupdater.md
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-public](./kibana-plugin-public.md) &gt; [AppUpdater](./kibana-plugin-public.appupdater.md)

## AppUpdater type

Updater for applications. see [ApplicationSetup](./kibana-plugin-public.applicationsetup.md)

<b>Signature:</b>

```typescript
export declare type AppUpdater = (app: AppBase) => Partial<AppUpdatableFields> | undefined;
```
Loading

0 comments on commit aeebedf

Please sign in to comment.