From 1d1bd9b1f536d47441227edd1fe5370d22d9e5de Mon Sep 17 00:00:00 2001 From: Liza K Date: Thu, 19 Mar 2020 00:26:16 +0200 Subject: [PATCH 1/7] addInfo toast --- .../notifications/toasts/toasts_api.test.ts | 14 ++++++++++++++ .../public/notifications/toasts/toasts_api.tsx | 18 +++++++++++++++++- .../index_management/__mocks__/ui/notify.js | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/core/public/notifications/toasts/toasts_api.test.ts b/src/core/public/notifications/toasts/toasts_api.test.ts index a0e419e989657..7fa200dd7a111 100644 --- a/src/core/public/notifications/toasts/toasts_api.test.ts +++ b/src/core/public/notifications/toasts/toasts_api.test.ts @@ -146,6 +146,20 @@ describe('#remove()', () => { }); }); +describe('#addInfo()', () => { + it('adds a info toast', async () => { + const toasts = new ToastsApi(toastDeps()); + expect(toasts.addInfo({})).toHaveProperty('color', 'primary'); + }); + + it('returns the created toast', async () => { + const toasts = new ToastsApi(toastDeps()); + const toast = toasts.addInfo({}); + const currentToasts = await getCurrentToasts(toasts); + expect(currentToasts[0]).toBe(toast); + }); +}); + describe('#addSuccess()', () => { it('adds a success toast', async () => { const toasts = new ToastsApi(toastDeps()); diff --git a/src/core/public/notifications/toasts/toasts_api.tsx b/src/core/public/notifications/toasts/toasts_api.tsx index 8b1850ff9508f..459f09487439f 100644 --- a/src/core/public/notifications/toasts/toasts_api.tsx +++ b/src/core/public/notifications/toasts/toasts_api.tsx @@ -84,7 +84,7 @@ const normalizeToast = (toastOrTitle: ToastInput): ToastInputFields => { */ export type IToasts = Pick< ToastsApi, - 'get$' | 'add' | 'remove' | 'addSuccess' | 'addWarning' | 'addDanger' | 'addError' + 'get$' | 'add' | 'remove' | 'addSuccess' | 'addWarning' | 'addDanger' | 'addError' | 'addInfo' >; /** @@ -145,6 +145,22 @@ export class ToastsApi implements IToasts { } } + /** + * Adds a new toast pre-configured with the info color and info icon. + * + * @param toastOrTitle - a {@link ToastInput} + * @param toastLifeTimeMs - a {@link number} + * @returns a {@link Toast} + */ + public addInfo(toastOrTitle: ToastInput, toastLifeTimeMs?: number) { + return this.add({ + color: 'primary', + iconType: 'iInCircle', + ...normalizeToast(toastOrTitle), + toastLifeTimeMs, + }); + } + /** * Adds a new toast pre-configured with the success color and check icon. * diff --git a/x-pack/plugins/index_management/__mocks__/ui/notify.js b/x-pack/plugins/index_management/__mocks__/ui/notify.js index d508c3383d5f9..3d64a99232bc3 100644 --- a/x-pack/plugins/index_management/__mocks__/ui/notify.js +++ b/x-pack/plugins/index_management/__mocks__/ui/notify.js @@ -5,6 +5,7 @@ */ export const toastNotifications = { + addInfo: () => {}, addSuccess: () => {}, addDanger: () => {}, addWarning: () => {}, From 372525ea621c1a92faafa811e7885c39bec1059e Mon Sep 17 00:00:00 2001 From: Liza K Date: Thu, 19 Mar 2020 00:31:57 +0200 Subject: [PATCH 2/7] md files --- .../kibana-plugin-core-public.itoasts.md | 2 +- ...na-plugin-core-public.toastsapi.addinfo.md | 27 +++++++++++++++++++ .../kibana-plugin-core-public.toastsapi.md | 1 + src/core/public/public.api.md | 4 ++- 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 docs/development/core/public/kibana-plugin-core-public.toastsapi.addinfo.md diff --git a/docs/development/core/public/kibana-plugin-core-public.itoasts.md b/docs/development/core/public/kibana-plugin-core-public.itoasts.md index 305ed82ea5693..e009c77fe23bc 100644 --- a/docs/development/core/public/kibana-plugin-core-public.itoasts.md +++ b/docs/development/core/public/kibana-plugin-core-public.itoasts.md @@ -9,5 +9,5 @@ Methods for adding and removing global toast messages. See [ToastsApi](./kibana- Signature: ```typescript -export declare type IToasts = Pick; +export declare type IToasts = Pick; ``` diff --git a/docs/development/core/public/kibana-plugin-core-public.toastsapi.addinfo.md b/docs/development/core/public/kibana-plugin-core-public.toastsapi.addinfo.md new file mode 100644 index 0000000000000..c7ef7a3e5f6eb --- /dev/null +++ b/docs/development/core/public/kibana-plugin-core-public.toastsapi.addinfo.md @@ -0,0 +1,27 @@ + + +[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [ToastsApi](./kibana-plugin-core-public.toastsapi.md) > [addInfo](./kibana-plugin-core-public.toastsapi.addinfo.md) + +## ToastsApi.addInfo() method + +Adds a new toast pre-configured with the info color and info icon. + +Signature: + +```typescript +addInfo(toastOrTitle: ToastInput, toastLifeTimeMs?: number): Toast; +``` + +## Parameters + +| Parameter | Type | Description | +| --- | --- | --- | +| toastOrTitle | ToastInput | a [ToastInput](./kibana-plugin-core-public.toastinput.md) | +| toastLifeTimeMs | number | a | + +Returns: + +`Toast` + +a [Toast](./kibana-plugin-core-public.toast.md) + diff --git a/docs/development/core/public/kibana-plugin-core-public.toastsapi.md b/docs/development/core/public/kibana-plugin-core-public.toastsapi.md index 4aa240fba0061..8160f335617b8 100644 --- a/docs/development/core/public/kibana-plugin-core-public.toastsapi.md +++ b/docs/development/core/public/kibana-plugin-core-public.toastsapi.md @@ -25,6 +25,7 @@ export declare class ToastsApi implements IToasts | [add(toastOrTitle)](./kibana-plugin-core-public.toastsapi.add.md) | | Adds a new toast to current array of toast. | | [addDanger(toastOrTitle)](./kibana-plugin-core-public.toastsapi.adddanger.md) | | Adds a new toast pre-configured with the danger color and alert icon. | | [addError(error, options)](./kibana-plugin-core-public.toastsapi.adderror.md) | | Adds a new toast that displays an exception message with a button to open the full stacktrace in a modal. | +| [addInfo(toastOrTitle, toastLifeTimeMs)](./kibana-plugin-core-public.toastsapi.addinfo.md) | | Adds a new toast pre-configured with the info color and info icon. | | [addSuccess(toastOrTitle)](./kibana-plugin-core-public.toastsapi.addsuccess.md) | | Adds a new toast pre-configured with the success color and check icon. | | [addWarning(toastOrTitle)](./kibana-plugin-core-public.toastsapi.addwarning.md) | | Adds a new toast pre-configured with the warning color and help icon. | | [get$()](./kibana-plugin-core-public.toastsapi.get_.md) | | Observable of the toast messages to show to the user. | diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md index 7428280b2dccb..f86e60d765950 100644 --- a/src/core/public/public.api.md +++ b/src/core/public/public.api.md @@ -778,7 +778,7 @@ export interface ImageValidation { } // @public -export type IToasts = Pick; +export type IToasts = Pick; // @public export interface IUiSettingsClient { @@ -1278,6 +1278,8 @@ export class ToastsApi implements IToasts { add(toastOrTitle: ToastInput): Toast; addDanger(toastOrTitle: ToastInput): Toast; addError(error: Error, options: ErrorToastOptions): Toast; + // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "number" + addInfo(toastOrTitle: ToastInput, toastLifeTimeMs?: number): Toast; addSuccess(toastOrTitle: ToastInput): Toast; addWarning(toastOrTitle: ToastInput): Toast; get$(): Rx.Observable; From f7df4e78599d40c4e39b0108a4882816908ad21b Mon Sep 17 00:00:00 2001 From: Liza K Date: Thu, 19 Mar 2020 11:52:00 +0200 Subject: [PATCH 3/7] fis types --- src/core/public/notifications/toasts/toasts_service.mock.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/public/notifications/toasts/toasts_service.mock.ts b/src/core/public/notifications/toasts/toasts_service.mock.ts index f44bd3253048d..2eb9cea7eb5c3 100644 --- a/src/core/public/notifications/toasts/toasts_service.mock.ts +++ b/src/core/public/notifications/toasts/toasts_service.mock.ts @@ -25,6 +25,7 @@ const createToastsApiMock = () => { get$: jest.fn(() => new Observable()), add: jest.fn(), remove: jest.fn(), + addInfo: jest.fn(), addSuccess: jest.fn(), addWarning: jest.fn(), addDanger: jest.fn(), From 685b69c776959c4bf9ec1a7d1c235096cee0b8ee Mon Sep 17 00:00:00 2001 From: Liza K Date: Thu, 19 Mar 2020 12:12:01 +0200 Subject: [PATCH 4/7] Added options to toast methods --- ...na-plugin-core-public.errortoastoptions.md | 4 +-- .../core/public/kibana-plugin-core-public.md | 2 +- ...-plugin-core-public.toastsapi.adddanger.md | 3 +- ...na-plugin-core-public.toastsapi.addinfo.md | 4 +-- ...plugin-core-public.toastsapi.addsuccess.md | 3 +- ...plugin-core-public.toastsapi.addwarning.md | 3 +- .../kibana-plugin-core-public.toastsapi.md | 8 ++--- .../notifications/toasts/toasts_api.tsx | 33 ++++++++++++++----- src/core/public/public.api.md | 17 ++++++---- 9 files changed, 51 insertions(+), 26 deletions(-) diff --git a/docs/development/core/public/kibana-plugin-core-public.errortoastoptions.md b/docs/development/core/public/kibana-plugin-core-public.errortoastoptions.md index cda64018c3f69..dc256e6f5bc06 100644 --- a/docs/development/core/public/kibana-plugin-core-public.errortoastoptions.md +++ b/docs/development/core/public/kibana-plugin-core-public.errortoastoptions.md @@ -4,12 +4,12 @@ ## ErrorToastOptions interface -Options available for [IToasts](./kibana-plugin-core-public.itoasts.md) APIs. +Options available for [IToasts](./kibana-plugin-core-public.itoasts.md) error APIs. Signature: ```typescript -export interface ErrorToastOptions +export interface ErrorToastOptions extends ToastOptions ``` ## Properties diff --git a/docs/development/core/public/kibana-plugin-core-public.md b/docs/development/core/public/kibana-plugin-core-public.md index a9fbaa25ea150..d217f82aa170f 100644 --- a/docs/development/core/public/kibana-plugin-core-public.md +++ b/docs/development/core/public/kibana-plugin-core-public.md @@ -57,7 +57,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | [CoreStart](./kibana-plugin-core-public.corestart.md) | Core services exposed to the Plugin start lifecycle | | [DocLinksStart](./kibana-plugin-core-public.doclinksstart.md) | | | [EnvironmentMode](./kibana-plugin-core-public.environmentmode.md) | | -| [ErrorToastOptions](./kibana-plugin-core-public.errortoastoptions.md) | Options available for [IToasts](./kibana-plugin-core-public.itoasts.md) APIs. | +| [ErrorToastOptions](./kibana-plugin-core-public.errortoastoptions.md) | Options available for [IToasts](./kibana-plugin-core-public.itoasts.md) error APIs. | | [FatalErrorInfo](./kibana-plugin-core-public.fatalerrorinfo.md) | Represents the message and stack of a fatal Error | | [FatalErrorsSetup](./kibana-plugin-core-public.fatalerrorssetup.md) | FatalErrors stop the Kibana Public Core and displays a fatal error screen with details about the Kibana build and the error. | | [HttpFetchOptions](./kibana-plugin-core-public.httpfetchoptions.md) | All options that may be used with a [HttpHandler](./kibana-plugin-core-public.httphandler.md). | diff --git a/docs/development/core/public/kibana-plugin-core-public.toastsapi.adddanger.md b/docs/development/core/public/kibana-plugin-core-public.toastsapi.adddanger.md index e8cc9ff74e0c4..f918f0bf8de1d 100644 --- a/docs/development/core/public/kibana-plugin-core-public.toastsapi.adddanger.md +++ b/docs/development/core/public/kibana-plugin-core-public.toastsapi.adddanger.md @@ -9,7 +9,7 @@ Adds a new toast pre-configured with the danger color and alert icon. Signature: ```typescript -addDanger(toastOrTitle: ToastInput): Toast; +addDanger(toastOrTitle: ToastInput, options?: ToastOptions): Toast; ``` ## Parameters @@ -17,6 +17,7 @@ addDanger(toastOrTitle: ToastInput): Toast; | Parameter | Type | Description | | --- | --- | --- | | toastOrTitle | ToastInput | a [ToastInput](./kibana-plugin-core-public.toastinput.md) | +| options | ToastOptions | a | Returns: diff --git a/docs/development/core/public/kibana-plugin-core-public.toastsapi.addinfo.md b/docs/development/core/public/kibana-plugin-core-public.toastsapi.addinfo.md index c7ef7a3e5f6eb..bbc80c2dc4c86 100644 --- a/docs/development/core/public/kibana-plugin-core-public.toastsapi.addinfo.md +++ b/docs/development/core/public/kibana-plugin-core-public.toastsapi.addinfo.md @@ -9,7 +9,7 @@ Adds a new toast pre-configured with the info color and info icon. Signature: ```typescript -addInfo(toastOrTitle: ToastInput, toastLifeTimeMs?: number): Toast; +addInfo(toastOrTitle: ToastInput, options?: ToastOptions): Toast; ``` ## Parameters @@ -17,7 +17,7 @@ addInfo(toastOrTitle: ToastInput, toastLifeTimeMs?: number): Toast; | Parameter | Type | Description | | --- | --- | --- | | toastOrTitle | ToastInput | a [ToastInput](./kibana-plugin-core-public.toastinput.md) | -| toastLifeTimeMs | number | a | +| options | ToastOptions | a | Returns: diff --git a/docs/development/core/public/kibana-plugin-core-public.toastsapi.addsuccess.md b/docs/development/core/public/kibana-plugin-core-public.toastsapi.addsuccess.md index 160cbd4bf6b29..071ec3d2da143 100644 --- a/docs/development/core/public/kibana-plugin-core-public.toastsapi.addsuccess.md +++ b/docs/development/core/public/kibana-plugin-core-public.toastsapi.addsuccess.md @@ -9,7 +9,7 @@ Adds a new toast pre-configured with the success color and check icon. Signature: ```typescript -addSuccess(toastOrTitle: ToastInput): Toast; +addSuccess(toastOrTitle: ToastInput, options?: ToastOptions): Toast; ``` ## Parameters @@ -17,6 +17,7 @@ addSuccess(toastOrTitle: ToastInput): Toast; | Parameter | Type | Description | | --- | --- | --- | | toastOrTitle | ToastInput | a [ToastInput](./kibana-plugin-core-public.toastinput.md) | +| options | ToastOptions | a | Returns: diff --git a/docs/development/core/public/kibana-plugin-core-public.toastsapi.addwarning.md b/docs/development/core/public/kibana-plugin-core-public.toastsapi.addwarning.md index 17f94cc5b4553..5f8adb534521b 100644 --- a/docs/development/core/public/kibana-plugin-core-public.toastsapi.addwarning.md +++ b/docs/development/core/public/kibana-plugin-core-public.toastsapi.addwarning.md @@ -9,7 +9,7 @@ Adds a new toast pre-configured with the warning color and help icon. Signature: ```typescript -addWarning(toastOrTitle: ToastInput): Toast; +addWarning(toastOrTitle: ToastInput, options?: ToastOptions): Toast; ``` ## Parameters @@ -17,6 +17,7 @@ addWarning(toastOrTitle: ToastInput): Toast; | Parameter | Type | Description | | --- | --- | --- | | toastOrTitle | ToastInput | a [ToastInput](./kibana-plugin-core-public.toastinput.md) | +| options | ToastOptions | a | Returns: diff --git a/docs/development/core/public/kibana-plugin-core-public.toastsapi.md b/docs/development/core/public/kibana-plugin-core-public.toastsapi.md index 8160f335617b8..ca4c08989128a 100644 --- a/docs/development/core/public/kibana-plugin-core-public.toastsapi.md +++ b/docs/development/core/public/kibana-plugin-core-public.toastsapi.md @@ -23,11 +23,11 @@ export declare class ToastsApi implements IToasts | Method | Modifiers | Description | | --- | --- | --- | | [add(toastOrTitle)](./kibana-plugin-core-public.toastsapi.add.md) | | Adds a new toast to current array of toast. | -| [addDanger(toastOrTitle)](./kibana-plugin-core-public.toastsapi.adddanger.md) | | Adds a new toast pre-configured with the danger color and alert icon. | +| [addDanger(toastOrTitle, options)](./kibana-plugin-core-public.toastsapi.adddanger.md) | | Adds a new toast pre-configured with the danger color and alert icon. | | [addError(error, options)](./kibana-plugin-core-public.toastsapi.adderror.md) | | Adds a new toast that displays an exception message with a button to open the full stacktrace in a modal. | -| [addInfo(toastOrTitle, toastLifeTimeMs)](./kibana-plugin-core-public.toastsapi.addinfo.md) | | Adds a new toast pre-configured with the info color and info icon. | -| [addSuccess(toastOrTitle)](./kibana-plugin-core-public.toastsapi.addsuccess.md) | | Adds a new toast pre-configured with the success color and check icon. | -| [addWarning(toastOrTitle)](./kibana-plugin-core-public.toastsapi.addwarning.md) | | Adds a new toast pre-configured with the warning color and help icon. | +| [addInfo(toastOrTitle, options)](./kibana-plugin-core-public.toastsapi.addinfo.md) | | Adds a new toast pre-configured with the info color and info icon. | +| [addSuccess(toastOrTitle, options)](./kibana-plugin-core-public.toastsapi.addsuccess.md) | | Adds a new toast pre-configured with the success color and check icon. | +| [addWarning(toastOrTitle, options)](./kibana-plugin-core-public.toastsapi.addwarning.md) | | Adds a new toast pre-configured with the warning color and help icon. | | [get$()](./kibana-plugin-core-public.toastsapi.get_.md) | | Observable of the toast messages to show to the user. | | [remove(toastOrId)](./kibana-plugin-core-public.toastsapi.remove.md) | | Removes a toast from the current array of toasts if present. | diff --git a/src/core/public/notifications/toasts/toasts_api.tsx b/src/core/public/notifications/toasts/toasts_api.tsx index 459f09487439f..53717b9c2e174 100644 --- a/src/core/public/notifications/toasts/toasts_api.tsx +++ b/src/core/public/notifications/toasts/toasts_api.tsx @@ -55,7 +55,18 @@ export type ToastInput = string | ToastInputFields; * Options available for {@link IToasts} APIs. * @public */ -export interface ErrorToastOptions { +export interface ToastOptions { + /** + * How long should the toast remain on screen. + */ + toastLifeTimeMs?: number; +} + +/** + * Options available for {@link IToasts} error APIs. + * @public + */ +export interface ErrorToastOptions extends ToastOptions { /** * The title of the toast and the dialog when expanding the message. */ @@ -149,15 +160,15 @@ export class ToastsApi implements IToasts { * Adds a new toast pre-configured with the info color and info icon. * * @param toastOrTitle - a {@link ToastInput} - * @param toastLifeTimeMs - a {@link number} + * @param options - a {@link ToastOptions} * @returns a {@link Toast} */ - public addInfo(toastOrTitle: ToastInput, toastLifeTimeMs?: number) { + public addInfo(toastOrTitle: ToastInput, options?: ToastOptions) { return this.add({ color: 'primary', iconType: 'iInCircle', ...normalizeToast(toastOrTitle), - toastLifeTimeMs, + ...options, }); } @@ -165,13 +176,15 @@ export class ToastsApi implements IToasts { * Adds a new toast pre-configured with the success color and check icon. * * @param toastOrTitle - a {@link ToastInput} + * @param options - a {@link ToastOptions} * @returns a {@link Toast} */ - public addSuccess(toastOrTitle: ToastInput) { + public addSuccess(toastOrTitle: ToastInput, options?: ToastOptions) { return this.add({ color: 'success', iconType: 'check', ...normalizeToast(toastOrTitle), + ...options, }); } @@ -179,14 +192,16 @@ export class ToastsApi implements IToasts { * Adds a new toast pre-configured with the warning color and help icon. * * @param toastOrTitle - a {@link ToastInput} + * @param options - a {@link ToastOptions} * @returns a {@link Toast} */ - public addWarning(toastOrTitle: ToastInput) { + public addWarning(toastOrTitle: ToastInput, options?: ToastOptions) { return this.add({ color: 'warning', iconType: 'help', toastLifeTimeMs: this.uiSettings.get('notifications:lifetime:warning'), ...normalizeToast(toastOrTitle), + ...options, }); } @@ -194,14 +209,16 @@ export class ToastsApi implements IToasts { * Adds a new toast pre-configured with the danger color and alert icon. * * @param toastOrTitle - a {@link ToastInput} + * @param options - a {@link ToastOptions} * @returns a {@link Toast} */ - public addDanger(toastOrTitle: ToastInput) { + public addDanger(toastOrTitle: ToastInput, options?: ToastOptions) { return this.add({ color: 'danger', iconType: 'alert', toastLifeTimeMs: this.uiSettings.get('notifications:lifetime:warning'), ...normalizeToast(toastOrTitle), + ...options, }); } @@ -217,7 +234,6 @@ export class ToastsApi implements IToasts { return this.add({ color: 'danger', iconType: 'alert', - title: options.title, toastLifeTimeMs: this.uiSettings.get('notifications:lifetime:error'), text: mountReactNode( this.i18n!.Context} /> ), + ...options, }); } diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md index f86e60d765950..1522d412e16bd 100644 --- a/src/core/public/public.api.md +++ b/src/core/public/public.api.md @@ -560,8 +560,10 @@ export interface EnvironmentMode { prod: boolean; } +// Warning: (ae-forgotten-export) The symbol "ToastOptions" needs to be exported by the entry point index.d.ts +// // @public -export interface ErrorToastOptions { +export interface ErrorToastOptions extends ToastOptions { title: string; toastMessage?: string; } @@ -1276,12 +1278,15 @@ export class ToastsApi implements IToasts { uiSettings: IUiSettingsClient; }); add(toastOrTitle: ToastInput): Toast; - addDanger(toastOrTitle: ToastInput): Toast; + // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "ToastOptions" + addDanger(toastOrTitle: ToastInput, options?: ToastOptions): Toast; addError(error: Error, options: ErrorToastOptions): Toast; - // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "number" - addInfo(toastOrTitle: ToastInput, toastLifeTimeMs?: number): Toast; - addSuccess(toastOrTitle: ToastInput): Toast; - addWarning(toastOrTitle: ToastInput): Toast; + // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "ToastOptions" + addInfo(toastOrTitle: ToastInput, options?: ToastOptions): Toast; + // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "ToastOptions" + addSuccess(toastOrTitle: ToastInput, options?: ToastOptions): Toast; + // Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "kibana" does not have an export "ToastOptions" + addWarning(toastOrTitle: ToastInput, options?: ToastOptions): Toast; get$(): Rx.Observable; remove(toastOrId: Toast | string): void; // @internal (undocumented) From 4f25318a173e02eefeff8ff2a97c547aed9c6c83 Mon Sep 17 00:00:00 2001 From: Liza K Date: Thu, 19 Mar 2020 12:16:47 +0200 Subject: [PATCH 5/7] Export ToastOptions --- .../core/public/kibana-plugin-core-public.md | 1 + .../kibana-plugin-core-public.toastsapi.adddanger.md | 2 +- .../kibana-plugin-core-public.toastsapi.addinfo.md | 2 +- .../kibana-plugin-core-public.toastsapi.addsuccess.md | 2 +- .../kibana-plugin-core-public.toastsapi.addwarning.md | 2 +- src/core/public/index.ts | 1 + src/core/public/notifications/index.ts | 1 + src/core/public/notifications/toasts/index.ts | 1 + src/core/public/public.api.md | 11 +++++------ 9 files changed, 13 insertions(+), 10 deletions(-) diff --git a/docs/development/core/public/kibana-plugin-core-public.md b/docs/development/core/public/kibana-plugin-core-public.md index d217f82aa170f..b8aa56eb2941b 100644 --- a/docs/development/core/public/kibana-plugin-core-public.md +++ b/docs/development/core/public/kibana-plugin-core-public.md @@ -115,6 +115,7 @@ The plugin integrates with the core system via lifecycle events: `setup` | [SavedObjectsUpdateOptions](./kibana-plugin-core-public.savedobjectsupdateoptions.md) | | | [StringValidationRegex](./kibana-plugin-core-public.stringvalidationregex.md) | StringValidation with regex object | | [StringValidationRegexString](./kibana-plugin-core-public.stringvalidationregexstring.md) | StringValidation as regex string | +| [ToastOptions](./kibana-plugin-core-public.toastoptions.md) | Options available for [IToasts](./kibana-plugin-core-public.itoasts.md) APIs. | | [UiSettingsParams](./kibana-plugin-core-public.uisettingsparams.md) | UiSettings parameters defined by the plugins. | | [UiSettingsState](./kibana-plugin-core-public.uisettingsstate.md) | | | [UserProvidedValues](./kibana-plugin-core-public.userprovidedvalues.md) | Describes the values explicitly set by user. | diff --git a/docs/development/core/public/kibana-plugin-core-public.toastsapi.adddanger.md b/docs/development/core/public/kibana-plugin-core-public.toastsapi.adddanger.md index f918f0bf8de1d..420100a1209ab 100644 --- a/docs/development/core/public/kibana-plugin-core-public.toastsapi.adddanger.md +++ b/docs/development/core/public/kibana-plugin-core-public.toastsapi.adddanger.md @@ -17,7 +17,7 @@ addDanger(toastOrTitle: ToastInput, options?: ToastOptions): Toast; | Parameter | Type | Description | | --- | --- | --- | | toastOrTitle | ToastInput | a [ToastInput](./kibana-plugin-core-public.toastinput.md) | -| options | ToastOptions | a | +| options | ToastOptions | a [ToastOptions](./kibana-plugin-core-public.toastoptions.md) | Returns: diff --git a/docs/development/core/public/kibana-plugin-core-public.toastsapi.addinfo.md b/docs/development/core/public/kibana-plugin-core-public.toastsapi.addinfo.md index bbc80c2dc4c86..76508d26b4ae9 100644 --- a/docs/development/core/public/kibana-plugin-core-public.toastsapi.addinfo.md +++ b/docs/development/core/public/kibana-plugin-core-public.toastsapi.addinfo.md @@ -17,7 +17,7 @@ addInfo(toastOrTitle: ToastInput, options?: ToastOptions): Toast; | Parameter | Type | Description | | --- | --- | --- | | toastOrTitle | ToastInput | a [ToastInput](./kibana-plugin-core-public.toastinput.md) | -| options | ToastOptions | a | +| options | ToastOptions | a [ToastOptions](./kibana-plugin-core-public.toastoptions.md) | Returns: diff --git a/docs/development/core/public/kibana-plugin-core-public.toastsapi.addsuccess.md b/docs/development/core/public/kibana-plugin-core-public.toastsapi.addsuccess.md index 071ec3d2da143..c79f48042514a 100644 --- a/docs/development/core/public/kibana-plugin-core-public.toastsapi.addsuccess.md +++ b/docs/development/core/public/kibana-plugin-core-public.toastsapi.addsuccess.md @@ -17,7 +17,7 @@ addSuccess(toastOrTitle: ToastInput, options?: ToastOptions): Toast; | Parameter | Type | Description | | --- | --- | --- | | toastOrTitle | ToastInput | a [ToastInput](./kibana-plugin-core-public.toastinput.md) | -| options | ToastOptions | a | +| options | ToastOptions | a [ToastOptions](./kibana-plugin-core-public.toastoptions.md) | Returns: diff --git a/docs/development/core/public/kibana-plugin-core-public.toastsapi.addwarning.md b/docs/development/core/public/kibana-plugin-core-public.toastsapi.addwarning.md index 5f8adb534521b..6154af148332d 100644 --- a/docs/development/core/public/kibana-plugin-core-public.toastsapi.addwarning.md +++ b/docs/development/core/public/kibana-plugin-core-public.toastsapi.addwarning.md @@ -17,7 +17,7 @@ addWarning(toastOrTitle: ToastInput, options?: ToastOptions): Toast; | Parameter | Type | Description | | --- | --- | --- | | toastOrTitle | ToastInput | a [ToastInput](./kibana-plugin-core-public.toastinput.md) | -| options | ToastOptions | a | +| options | ToastOptions | a [ToastOptions](./kibana-plugin-core-public.toastoptions.md) | Returns: diff --git a/src/core/public/index.ts b/src/core/public/index.ts index 0ff044878afa9..b91afa3ae7dc0 100644 --- a/src/core/public/index.ts +++ b/src/core/public/index.ts @@ -168,6 +168,7 @@ export { ToastInputFields, ToastsSetup, ToastsStart, + ToastOptions, ErrorToastOptions, } from './notifications'; diff --git a/src/core/public/notifications/index.ts b/src/core/public/notifications/index.ts index 55b64ac375f08..1a5c2cee7ced6 100644 --- a/src/core/public/notifications/index.ts +++ b/src/core/public/notifications/index.ts @@ -19,6 +19,7 @@ export { ErrorToastOptions, + ToastOptions, Toast, ToastInput, IToasts, diff --git a/src/core/public/notifications/toasts/index.ts b/src/core/public/notifications/toasts/index.ts index 6e9de11683364..b259258b8a335 100644 --- a/src/core/public/notifications/toasts/index.ts +++ b/src/core/public/notifications/toasts/index.ts @@ -20,6 +20,7 @@ export { ToastsService, ToastsSetup, ToastsStart } from './toasts_service'; export { ErrorToastOptions, + ToastOptions, ToastsApi, ToastInput, IToasts, diff --git a/src/core/public/public.api.md b/src/core/public/public.api.md index 1522d412e16bd..37212a07ee631 100644 --- a/src/core/public/public.api.md +++ b/src/core/public/public.api.md @@ -560,8 +560,6 @@ export interface EnvironmentMode { prod: boolean; } -// Warning: (ae-forgotten-export) The symbol "ToastOptions" needs to be exported by the entry point index.d.ts -// // @public export interface ErrorToastOptions extends ToastOptions { title: string; @@ -1272,20 +1270,21 @@ export type ToastInputFields = Pick; remove(toastOrId: Toast | string): void; From 697c3e387681ce92671613c5850e464659cdad62 Mon Sep 17 00:00:00 2001 From: Liza K Date: Thu, 19 Mar 2020 12:17:10 +0200 Subject: [PATCH 6/7] Export ToastOptions --- .../kibana-plugin-core-public.toastoptions.md | 20 +++++++++++++++++++ ...ore-public.toastoptions.toastlifetimems.md | 13 ++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 docs/development/core/public/kibana-plugin-core-public.toastoptions.md create mode 100644 docs/development/core/public/kibana-plugin-core-public.toastoptions.toastlifetimems.md diff --git a/docs/development/core/public/kibana-plugin-core-public.toastoptions.md b/docs/development/core/public/kibana-plugin-core-public.toastoptions.md new file mode 100644 index 0000000000000..0d85c482c2288 --- /dev/null +++ b/docs/development/core/public/kibana-plugin-core-public.toastoptions.md @@ -0,0 +1,20 @@ + + +[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [ToastOptions](./kibana-plugin-core-public.toastoptions.md) + +## ToastOptions interface + +Options available for [IToasts](./kibana-plugin-core-public.itoasts.md) APIs. + +Signature: + +```typescript +export interface ToastOptions +``` + +## Properties + +| Property | Type | Description | +| --- | --- | --- | +| [toastLifeTimeMs](./kibana-plugin-core-public.toastoptions.toastlifetimems.md) | number | How long should the toast remain on screen. | + diff --git a/docs/development/core/public/kibana-plugin-core-public.toastoptions.toastlifetimems.md b/docs/development/core/public/kibana-plugin-core-public.toastoptions.toastlifetimems.md new file mode 100644 index 0000000000000..bb0e2f9afc83b --- /dev/null +++ b/docs/development/core/public/kibana-plugin-core-public.toastoptions.toastlifetimems.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [kibana-plugin-core-public](./kibana-plugin-core-public.md) > [ToastOptions](./kibana-plugin-core-public.toastoptions.md) > [toastLifeTimeMs](./kibana-plugin-core-public.toastoptions.toastlifetimems.md) + +## ToastOptions.toastLifeTimeMs property + +How long should the toast remain on screen. + +Signature: + +```typescript +toastLifeTimeMs?: number; +``` From e63a23335ebdf212e15846739146bffe14e61791 Mon Sep 17 00:00:00 2001 From: Liza K Date: Fri, 20 Mar 2020 00:05:28 +0200 Subject: [PATCH 7/7] added test --- src/core/public/notifications/toasts/toasts_api.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/public/notifications/toasts/toasts_api.test.ts b/src/core/public/notifications/toasts/toasts_api.test.ts index 7fa200dd7a111..7c0ef5576256a 100644 --- a/src/core/public/notifications/toasts/toasts_api.test.ts +++ b/src/core/public/notifications/toasts/toasts_api.test.ts @@ -154,8 +154,9 @@ describe('#addInfo()', () => { it('returns the created toast', async () => { const toasts = new ToastsApi(toastDeps()); - const toast = toasts.addInfo({}); + const toast = toasts.addInfo({}, { toastLifeTimeMs: 1 }); const currentToasts = await getCurrentToasts(toasts); + expect(currentToasts[0].toastLifeTimeMs).toBe(1); expect(currentToasts[0]).toBe(toast); }); });