-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move ui/notify banners to New Platform
- Loading branch information
Showing
33 changed files
with
460 additions
and
439 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
docs/development/core/public/kibana-plugin-public.overlaybannermount.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) > [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. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export declare type OverlayBannerMount = (element: HTMLElement) => OverlayBannerUnmount; | ||
``` |
27 changes: 27 additions & 0 deletions
27
docs/development/core/public/kibana-plugin-public.overlaybannersstart.add.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) > [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 | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
add(mount: OverlayBannerMount, priority?: number): symbol; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| mount | <code>OverlayBannerMount</code> | | | ||
| priority | <code>number</code> | | | ||
|
||
<b>Returns:</b> | ||
|
||
`symbol` | ||
|
||
a unique symbol 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) | ||
|
21 changes: 21 additions & 0 deletions
21
docs/development/core/public/kibana-plugin-public.overlaybannersstart.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) > [kibana-plugin-public](./kibana-plugin-public.md) > [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 | | ||
| [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 | | ||
|
26 changes: 26 additions & 0 deletions
26
docs/development/core/public/kibana-plugin-public.overlaybannersstart.remove.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) > [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 | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
remove(id: symbol): boolean; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| id | <code>symbol</code> | | | ||
|
||
<b>Returns:</b> | ||
|
||
`boolean` | ||
|
||
if the banner was found or not | ||
|
28 changes: 28 additions & 0 deletions
28
docs/development/core/public/kibana-plugin-public.overlaybannersstart.replace.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) > [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 | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
replace(id: symbol, mount: OverlayBannerMount, priority?: number): symbol; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| id | <code>symbol</code> | | | ||
| mount | <code>OverlayBannerMount</code> | | | ||
| priority | <code>number</code> | | | ||
|
||
<b>Returns:</b> | ||
|
||
`symbol` | ||
|
||
a new symbol 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) | ||
|
13 changes: 13 additions & 0 deletions
13
docs/development/core/public/kibana-plugin-public.overlaybannerunmount.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) > [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. | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export declare type OverlayBannerUnmount = () => void; | ||
``` |
13 changes: 13 additions & 0 deletions
13
docs/development/core/public/kibana-plugin-public.overlaystart.banners.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) > [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) | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
banners: OverlayBannersStart; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ | |
@import '@elastic/eui/src/global_styling/mixins/index'; | ||
|
||
@import './chrome/index'; | ||
@import './overlays/index'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@import './banners_list'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* 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, { useEffect, useRef, useState } from 'react'; | ||
import { Observable } from 'rxjs'; | ||
|
||
import { OverlayBanner } from './banners_service'; | ||
|
||
interface Props { | ||
banners$: Observable<OverlayBanner[]>; | ||
} | ||
|
||
/** | ||
* BannersList is a list of "banners". A banner something that is displayed at the top of Kibana that may or may not | ||
* disappear. | ||
* | ||
* Whether or not a banner can be closed is completely up to the author of the banner. Some banners make sense to be | ||
* static, such as banners meant to indicate the sensitivity (e.g., classification) of the information being | ||
* represented. | ||
*/ | ||
export const BannersList: React.FunctionComponent<Props> = ({ banners$ }) => { | ||
const [banners, setBanners] = useState<OverlayBanner[]>([]); | ||
useEffect(() => { | ||
const subscription = banners$.subscribe(setBanners); | ||
return () => subscription.unsubscribe(); | ||
}, [banners$]); // Only un/re-subscribe if the Observable changes | ||
|
||
if (banners.length === 0) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className="kbnGlobalBannerList"> | ||
{banners.map((banner, idx) => ( | ||
<BannerItem key={idx} banner={banner} /> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
const BannerItem: React.FunctionComponent<{ banner: OverlayBanner }> = ({ banner }) => { | ||
const element = useRef(null); | ||
useEffect(() => banner.mount(element.current!)); | ||
|
||
return ( | ||
<div data-test-priority={banner.priority} className="kbnGlobalBannerList__item" ref={element} /> | ||
); | ||
}; |
Oops, something went wrong.