mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
(cherry picked from commit 1e39a2c67e
)
Co-authored-by: Michael Dokolin <mikhail.dokolin@elastic.co>
This commit is contained in:
parent
5fd513019f
commit
ca9e2531b8
4 changed files with 57 additions and 42 deletions
|
@ -81,6 +81,9 @@ Array [
|
|||
/>,
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"toastLifeTimeMs": 86400000,
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
|
@ -183,44 +186,52 @@ Array [
|
|||
/>,
|
||||
},
|
||||
},
|
||||
Object {
|
||||
"toastLifeTimeMs": 86400000,
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`stream handler showNotifications show success 1`] = `
|
||||
Object {
|
||||
"color": "success",
|
||||
"data-test-subj": "completeReportSuccess",
|
||||
"text": MountPoint {
|
||||
"reactNode": <React.Fragment>
|
||||
<p>
|
||||
<ReportLink
|
||||
Array [
|
||||
Object {
|
||||
"color": "success",
|
||||
"data-test-subj": "completeReportSuccess",
|
||||
"text": MountPoint {
|
||||
"reactNode": <React.Fragment>
|
||||
<p>
|
||||
<ReportLink
|
||||
getUrl={[Function]}
|
||||
/>
|
||||
</p>
|
||||
<DownloadButton
|
||||
getUrl={[Function]}
|
||||
job={
|
||||
Object {
|
||||
"id": "yas1",
|
||||
"jobtype": "yas",
|
||||
"status": "completed",
|
||||
"title": "Yas",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</p>
|
||||
<DownloadButton
|
||||
getUrl={[Function]}
|
||||
job={
|
||||
</React.Fragment>,
|
||||
},
|
||||
"title": MountPoint {
|
||||
"reactNode": <FormattedMessage
|
||||
defaultMessage="{reportType} created for '{reportObjectTitle}'"
|
||||
id="xpack.reporting.publicNotifier.successfullyCreatedReportNotificationTitle"
|
||||
values={
|
||||
Object {
|
||||
"id": "yas1",
|
||||
"jobtype": "yas",
|
||||
"status": "completed",
|
||||
"title": "Yas",
|
||||
"reportObjectTitle": "Yas",
|
||||
"reportType": "yas",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</React.Fragment>,
|
||||
/>,
|
||||
},
|
||||
},
|
||||
"title": MountPoint {
|
||||
"reactNode": <FormattedMessage
|
||||
defaultMessage="{reportType} created for '{reportObjectTitle}'"
|
||||
id="xpack.reporting.publicNotifier.successfullyCreatedReportNotificationTitle"
|
||||
values={
|
||||
Object {
|
||||
"reportObjectTitle": "Yas",
|
||||
"reportType": "yas",
|
||||
}
|
||||
}
|
||||
/>,
|
||||
Object {
|
||||
"toastLifeTimeMs": 86400000,
|
||||
},
|
||||
}
|
||||
]
|
||||
`;
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { omit } from 'lodash';
|
||||
import sinon, { stub } from 'sinon';
|
||||
import { NotificationsStart } from 'src/core/public';
|
||||
import { coreMock, themeServiceMock } from '../../../../../src/core/public/mocks';
|
||||
|
@ -103,7 +102,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();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
@ -52,6 +58,8 @@ export class ReportingNotifierStreamHandler {
|
|||
failed: failedJobs,
|
||||
}: JobSummarySet): Rx.Observable<JobSummarySet> {
|
||||
const showNotificationsAsync = async () => {
|
||||
const completedOptions = { toastLifeTimeMs: COMPLETED_JOB_TOAST_TIMEOUT };
|
||||
|
||||
// notifications with download link
|
||||
for (const job of completedJobs) {
|
||||
if (job.csvContainsFormulas) {
|
||||
|
@ -61,7 +69,8 @@ export class ReportingNotifierStreamHandler {
|
|||
this.apiClient.getManagementLink,
|
||||
this.apiClient.getDownloadLink,
|
||||
this.theme
|
||||
)
|
||||
),
|
||||
completedOptions
|
||||
);
|
||||
} else if (job.maxSizeReached) {
|
||||
this.notifications.toasts.addWarning(
|
||||
|
@ -70,7 +79,8 @@ export class ReportingNotifierStreamHandler {
|
|||
this.apiClient.getManagementLink,
|
||||
this.apiClient.getDownloadLink,
|
||||
this.theme
|
||||
)
|
||||
),
|
||||
completedOptions
|
||||
);
|
||||
} else if (job.status === JOB_STATUSES.WARNINGS) {
|
||||
this.notifications.toasts.addWarning(
|
||||
|
@ -79,7 +89,8 @@ export class ReportingNotifierStreamHandler {
|
|||
this.apiClient.getManagementLink,
|
||||
this.apiClient.getDownloadLink,
|
||||
this.theme
|
||||
)
|
||||
),
|
||||
completedOptions
|
||||
);
|
||||
} else {
|
||||
this.notifications.toasts.addSuccess(
|
||||
|
@ -88,7 +99,8 @@ export class ReportingNotifierStreamHandler {
|
|||
this.apiClient.getManagementLink,
|
||||
this.apiClient.getDownloadLink,
|
||||
this.theme
|
||||
)
|
||||
),
|
||||
completedOptions
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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',
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue