Skip to content

Commit

Permalink
use new Mount types for OverlayBanner apis
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Nov 1, 2019
1 parent ab81138 commit 081f878
Show file tree
Hide file tree
Showing 10 changed files with 1,009 additions and 1,067 deletions.
2 changes: 0 additions & 2 deletions docs/development/core/public/kibana-plugin-public.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [IContextProvider](./kibana-plugin-public.icontextprovider.md) | A function that returns a context value for a specific key of given context type. |
| [IToasts](./kibana-plugin-public.itoasts.md) | Methods for adding and removing global toast messages. See [ToastsApi](./kibana-plugin-public.toastsapi.md)<!-- -->. |
| [MountPoint](./kibana-plugin-public.mountpoint.md) | A function that will should mount DOM content inside the provided container element and return a handler to unmount it. |
| [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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ Add a new banner
<b>Signature:</b>

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

## Parameters

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

<b>Returns:</b>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ Replace a banner in place
<b>Signature:</b>

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

## Parameters

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

<b>Returns:</b>
Expand Down

This file was deleted.

8 changes: 1 addition & 7 deletions src/core/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,7 @@ export {
InterceptedHttpResponse,
} from './http';

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

export {
Toast,
Expand Down
27 changes: 7 additions & 20 deletions src/core/public/overlays/banners/banners_service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,20 @@ import { PriorityMap } from './priority_map';
import { BannersList } from './banners_list';
import { UiSettingsClientContract } from '../../ui_settings';
import { I18nStart } from '../../i18n';
import { MountPoint } from '../../types';
import { UserBannerService } from './user_banner_service';

/**
* A function that will unmount the banner from the element.
* @public
*/
export type OverlayBannerUnmount = () => void;

/**
* A function that will mount the banner inside the provided element.
* @param element an element to render into
* @returns a {@link OverlayBannerUnmount}
* @public
*/
export type OverlayBannerMount = (element: HTMLElement) => OverlayBannerUnmount;

/** @public */
export interface OverlayBannersStart {
/**
* Add a new banner
*
* @param mount {@link OverlayBannerMount}
* @param mount {@link MountPoint}
* @param priority optional priority order to display this banner. Higher priority values are shown first.
* @returns a unique identifier for the given banner to be used with {@link OverlayBannersStart.remove} and
* {@link OverlayBannersStart.replace}
*/
add(mount: OverlayBannerMount, priority?: number): string;
add(mount: MountPoint, priority?: number): string;

/**
* Remove a banner
Expand All @@ -65,12 +52,12 @@ export interface OverlayBannersStart {
* Replace a banner in place
*
* @param id the unique identifier for the banner returned by {@link OverlayBannersStart.add}
* @param mount {@link OverlayBannerMount}
* @param mount {@link MountPoint}
* @param priority optional priority order to display this banner. Higher priority values are shown first.
* @returns a new identifier for the given banner to be used with {@link OverlayBannersStart.remove} and
* {@link OverlayBannersStart.replace}
*/
replace(id: string | undefined, mount: OverlayBannerMount, priority?: number): string;
replace(id: string | undefined, mount: MountPoint, priority?: number): string;

/** @internal */
get$(): Observable<OverlayBanner[]>;
Expand All @@ -80,7 +67,7 @@ export interface OverlayBannersStart {
/** @internal */
export interface OverlayBanner {
readonly id: string;
readonly mount: OverlayBannerMount;
readonly mount: MountPoint;
readonly priority: number;
}

Expand Down Expand Up @@ -116,7 +103,7 @@ export class OverlayBannersService {
return true;
},

replace(id: string | undefined, mount: OverlayBannerMount, priority = 0) {
replace(id: string | undefined, mount: MountPoint, priority = 0) {
if (!id || !banners$.value.has(id)) {
return this.add(mount, priority);
}
Expand Down
7 changes: 1 addition & 6 deletions src/core/public/overlays/banners/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,4 @@
* under the License.
*/

export {
OverlayBannerMount,
OverlayBannerUnmount,
OverlayBannersStart,
OverlayBannersService,
} from './banners_service';
export { OverlayBannersStart, OverlayBannersService } from './banners_service';
2 changes: 1 addition & 1 deletion src/core/public/overlays/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
* under the License.
*/

export { OverlayBannerMount, OverlayBannerUnmount, OverlayBannersStart } from './banners';
export { OverlayBannersStart } from './banners';
export { OverlayService, OverlayStart, OverlayRef } from './overlay_service';
Loading

0 comments on commit 081f878

Please sign in to comment.