-
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
34 changed files
with
678 additions
and
413 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) | ||
|
15 changes: 15 additions & 0 deletions
15
...evelopment/core/public/kibana-plugin-public.overlaybannersstart.getcomponent.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,15 @@ | ||
<!-- 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) > [getComponent](./kibana-plugin-public.overlaybannersstart.getcomponent.md) | ||
|
||
## OverlayBannersStart.getComponent() method | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
getComponent(): JSX.Element; | ||
``` | ||
<b>Returns:</b> | ||
|
||
`JSX.Element` | ||
|
22 changes: 22 additions & 0 deletions
22
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,22 @@ | ||
<!-- 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 | | ||
| [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 | | ||
|
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
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,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(<BannersList banners$={new BehaviorSubject([])} />).html()).toEqual(null); | ||
}); | ||
|
||
test('renders a list of banners', () => { | ||
const banners$ = new BehaviorSubject<OverlayBanner[]>([ | ||
{ | ||
id: Symbol(), | ||
mount: (el: HTMLElement) => { | ||
el.innerHTML = '<h1>Hello!</h1>'; | ||
return () => (el.innerHTML = ''); | ||
}, | ||
priority: 0, | ||
}, | ||
]); | ||
|
||
expect(mount(<BannersList banners$={banners$} />).html()).toMatchInlineSnapshot( | ||
`"<div class=\\"kbnGlobalBannerList\\"><div data-test-priority=\\"0\\" class=\\"kbnGlobalBannerList__item\\"><h1>Hello!</h1></div></div>"` | ||
); | ||
}); | ||
|
||
test('updates banners', () => { | ||
const unmount = jest.fn(); | ||
const banners$ = new BehaviorSubject<OverlayBanner[]>([ | ||
{ | ||
id: Symbol(), | ||
mount: (el: HTMLElement) => { | ||
el.innerHTML = '<h1>Hello!</h1>'; | ||
return unmount; | ||
}, | ||
priority: 0, | ||
}, | ||
]); | ||
|
||
const component = mount(<BannersList banners$={banners$} />); | ||
|
||
act(() => { | ||
banners$.next([ | ||
{ | ||
id: Symbol(), | ||
mount: (el: HTMLElement) => { | ||
el.innerHTML = '<h1>First Banner!</h1>'; | ||
return () => (el.innerHTML = ''); | ||
}, | ||
priority: 0, | ||
}, | ||
{ | ||
id: Symbol(), | ||
mount: (el: HTMLElement) => { | ||
el.innerHTML = '<h1>Second banner!</h1>'; | ||
return () => (el.innerHTML = ''); | ||
}, | ||
priority: 0, | ||
}, | ||
]); | ||
}); | ||
|
||
// Two new banners should be rendered | ||
expect(component.html()).toMatchInlineSnapshot( | ||
`"<div class=\\"kbnGlobalBannerList\\"><div data-test-priority=\\"0\\" class=\\"kbnGlobalBannerList__item\\"><h1>First Banner!</h1></div><div data-test-priority=\\"0\\" class=\\"kbnGlobalBannerList__item\\"><h1>Second banner!</h1></div></div>"` | ||
); | ||
// Original banner should be unmounted | ||
expect(unmount).toHaveBeenCalled(); | ||
}); | ||
|
||
test('unsubscribe on unmount', () => { | ||
const banners$ = new BehaviorSubject([]); | ||
const subscribe = jest.spyOn(banners$, 'subscribe'); | ||
const component = mount(<BannersList banners$={banners$} />); | ||
// Grab the returned subscription and spy its `unsubscribe` method | ||
const subscription = subscribe.mock.results[0].value; | ||
const unsubscribe = jest.spyOn(subscription, 'unsubscribe'); | ||
|
||
component.unmount(); | ||
expect(unsubscribe).toHaveBeenCalled(); | ||
}); | ||
}); |
Oops, something went wrong.