PluginInitializer
. |
@@ -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 plugin
export at the root of a plugin's public
directory should conform to this interface. |
| [PluginOpaqueId](./kibana-plugin-public.pluginopaqueid.md) | |
| [RecursiveReadonly](./kibana-plugin-public.recursivereadonly.md) | |
diff --git a/docs/development/core/public/kibana-plugin-public.overlaybannermount.md b/docs/development/core/public/kibana-plugin-public.overlaybannermount.md
new file mode 100644
index 00000000000000..0fd0aca652cf0b
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.overlaybannermount.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [OverlayBannerMount](./kibana-plugin-public.overlaybannermount.md)
+
+## OverlayBannerMount type
+
+A function that will mount the banner inside the provided element.
+
+Signature:
+
+```typescript
+export declare type OverlayBannerMount = (element: HTMLElement) => OverlayBannerUnmount;
+```
diff --git a/docs/development/core/public/kibana-plugin-public.overlaybannersstart.add.md b/docs/development/core/public/kibana-plugin-public.overlaybannersstart.add.md
new file mode 100644
index 00000000000000..8c3e874804e082
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.overlaybannersstart.add.md
@@ -0,0 +1,27 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [OverlayBannersStart](./kibana-plugin-public.overlaybannersstart.md) > [add](./kibana-plugin-public.overlaybannersstart.add.md)
+
+## OverlayBannersStart.add() method
+
+Add a new banner
+
+Signature:
+
+```typescript
+add(mount: OverlayBannerMount, priority?: number): string;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| mount | OverlayBannerMount
| |
+| priority | number
| |
+
+Returns:
+
+`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)
+
diff --git a/docs/development/core/public/kibana-plugin-public.overlaybannersstart.getcomponent.md b/docs/development/core/public/kibana-plugin-public.overlaybannersstart.getcomponent.md
new file mode 100644
index 00000000000000..0ecb9862dee3dd
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.overlaybannersstart.getcomponent.md
@@ -0,0 +1,15 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [OverlayBannersStart](./kibana-plugin-public.overlaybannersstart.md) > [getComponent](./kibana-plugin-public.overlaybannersstart.getcomponent.md)
+
+## OverlayBannersStart.getComponent() method
+
+Signature:
+
+```typescript
+getComponent(): JSX.Element;
+```
+Returns:
+
+`JSX.Element`
+
diff --git a/docs/development/core/public/kibana-plugin-public.overlaybannersstart.md b/docs/development/core/public/kibana-plugin-public.overlaybannersstart.md
new file mode 100644
index 00000000000000..34e4ab85537924
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.overlaybannersstart.md
@@ -0,0 +1,22 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [OverlayBannersStart](./kibana-plugin-public.overlaybannersstart.md)
+
+## OverlayBannersStart interface
+
+
+Signature:
+
+```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 |
+
diff --git a/docs/development/core/public/kibana-plugin-public.overlaybannersstart.remove.md b/docs/development/core/public/kibana-plugin-public.overlaybannersstart.remove.md
new file mode 100644
index 00000000000000..4fc5cfcd1c8d0b
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.overlaybannersstart.remove.md
@@ -0,0 +1,26 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [OverlayBannersStart](./kibana-plugin-public.overlaybannersstart.md) > [remove](./kibana-plugin-public.overlaybannersstart.remove.md)
+
+## OverlayBannersStart.remove() method
+
+Remove a banner
+
+Signature:
+
+```typescript
+remove(id: string): boolean;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| id | string
| |
+
+Returns:
+
+`boolean`
+
+if the banner was found or not
+
diff --git a/docs/development/core/public/kibana-plugin-public.overlaybannersstart.replace.md b/docs/development/core/public/kibana-plugin-public.overlaybannersstart.replace.md
new file mode 100644
index 00000000000000..8f624c285b1800
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.overlaybannersstart.replace.md
@@ -0,0 +1,28 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [OverlayBannersStart](./kibana-plugin-public.overlaybannersstart.md) > [replace](./kibana-plugin-public.overlaybannersstart.replace.md)
+
+## OverlayBannersStart.replace() method
+
+Replace a banner in place
+
+Signature:
+
+```typescript
+replace(id: string | undefined, mount: OverlayBannerMount, priority?: number): string;
+```
+
+## Parameters
+
+| Parameter | Type | Description |
+| --- | --- | --- |
+| id | string | undefined
| |
+| mount | OverlayBannerMount
| |
+| priority | number
| |
+
+Returns:
+
+`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)
+
diff --git a/docs/development/core/public/kibana-plugin-public.overlaybannerunmount.md b/docs/development/core/public/kibana-plugin-public.overlaybannerunmount.md
new file mode 100644
index 00000000000000..c9a7c2b8fee929
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.overlaybannerunmount.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [OverlayBannerUnmount](./kibana-plugin-public.overlaybannerunmount.md)
+
+## OverlayBannerUnmount type
+
+A function that will unmount the banner from the element.
+
+Signature:
+
+```typescript
+export declare type OverlayBannerUnmount = () => void;
+```
diff --git a/docs/development/core/public/kibana-plugin-public.overlaystart.banners.md b/docs/development/core/public/kibana-plugin-public.overlaystart.banners.md
new file mode 100644
index 00000000000000..60ecc4b873f0d8
--- /dev/null
+++ b/docs/development/core/public/kibana-plugin-public.overlaystart.banners.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-public](./kibana-plugin-public.md) > [OverlayStart](./kibana-plugin-public.overlaystart.md) > [banners](./kibana-plugin-public.overlaystart.banners.md)
+
+## OverlayStart.banners property
+
+[OverlayBannersStart](./kibana-plugin-public.overlaybannersstart.md)
+
+Signature:
+
+```typescript
+banners: OverlayBannersStart;
+```
diff --git a/docs/development/core/public/kibana-plugin-public.overlaystart.md b/docs/development/core/public/kibana-plugin-public.overlaystart.md
index 1345beffbfb6ac..6bcf0a581df800 100644
--- a/docs/development/core/public/kibana-plugin-public.overlaystart.md
+++ b/docs/development/core/public/kibana-plugin-public.overlaystart.md
@@ -15,6 +15,7 @@ export interface OverlayStart
| Property | Type | Description |
| --- | --- | --- |
+| [banners](./kibana-plugin-public.overlaystart.banners.md) | OverlayBannersStart
| [OverlayBannersStart](./kibana-plugin-public.overlaybannersstart.md) |
| [openFlyout](./kibana-plugin-public.overlaystart.openflyout.md) | (flyoutChildren: React.ReactNode, flyoutProps?: {
closeButtonAriaLabel?: string;
'data-test-subj'?: string;
}) => OverlayRef
| |
| [openModal](./kibana-plugin-public.overlaystart.openmodal.md) | (modalChildren: React.ReactNode, modalProps?: {
className?: string;
closeButtonAriaLabel?: string;
'data-test-subj'?: string;
}) => OverlayRef
| |
diff --git a/src/core/public/core_system.test.ts b/src/core/public/core_system.test.ts
index 895fc785b11b1c..36a1393501ea3d 100644
--- a/src/core/public/core_system.test.ts
+++ b/src/core/public/core_system.test.ts
@@ -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),
});
});
diff --git a/src/core/public/core_system.ts b/src/core/public/core_system.ts
index 4eb16572d8fec1..7b9ed50f095910 100644
--- a/src/core/public/core_system.ts
+++ b/src/core/public/core_system.ts
@@ -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 });
@@ -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,
@@ -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']),
@@ -252,6 +256,7 @@ export class CoreSystem {
application,
chrome,
injectedMetadata,
+ overlays,
targetDomElement: coreUiTargetDomElement,
});
diff --git a/src/core/public/fatal_errors/fatal_errors_service.tsx b/src/core/public/fatal_errors/fatal_errors_service.tsx
index 6e9b9e8c825eac..5c6a7bb322ae1f 100644
--- a/src/core/public/fatal_errors/fatal_errors_service.tsx
+++ b/src/core/public/fatal_errors/fatal_errors_service.tsx
@@ -101,6 +101,8 @@ export class FatalErrorsService {
},
};
+ this.setupGlobalErrorHandlers(fatalErrorsSetup);
+
return fatalErrorsSetup;
}
@@ -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
+ });
+ }
+ }
}
diff --git a/src/core/public/index.scss b/src/core/public/index.scss
index 42a25aa686696a..86f2efdff77020 100644
--- a/src/core/public/index.scss
+++ b/src/core/public/index.scss
@@ -8,3 +8,4 @@
@import '@elastic/eui/src/global_styling/mixins/index';
@import './chrome/index';
+@import './overlays/index';
diff --git a/src/core/public/index.ts b/src/core/public/index.ts
index 89c309d8427d76..35d08bace111e2 100644
--- a/src/core/public/index.ts
+++ b/src/core/public/index.ts
@@ -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';
@@ -107,6 +107,14 @@ export {
HttpBody,
} from './http';
+export {
+ OverlayStart,
+ OverlayBannerMount,
+ OverlayBannerUnmount,
+ OverlayBannersStart,
+ OverlayRef,
+} from './overlays';
+
/**
* Core services exposed to the `Plugin` setup lifecycle
*
@@ -221,8 +229,6 @@ export {
LegacyNavLink,
NotificationsSetup,
NotificationsStart,
- OverlayRef,
- OverlayStart,
Plugin,
PluginInitializer,
PluginInitializerContext,
diff --git a/src/legacy/ui/public/notify/_index.scss b/src/core/public/overlays/_index.scss
similarity index 100%
rename from src/legacy/ui/public/notify/_index.scss
rename to src/core/public/overlays/_index.scss
diff --git a/src/legacy/ui/public/notify/banners/_global_banner_list.scss b/src/core/public/overlays/banners/_banners_list.scss
similarity index 100%
rename from src/legacy/ui/public/notify/banners/_global_banner_list.scss
rename to src/core/public/overlays/banners/_banners_list.scss
diff --git a/src/core/public/overlays/banners/_index.scss b/src/core/public/overlays/banners/_index.scss
new file mode 100644
index 00000000000000..c0c8056ff5d7d5
--- /dev/null
+++ b/src/core/public/overlays/banners/_index.scss
@@ -0,0 +1 @@
+@import './banners_list';
diff --git a/src/core/public/overlays/banners/banners_list.test.tsx b/src/core/public/overlays/banners/banners_list.test.tsx
new file mode 100644
index 00000000000000..dbee20790fa94e
--- /dev/null
+++ b/src/core/public/overlays/banners/banners_list.test.tsx
@@ -0,0 +1,105 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import React from 'react';
+import { act } from 'react-dom/test-utils';
+import { mount } from 'enzyme';
+
+import { BannersList } from './banners_list';
+import { BehaviorSubject } from 'rxjs';
+import { OverlayBanner } from './banners_service';
+
+describe('BannersList', () => {
+ test('renders null if no banners', () => {
+ expect(mount(