Skip to content

Commit

Permalink
[ML] Improve bucket span estimator error toast (#105457) (#105552)
Browse files Browse the repository at this point in the history
Co-authored-by: James Gowdy <jgowdy@elastic.co>
  • Loading branch information
kibanamachine and jgowdyelastic authored Jul 14, 2021
1 parent 0c0af7a commit 99fc6ef
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { useContext, useState } from 'react';

import { i18n } from '@kbn/i18n';
import { JobCreatorContext } from '../../../job_creator_context';
import { EVENT_RATE_FIELD_ID } from '../../../../../../../../../common/types/fields';
import { BucketSpanEstimatorData } from '../../../../../../../../../common/types/job_service';
Expand Down Expand Up @@ -76,10 +76,16 @@ export function useEstimateBucketSpan() {

async function estimateBucketSpan() {
setStatus(ESTIMATE_STATUS.RUNNING);
const { name, error, message } = await ml.estimateBucketSpan(data);
const { name, error, message: text } = await ml.estimateBucketSpan(data);
setStatus(ESTIMATE_STATUS.NOT_RUNNING);
if (error === true) {
getToastNotificationService().displayErrorToast(message);
const title = i18n.translate(
'xpack.ml.newJob.wizard.pickFieldsStep.bucketSpanEstimator.errorTitle',
{
defaultMessage: 'Bucket span could not be estimated',
}
);
getToastNotificationService().displayWarningToast({ title, text });
} else {
jobCreator.bucketSpan = name;
jobCreatorUpdate();
Expand Down

0 comments on commit 99fc6ef

Please sign in to comment.