From f70aacec87f1d3ceaa56a350d9d25a84f0934a04 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Wed, 16 Sep 2020 12:59:46 +0200 Subject: [PATCH] [Grok] Fix missing error message in error toasts (#77499) --- .../components/grok_debugger/grok_debugger.js | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js b/x-pack/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js index 83be5520943b..75569f472e21 100644 --- a/x-pack/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js +++ b/x-pack/plugins/grokdebugger/public/components/grok_debugger/grok_debugger.js @@ -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, }); } };