Skip to content

Commit

Permalink
[Grok] Fix missing error message in error toasts (elastic#77499)
Browse files Browse the repository at this point in the history
  • Loading branch information
jloleysens committed Sep 16, 2020
1 parent 8576293 commit bc9bc7d
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down Expand Up @@ -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,
});
}
};
Expand Down

0 comments on commit bc9bc7d

Please sign in to comment.