mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[i18n] Translate fatal errors (#29410)
* Translate fatal_errors * Update snapshot * Update snapshots * Fix ids * Add path to translations in scr/core folder
This commit is contained in:
parent
db147984f8
commit
53307404e6
7 changed files with 69 additions and 26 deletions
|
@ -3,6 +3,7 @@
|
|||
"common.ui": "src/ui",
|
||||
"server": "src/server",
|
||||
"console": "src/legacy/core_plugins/console",
|
||||
"core": "src/core",
|
||||
"inputControl": "src/legacy/core_plugins/input_control_vis",
|
||||
"inspectorViews": "src/legacy/core_plugins/inspector_views",
|
||||
"interpreter": "src/legacy/core_plugins/interpreter",
|
||||
|
@ -45,6 +46,7 @@
|
|||
"xpack.watcher": "x-pack/plugins/watcher"
|
||||
},
|
||||
"exclude": [
|
||||
"src/core/public/fatal_errors/get_error_info.ts",
|
||||
"src/ui/ui_render/bootstrap/app_bootstrap.js",
|
||||
"src/ui/ui_render/ui_render_mixin.js",
|
||||
"x-pack/plugins/infra/public/graphql/types.ts",
|
||||
|
|
|
@ -28,7 +28,11 @@ exports[`rendering render matches snapshot 1`] = `
|
|||
onClick={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Clear your session
|
||||
<FormattedMessage
|
||||
defaultMessage="Clear your session"
|
||||
id="core.fatalErrors.clearYourSessionButtonLabel"
|
||||
values={Object {}}
|
||||
/>
|
||||
</EuiButton>,
|
||||
<EuiButtonEmpty
|
||||
color="primary"
|
||||
|
@ -37,20 +41,33 @@ exports[`rendering render matches snapshot 1`] = `
|
|||
onClick={[Function]}
|
||||
type="button"
|
||||
>
|
||||
Go back
|
||||
<FormattedMessage
|
||||
defaultMessage="Go back"
|
||||
id="core.fatalErrors.goBackButtonLabel"
|
||||
values={Object {}}
|
||||
/>
|
||||
</EuiButtonEmpty>,
|
||||
]
|
||||
}
|
||||
body={
|
||||
<p>
|
||||
Try refreshing the page. If that doesn't work, go back to the previous page or clear your session data.
|
||||
<FormattedMessage
|
||||
defaultMessage="Try refreshing the page. If that doesn't work, go back to the previous page or
|
||||
clear your session data."
|
||||
id="core.fatalErrors.tryRefreshingPageDescription"
|
||||
values={Object {}}
|
||||
/>
|
||||
</p>
|
||||
}
|
||||
iconColor="danger"
|
||||
iconType="alert"
|
||||
title={
|
||||
<h2>
|
||||
Something went wrong
|
||||
<FormattedMessage
|
||||
defaultMessage="Something went wrong"
|
||||
id="core.fatalErrors.somethingWentWrongTitle"
|
||||
values={Object {}}
|
||||
/>
|
||||
</h2>
|
||||
}
|
||||
/>
|
||||
|
|
|
@ -3,11 +3,13 @@
|
|||
exports[`#add() deletes all children of rootDomElement and renders <FatalErrorScreen /> into it: fatal error screen component 1`] = `
|
||||
Array [
|
||||
Array [
|
||||
<FatalErrorsScreen
|
||||
buildNumber="kibanaBuildNumber"
|
||||
errorInfo$={Rx.Observable}
|
||||
kibanaVersion="kibanaVersion"
|
||||
/>,
|
||||
<I18nProvider>
|
||||
<FatalErrorsScreen
|
||||
buildNumber="kibanaBuildNumber"
|
||||
errorInfo$={Rx.Observable}
|
||||
kibanaVersion="kibanaVersion"
|
||||
/>
|
||||
</I18nProvider>,
|
||||
<div />,
|
||||
],
|
||||
]
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
|
||||
import { EuiCallOut } from '@elastic/eui';
|
||||
import testSubjSelector from '@kbn/test-subj-selector';
|
||||
import { mount, shallow } from 'enzyme';
|
||||
import React from 'react';
|
||||
import * as Rx from 'rxjs';
|
||||
import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers';
|
||||
|
||||
import { FatalErrorsScreen } from './fatal_errors_screen';
|
||||
|
||||
|
@ -54,7 +54,7 @@ describe('reloading', () => {
|
|||
|
||||
const locationReloadSpy = jest.spyOn(window.location, 'reload').mockImplementation(noop);
|
||||
|
||||
shallow(<FatalErrorsScreen {...defaultProps} />);
|
||||
shallowWithIntl(<FatalErrorsScreen {...defaultProps} />);
|
||||
expect(addEventListenerSpy).toHaveBeenCalledTimes(1);
|
||||
expect(addEventListenerSpy).toHaveBeenCalledWith('hashchange', expect.any(Function), undefined);
|
||||
|
||||
|
@ -67,13 +67,13 @@ describe('reloading', () => {
|
|||
|
||||
describe('rendering', () => {
|
||||
it('render matches snapshot', () => {
|
||||
expect(shallow(<FatalErrorsScreen {...defaultProps} />)).toMatchSnapshot();
|
||||
expect(shallowWithIntl(<FatalErrorsScreen {...defaultProps} />)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('rerenders when errorInfo$ emits more errors', () => {
|
||||
const errorInfo$ = new Rx.ReplaySubject<typeof errorInfoFoo>();
|
||||
|
||||
const el = shallow(<FatalErrorsScreen {...defaultProps} errorInfo$={errorInfo$} />);
|
||||
const el = shallowWithIntl(<FatalErrorsScreen {...defaultProps} errorInfo$={errorInfo$} />);
|
||||
|
||||
expect(el.find(EuiCallOut)).toHaveLength(0);
|
||||
|
||||
|
@ -111,7 +111,7 @@ describe('buttons', () => {
|
|||
window.location.hash = '/foo/bar';
|
||||
jest.spyOn(window.location, 'reload').mockImplementation(noop);
|
||||
|
||||
const el = mount(<FatalErrorsScreen {...defaultProps} />);
|
||||
const el = mountWithIntl(<FatalErrorsScreen {...defaultProps} />);
|
||||
const button = el.find('button').find(testSubjSelector('clearSession'));
|
||||
button.simulate('click');
|
||||
|
||||
|
@ -126,7 +126,7 @@ describe('buttons', () => {
|
|||
it('calls window.history.back()', () => {
|
||||
jest.spyOn(window.history, 'back').mockImplementation(noop);
|
||||
|
||||
const el = mount(<FatalErrorsScreen {...defaultProps} />);
|
||||
const el = mountWithIntl(<FatalErrorsScreen {...defaultProps} />);
|
||||
const button = el.find('button').find(testSubjSelector('goBack'));
|
||||
button.simulate('click');
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@ import React from 'react';
|
|||
import * as Rx from 'rxjs';
|
||||
import { tap } from 'rxjs/operators';
|
||||
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
|
||||
import { ErrorInfo } from './get_error_info';
|
||||
|
||||
interface Props {
|
||||
|
@ -91,11 +93,21 @@ export class FatalErrorsScreen extends React.Component<Props, State> {
|
|||
<EuiEmptyPrompt
|
||||
iconType="alert"
|
||||
iconColor="danger"
|
||||
title={<h2>Something went wrong</h2>}
|
||||
title={
|
||||
<h2>
|
||||
<FormattedMessage
|
||||
id="core.fatalErrors.somethingWentWrongTitle"
|
||||
defaultMessage="Something went wrong"
|
||||
/>
|
||||
</h2>
|
||||
}
|
||||
body={
|
||||
<p>
|
||||
Try refreshing the page. If that doesn't work, go back to the previous page or
|
||||
clear your session data.
|
||||
<FormattedMessage
|
||||
id="core.fatalErrors.tryRefreshingPageDescription"
|
||||
defaultMessage="Try refreshing the page. If that doesn't work, go back to the previous page or
|
||||
clear your session data."
|
||||
/>
|
||||
</p>
|
||||
}
|
||||
actions={[
|
||||
|
@ -105,10 +117,16 @@ export class FatalErrorsScreen extends React.Component<Props, State> {
|
|||
onClick={this.onClickClearSession}
|
||||
data-test-subj="clearSession"
|
||||
>
|
||||
Clear your session
|
||||
<FormattedMessage
|
||||
id="core.fatalErrors.clearYourSessionButtonLabel"
|
||||
defaultMessage="Clear your session"
|
||||
/>
|
||||
</EuiButton>,
|
||||
<EuiButtonEmpty onClick={this.onClickGoBack} data-test-subj="goBack">
|
||||
Go back
|
||||
<FormattedMessage
|
||||
id="core.fatalErrors.goBackButtonLabel"
|
||||
defaultMessage="Go back"
|
||||
/>
|
||||
</EuiButtonEmpty>,
|
||||
]}
|
||||
/>
|
||||
|
|
|
@ -26,6 +26,8 @@ import { InjectedMetadataService } from '../injected_metadata';
|
|||
import { FatalErrorsScreen } from './fatal_errors_screen';
|
||||
import { ErrorInfo, getErrorInfo } from './get_error_info';
|
||||
|
||||
import { I18nProvider } from '@kbn/i18n/react';
|
||||
|
||||
export interface FatalErrorsParams {
|
||||
rootDomElement: HTMLElement;
|
||||
injectedMetadata: InjectedMetadataService;
|
||||
|
@ -85,11 +87,13 @@ export class FatalErrorsService {
|
|||
this.params.rootDomElement.appendChild(container);
|
||||
|
||||
render(
|
||||
<FatalErrorsScreen
|
||||
buildNumber={this.params.injectedMetadata.getKibanaBuildNumber()}
|
||||
kibanaVersion={this.params.injectedMetadata.getKibanaVersion()}
|
||||
errorInfo$={this.errorInfo$}
|
||||
/>,
|
||||
<I18nProvider>
|
||||
<FatalErrorsScreen
|
||||
buildNumber={this.params.injectedMetadata.getKibanaBuildNumber()}
|
||||
kibanaVersion={this.params.injectedMetadata.getKibanaVersion()}
|
||||
errorInfo$={this.errorInfo$}
|
||||
/>
|
||||
</I18nProvider>,
|
||||
container
|
||||
);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import { fromRoot } from '../../utils';
|
|||
export async function i18nMixin(kbnServer, server, config) {
|
||||
const locale = config.get('i18n.locale');
|
||||
|
||||
const translationsDirs = [fromRoot('src/ui/translations'), fromRoot('src/server/translations')];
|
||||
const translationsDirs = [fromRoot('src/ui/translations'), fromRoot('src/server/translations'), fromRoot('src/core/translations')];
|
||||
|
||||
const groupedEntries = await Promise.all([
|
||||
...config.get('plugins.scanDirs').map(async path => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue