Skip to content

Commit

Permalink
Move ui/notify banners to New Platform (#43610)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshdover committed Sep 17, 2019
1 parent c171880 commit 812c950
Show file tree
Hide file tree
Showing 57 changed files with 1,243 additions and 576 deletions.
3 changes: 3 additions & 0 deletions docs/development/core/public/kibana-plugin-public.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [LegacyNavLink](./kibana-plugin-public.legacynavlink.md) | |
| [NotificationsSetup](./kibana-plugin-public.notificationssetup.md) | |
| [NotificationsStart](./kibana-plugin-public.notificationsstart.md) | |
| [OverlayBannersStart](./kibana-plugin-public.overlaybannersstart.md) | |
| [OverlayRef](./kibana-plugin-public.overlayref.md) | |
| [OverlayStart](./kibana-plugin-public.overlaystart.md) | |
| [Plugin](./kibana-plugin-public.plugin.md) | The interface that should be returned by a <code>PluginInitializer</code>. |
Expand Down Expand Up @@ -95,6 +96,8 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [HttpStart](./kibana-plugin-public.httpstart.md) | |
| [IContextHandler](./kibana-plugin-public.icontexthandler.md) | A function registered by a plugin to perform some action. |
| [IContextProvider](./kibana-plugin-public.icontextprovider.md) | A function that returns a context value for a specific key of given context type. |
| [OverlayBannerMount](./kibana-plugin-public.overlaybannermount.md) | A function that will mount the banner inside the provided element. |
| [OverlayBannerUnmount](./kibana-plugin-public.overlaybannerunmount.md) | A function that will unmount the banner from the element. |
| [PluginInitializer](./kibana-plugin-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-public.pluginopaqueid.md) | |
| [RecursiveReadonly](./kibana-plugin-public.recursivereadonly.md) | |
Expand Down
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; [OverlayBannerMount](./kibana-plugin-public.overlaybannermount.md)

## OverlayBannerMount type

A function that will mount the banner inside the provided element.

<b>Signature:</b>

```typescript
export declare type OverlayBannerMount = (element: HTMLElement) => OverlayBannerUnmount;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [OverlayBannersStart](./kibana-plugin-public.overlaybannersstart.md) &gt; [add](./kibana-plugin-public.overlaybannersstart.add.md)

## OverlayBannersStart.add() method

Add a new banner

<b>Signature:</b>

```typescript
add(mount: OverlayBannerMount, priority?: number): string;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| mount | <code>OverlayBannerMount</code> | |
| priority | <code>number</code> | |

<b>Returns:</b>

`string`

a unique identifier for the given banner to be used with [OverlayBannersStart.remove()](./kibana-plugin-public.overlaybannersstart.remove.md) and [OverlayBannersStart.replace()](./kibana-plugin-public.overlaybannersstart.replace.md)

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

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [OverlayBannersStart](./kibana-plugin-public.overlaybannersstart.md) &gt; [getComponent](./kibana-plugin-public.overlaybannersstart.getcomponent.md)

## OverlayBannersStart.getComponent() method

<b>Signature:</b>

```typescript
getComponent(): JSX.Element;
```
<b>Returns:</b>

`JSX.Element`

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

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

## OverlayBannersStart interface


<b>Signature:</b>

```typescript
export interface OverlayBannersStart
```

## Methods

| Method | Description |
| --- | --- |
| [add(mount, priority)](./kibana-plugin-public.overlaybannersstart.add.md) | Add a new banner |
| [getComponent()](./kibana-plugin-public.overlaybannersstart.getcomponent.md) | |
| [remove(id)](./kibana-plugin-public.overlaybannersstart.remove.md) | Remove a banner |
| [replace(id, mount, priority)](./kibana-plugin-public.overlaybannersstart.replace.md) | Replace a banner in place |

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

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [OverlayBannersStart](./kibana-plugin-public.overlaybannersstart.md) &gt; [remove](./kibana-plugin-public.overlaybannersstart.remove.md)

## OverlayBannersStart.remove() method

Remove a banner

<b>Signature:</b>

```typescript
remove(id: string): boolean;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| id | <code>string</code> | |

<b>Returns:</b>

`boolean`

if the banner was found or not

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

[Home](./index.md) &gt; [kibana-plugin-public](./kibana-plugin-public.md) &gt; [OverlayBannersStart](./kibana-plugin-public.overlaybannersstart.md) &gt; [replace](./kibana-plugin-public.overlaybannersstart.replace.md)

## OverlayBannersStart.replace() method

Replace a banner in place

<b>Signature:</b>

```typescript
replace(id: string | undefined, mount: OverlayBannerMount, priority?: number): string;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| id | <code>string &#124; undefined</code> | |
| mount | <code>OverlayBannerMount</code> | |
| priority | <code>number</code> | |

<b>Returns:</b>

`string`

a new identifier for the given banner to be used with [OverlayBannersStart.remove()](./kibana-plugin-public.overlaybannersstart.remove.md) and [OverlayBannersStart.replace()](./kibana-plugin-public.overlaybannersstart.replace.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; [OverlayBannerUnmount](./kibana-plugin-public.overlaybannerunmount.md)

## OverlayBannerUnmount type

A function that will unmount the banner from the element.

<b>Signature:</b>

```typescript
export declare type OverlayBannerUnmount = () => void;
```
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; [OverlayStart](./kibana-plugin-public.overlaystart.md) &gt; [banners](./kibana-plugin-public.overlaystart.banners.md)

## OverlayStart.banners property

[OverlayBannersStart](./kibana-plugin-public.overlaybannersstart.md)

<b>Signature:</b>

```typescript
banners: OverlayBannersStart;
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface OverlayStart

| Property | Type | Description |
| --- | --- | --- |
| [banners](./kibana-plugin-public.overlaystart.banners.md) | <code>OverlayBannersStart</code> | [OverlayBannersStart](./kibana-plugin-public.overlaybannersstart.md) |
| [openFlyout](./kibana-plugin-public.overlaystart.openflyout.md) | <code>(flyoutChildren: React.ReactNode, flyoutProps?: {</code><br/><code> closeButtonAriaLabel?: string;</code><br/><code> 'data-test-subj'?: string;</code><br/><code> }) =&gt; OverlayRef</code> | |
| [openModal](./kibana-plugin-public.overlaystart.openmodal.md) | <code>(modalChildren: React.ReactNode, modalProps?: {</code><br/><code> className?: string;</code><br/><code> closeButtonAriaLabel?: string;</code><br/><code> 'data-test-subj'?: string;</code><br/><code> }) =&gt; OverlayRef</code> | |

1 change: 1 addition & 0 deletions src/core/public/core_system.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ describe('#start()', () => {
application: expect.any(Object),
chrome: expect.any(Object),
injectedMetadata: expect.any(Object),
overlays: expect.any(Object),
targetDomElement: expect.any(HTMLElement),
});
});
Expand Down
9 changes: 7 additions & 2 deletions src/core/public/core_system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export class CoreSystem {
public async start() {
try {
const injectedMetadata = await this.injectedMetadata.start();
const uiSettings = await this.uiSettings.start();
const docLinks = await this.docLinks.start({ injectedMetadata });
const http = await this.http.start({ injectedMetadata, fatalErrors: this.fatalErrorsSetup });
const savedObjects = await this.savedObjects.start({ http });
Expand All @@ -208,7 +209,11 @@ export class CoreSystem {
this.rootDomElement.appendChild(notificationsTargetDomElement);
this.rootDomElement.appendChild(overlayTargetDomElement);

const overlays = this.overlay.start({ i18n, targetDomElement: overlayTargetDomElement });
const overlays = this.overlay.start({
i18n,
targetDomElement: overlayTargetDomElement,
uiSettings,
});
const notifications = await this.notifications.start({
i18n,
overlays,
Expand All @@ -221,7 +226,6 @@ export class CoreSystem {
injectedMetadata,
notifications,
});
const uiSettings = await this.uiSettings.start();

application.registerMountContext(this.coreContext.coreId, 'core', () => ({
application: pick(application, ['capabilities', 'navigateToApp']),
Expand Down Expand Up @@ -252,6 +256,7 @@ export class CoreSystem {
application,
chrome,
injectedMetadata,
overlays,
targetDomElement: coreUiTargetDomElement,
});

Expand Down
10 changes: 10 additions & 0 deletions src/core/public/fatal_errors/fatal_errors_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ export class FatalErrorsService {
},
};

this.setupGlobalErrorHandlers(fatalErrorsSetup);

return fatalErrorsSetup;
}

Expand All @@ -123,4 +125,12 @@ export class FatalErrorsService {
container
);
}

private setupGlobalErrorHandlers(fatalErrorsSetup: FatalErrorsSetup) {
if (window.addEventListener) {
window.addEventListener('unhandledrejection', function(e) {
console.log(`Detected an unhandled Promise rejection.\n${e.reason}`); // eslint-disable-line no-console
});
}
}
}
1 change: 1 addition & 0 deletions src/core/public/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
@import '@elastic/eui/src/global_styling/mixins/index';

@import './chrome/index';
@import './overlays/index';
12 changes: 9 additions & 3 deletions src/core/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import {
ToastInput,
ToastsApi,
} from './notifications';
import { OverlayRef, OverlayStart } from './overlays';
import { OverlayStart } from './overlays';
import { Plugin, PluginInitializer, PluginInitializerContext, PluginOpaqueId } from './plugins';
import { UiSettingsClient, UiSettingsState, UiSettingsClientContract } from './ui_settings';
import { ApplicationSetup, Capabilities, ApplicationStart } from './application';
Expand Down Expand Up @@ -107,6 +107,14 @@ export {
HttpBody,
} from './http';

export {
OverlayStart,
OverlayBannerMount,
OverlayBannerUnmount,
OverlayBannersStart,
OverlayRef,
} from './overlays';

/**
* Core services exposed to the `Plugin` setup lifecycle
*
Expand Down Expand Up @@ -221,8 +229,6 @@ export {
LegacyNavLink,
NotificationsSetup,
NotificationsStart,
OverlayRef,
OverlayStart,
Plugin,
PluginInitializer,
PluginInitializerContext,
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/core/public/overlays/banners/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import './banners_list';
Loading

0 comments on commit 812c950

Please sign in to comment.