[Grok] Fix missing error message in error toasts (#77499)

This commit is contained in:
Jean-Louis Leysens 2020-09-16 12:59:46 +02:00 committed by GitHub
parent efe76121c7
commit f70aacec87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,10 +4,10 @@
* you may not use this file except in compliance with the Elastic License.
*/
import React from 'react';
import { isEmpty } from 'lodash';
import { i18n } from '@kbn/i18n';
import isEmpty from 'lodash/isEmpty';
import './brace_imports';
import {
EuiForm,
EuiButton,
@ -25,6 +25,17 @@ import { GrokdebuggerRequest } from '../../models/grokdebugger_request';
import { withKibana } from '../../../../../../src/plugins/kibana_react/public';
import { FormattedMessage } from '@kbn/i18n/react';
const i18nTexts = {
simulate: {
errorTitle: i18n.translate('xpack.grokDebugger.simulate.errorTitle', {
defaultMessage: 'Simulate error',
}),
unknownErrorTitle: i18n.translate('xpack.grokDebugger.unknownErrorTitle', {
defaultMessage: 'Something went wrong',
}),
},
};
export class GrokDebuggerComponent extends React.Component {
constructor(props) {
super(props);
@ -84,12 +95,13 @@ export class GrokDebuggerComponent extends React.Component {
if (!isEmpty(simulateResponse.error)) {
notifications.toasts.addDanger({
body: simulateResponse.error,
title: i18nTexts.simulate.errorTitle,
text: simulateResponse.error,
});
}
} catch (e) {
notifications.toasts.addDanger({
body: e,
notifications.toasts.addError(e, {
title: i18nTexts.simulate.unknownErrorTitle,
});
}
};