diff --git a/x-pack/plugins/reporting/public/lib/__snapshots__/stream_handler.test.ts.snap b/x-pack/plugins/reporting/public/lib/__snapshots__/stream_handler.test.ts.snap index 935f3e297b2cb..ab6a5109a1066 100644 --- a/x-pack/plugins/reporting/public/lib/__snapshots__/stream_handler.test.ts.snap +++ b/x-pack/plugins/reporting/public/lib/__snapshots__/stream_handler.test.ts.snap @@ -84,6 +84,9 @@ Array [ />, }, }, + Object { + "toastLifeTimeMs": 86400000, + }, ] `; @@ -184,44 +187,52 @@ Array [ />, }, }, + Object { + "toastLifeTimeMs": 86400000, + }, ] `; exports[`stream handler showNotifications show success 1`] = ` -Object { - "color": "success", - "data-test-subj": "completeReportSuccess", - "text": MountPoint { - "reactNode": -

- +

+ +

+ -

- , + }, + "title": MountPoint { + "reactNode": -
, + />, + }, }, - "title": MountPoint { - "reactNode": , + Object { + "toastLifeTimeMs": 86400000, }, -} +] `; diff --git a/x-pack/plugins/reporting/public/lib/stream_handler.test.ts b/x-pack/plugins/reporting/public/lib/stream_handler.test.ts index d3075d4e5a906..6f575652450c1 100644 --- a/x-pack/plugins/reporting/public/lib/stream_handler.test.ts +++ b/x-pack/plugins/reporting/public/lib/stream_handler.test.ts @@ -5,7 +5,6 @@ * 2.0. */ -import { omit } from 'lodash'; import sinon, { stub } from 'sinon'; import { NotificationsStart } from '@kbn/core/public'; import { coreMock, themeServiceMock, docLinksServiceMock } from '@kbn/core/public/mocks'; @@ -124,7 +123,7 @@ describe('stream handler', () => { expect(mockShowDanger.callCount).toBe(0); expect(mockShowSuccess.callCount).toBe(1); expect(mockShowWarning.callCount).toBe(0); - expect(omit(mockShowSuccess.args[0][0], 'toastLifeTimeMs')).toMatchSnapshot(); + expect(mockShowSuccess.args[0]).toMatchSnapshot(); done(); }); }); diff --git a/x-pack/plugins/reporting/public/lib/stream_handler.ts b/x-pack/plugins/reporting/public/lib/stream_handler.ts index ba2c32de49f64..ef27989a6d420 100644 --- a/x-pack/plugins/reporting/public/lib/stream_handler.ts +++ b/x-pack/plugins/reporting/public/lib/stream_handler.ts @@ -22,6 +22,12 @@ import { import { Job } from './job'; import { ReportingAPIClient } from './reporting_api_client'; +/** + * @todo Replace with `Infinity` once elastic/eui#5945 is resolved. + * @see https://github.com/elastic/eui/issues/5945 + */ +const COMPLETED_JOB_TOAST_TIMEOUT = 24 * 60 * 60 * 1000; // 24 hours + function updateStored(jobIds: JobId[]): void { sessionStorage.setItem(JOB_COMPLETION_NOTIFICATIONS_SESSION_KEY, JSON.stringify(jobIds)); } @@ -54,6 +60,8 @@ export class ReportingNotifierStreamHandler { failed: failedJobs, }: JobSummarySet): Rx.Observable { const showNotificationsAsync = async () => { + const completedOptions = { toastLifeTimeMs: COMPLETED_JOB_TOAST_TIMEOUT }; + // notifications with download link for (const job of completedJobs) { if (job.csvContainsFormulas) { @@ -63,7 +71,8 @@ export class ReportingNotifierStreamHandler { this.apiClient.getManagementLink, this.apiClient.getDownloadLink, this.theme - ) + ), + completedOptions ); } else if (job.maxSizeReached) { this.notifications.toasts.addWarning( @@ -72,7 +81,8 @@ export class ReportingNotifierStreamHandler { this.apiClient.getManagementLink, this.apiClient.getDownloadLink, this.theme - ) + ), + completedOptions ); } else if (job.status === JOB_STATUSES.WARNINGS) { this.notifications.toasts.addWarning( @@ -81,7 +91,8 @@ export class ReportingNotifierStreamHandler { this.apiClient.getManagementLink, this.apiClient.getDownloadLink, this.theme - ) + ), + completedOptions ); } else { this.notifications.toasts.addSuccess( @@ -90,7 +101,8 @@ export class ReportingNotifierStreamHandler { this.apiClient.getManagementLink, this.apiClient.getDownloadLink, this.theme - ) + ), + completedOptions ); } } diff --git a/x-pack/plugins/reporting/public/notifier/job_success.tsx b/x-pack/plugins/reporting/public/notifier/job_success.tsx index f7b71d78de8bd..44389e164472a 100644 --- a/x-pack/plugins/reporting/public/notifier/job_success.tsx +++ b/x-pack/plugins/reporting/public/notifier/job_success.tsx @@ -37,12 +37,5 @@ export const getSuccessToast = ( , { theme$: theme.theme$ } ), - /** - * If timeout is an Infinity value, a Not-a-Number (NaN) value, or negative, then timeout will be zero. - * And we cannot use `Number.MAX_SAFE_INTEGER` because EUI's Timer implementation - * subtracts it from the current time to evaluate the remainder. - * @see https://www.w3.org/TR/2011/WD-html5-20110525/timers.html - */ - toastLifeTimeMs: Number.MAX_SAFE_INTEGER - Date.now(), 'data-test-subj': 'completeReportSuccess', });