Skip to content

Commit aeebedf

Browse files
authored
Add ApplicationService app status management (#50223)
* 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
1 parent 794bb02 commit aeebedf

File tree

75 files changed

+1798
-581
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1798
-581
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[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)
4+
5+
## AppBase.chromeless property
6+
7+
Hide the UI chrome when the application is mounted. Defaults to `false`<!-- -->. Takes precedence over chrome service visibility settings.
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
chromeless?: boolean;
13+
```

docs/development/core/public/kibana-plugin-public.appbase.id.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
## AppBase.id property
66

7+
The unique identifier of the application
8+
79
<b>Signature:</b>
810

911
```typescript

docs/development/core/public/kibana-plugin-public.appbase.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,14 @@ export interface AppBase
1616
| Property | Type | Description |
1717
| --- | --- | --- |
1818
| [capabilities](./kibana-plugin-public.appbase.capabilities.md) | <code>Partial&lt;Capabilities&gt;</code> | Custom capabilities defined by the app. |
19+
| [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. |
1920
| [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. |
2021
| [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. |
21-
| [id](./kibana-plugin-public.appbase.id.md) | <code>string</code> | |
22+
| [id](./kibana-plugin-public.appbase.id.md) | <code>string</code> | The unique identifier of the application |
23+
| [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) |
2224
| [order](./kibana-plugin-public.appbase.order.md) | <code>number</code> | An ordinal used to sort nav links relative to one another for display. |
25+
| [status](./kibana-plugin-public.appbase.status.md) | <code>AppStatus</code> | The initial status of the application. Defaulting to <code>accessible</code> |
2326
| [title](./kibana-plugin-public.appbase.title.md) | <code>string</code> | The title of the application. |
24-
| [tooltip$](./kibana-plugin-public.appbase.tooltip_.md) | <code>Observable&lt;string&gt;</code> | An observable for a tooltip shown when hovering over app link. |
27+
| [tooltip](./kibana-plugin-public.appbase.tooltip.md) | <code>string</code> | A tooltip shown when hovering over app link. |
28+
| [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. |
2529

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[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)
4+
5+
## AppBase.navLinkStatus property
6+
7+
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)
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
navLinkStatus?: AppNavLinkStatus;
13+
```
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
22

3-
[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)
3+
[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)
44

5-
## AppBase.tooltip$ property
5+
## AppBase.status property
66

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

99
<b>Signature:</b>
1010

1111
```typescript
12-
tooltip$?: Observable<string>;
12+
status?: AppStatus;
1313
```
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[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)
4+
5+
## AppBase.tooltip property
6+
7+
A tooltip shown when hovering over app link.
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
tooltip?: string;
13+
```
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[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)
4+
5+
## AppBase.updater$ property
6+
7+
An [AppUpdater](./kibana-plugin-public.appupdater.md) observable that can be used to update the application [AppUpdatableFields](./kibana-plugin-public.appupdatablefields.md) at runtime.
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
updater$?: Observable<AppUpdater>;
13+
```
14+
15+
## Example
16+
17+
How to update an application navLink at runtime
18+
19+
```ts
20+
// inside your plugin's setup function
21+
export class MyPlugin implements Plugin {
22+
private appUpdater = new BehaviorSubject<AppUpdater>(() => ({}));
23+
24+
setup({ application }) {
25+
application.register({
26+
id: 'my-app',
27+
title: 'My App',
28+
updater$: this.appUpdater,
29+
async mount(params) {
30+
const { renderApp } = await import('./application');
31+
return renderApp(params);
32+
},
33+
});
34+
}
35+
36+
start() {
37+
// later, when the navlink needs to be updated
38+
appUpdater.next(() => {
39+
navLinkStatus: AppNavLinkStatus.disabled,
40+
})
41+
}
42+
43+
```
44+

docs/development/core/public/kibana-plugin-public.applicationsetup.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ export interface ApplicationSetup
1616
| Method | Description |
1717
| --- | --- |
1818
| [register(app)](./kibana-plugin-public.applicationsetup.register.md) | Register an mountable application to the system. |
19+
| [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. |
1920
| [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)<!-- -->. |
2021

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[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)
4+
5+
## ApplicationSetup.registerAppUpdater() method
6+
7+
Register an application updater that can be used to change the [AppUpdatableFields](./kibana-plugin-public.appupdatablefields.md) fields of all applications at runtime.
8+
9+
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.
10+
11+
<b>Signature:</b>
12+
13+
```typescript
14+
registerAppUpdater(appUpdater$: Observable<AppUpdater>): void;
15+
```
16+
17+
## Parameters
18+
19+
| Parameter | Type | Description |
20+
| --- | --- | --- |
21+
| appUpdater$ | <code>Observable&lt;AppUpdater&gt;</code> | |
22+
23+
<b>Returns:</b>
24+
25+
`void`
26+
27+
## Example
28+
29+
How to register an application updater that disables some applications:
30+
31+
```ts
32+
// inside your plugin's setup function
33+
export class MyPlugin implements Plugin {
34+
setup({ application }) {
35+
application.registerAppUpdater(
36+
new BehaviorSubject<AppUpdater>(app => {
37+
if (myPluginApi.shouldDisable(app))
38+
return {
39+
status: AppStatus.inaccessible,
40+
};
41+
})
42+
);
43+
}
44+
}
45+
46+
```
47+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [AppNavLinkStatus](./kibana-plugin-public.appnavlinkstatus.md)
4+
5+
## AppNavLinkStatus enum
6+
7+
Status of the application's navLink.
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
export declare enum AppNavLinkStatus
13+
```
14+
15+
## Enumeration Members
16+
17+
| Member | Value | Description |
18+
| --- | --- | --- |
19+
| 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>. |
20+
| disabled | <code>2</code> | The application navLink is visible but inactive and not clickable in the navigation bar. |
21+
| hidden | <code>3</code> | The application navLink does not appear in the navigation bar. |
22+
| visible | <code>1</code> | The application navLink is visible and clickable in the navigation bar. |
23+

0 commit comments

Comments
 (0)