[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. * you may not use this file except in compliance with the Elastic License.
*/ */
import React from 'react'; import React from 'react';
import { isEmpty } from 'lodash'; import { i18n } from '@kbn/i18n';
import isEmpty from 'lodash/isEmpty';
import './brace_imports'; import './brace_imports';
import { import {
EuiForm, EuiForm,
EuiButton, EuiButton,
@ -25,6 +25,17 @@ import { GrokdebuggerRequest } from '../../models/grokdebugger_request';
import { withKibana } from '../../../../../../src/plugins/kibana_react/public'; import { withKibana } from '../../../../../../src/plugins/kibana_react/public';
import { FormattedMessage } from '@kbn/i18n/react'; 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 { export class GrokDebuggerComponent extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
@ -84,12 +95,13 @@ export class GrokDebuggerComponent extends React.Component {
if (!isEmpty(simulateResponse.error)) { if (!isEmpty(simulateResponse.error)) {
notifications.toasts.addDanger({ notifications.toasts.addDanger({
body: simulateResponse.error, title: i18nTexts.simulate.errorTitle,
text: simulateResponse.error,
}); });
} }
} catch (e) { } catch (e) {
notifications.toasts.addDanger({ notifications.toasts.addError(e, {
body: e, title: i18nTexts.simulate.unknownErrorTitle,
}); });
} }
}; };