Skip to content

Commit fb6be4c

Browse files
tibmtmaryia-lapata
authored andcommitted
Translate Spaces component (#24411)
* Translate Spaces component * fix one little error * update Spaces component * update translation of Spaces components * Update snapshots * update Space translation - intl type * update Space translation - remove view/views id namespace * rename ids * use testing helper functions instead of shallow, render, mount from enzyme * fix unit tests * fix ts path for enzyme test helpers * fix path to enzyme helpers test functions * Update snapshots * fix path to enzyme test helpers * Remove unused dependency.
1 parent 1155b81 commit fb6be4c

File tree

46 files changed

+797
-219
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+797
-219
lines changed

x-pack/dev-tools/jest/create_jest_config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export function createJestConfig({
2424
"^ui/(.*)": `${kibanaDirectory}/src/ui/public/$1`,
2525
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
2626
`${kibanaDirectory}/src/dev/jest/mocks/file_mock.js`,
27-
"\\.(css|less|scss)$": `${kibanaDirectory}/src/dev/jest/mocks/style_mock.js`
27+
"\\.(css|less|scss)$": `${kibanaDirectory}/src/dev/jest/mocks/style_mock.js`,
28+
"^test_utils/enzyme_helpers": `${xPackKibanaDirectory}/test_utils/enzyme_helpers.tsx`
2829
},
2930
setupFiles: [
3031
`${kibanaDirectory}/src/dev/jest/setup/babel_polyfill.js`,

x-pack/plugins/security/public/views/management/edit_role/components/privileges/kibana/impacted_spaces_flyout.test.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
*/
66

77
import { EuiFlyout, EuiLink } from '@elastic/eui';
8-
import { mount, shallow } from 'enzyme';
98
import React from 'react';
9+
import { mountWithIntl, shallowWithIntl } from 'test_utils/enzyme_helpers';
1010
import { ImpactedSpacesFlyout } from './impacted_spaces_flyout';
1111
import { PrivilegeSpaceTable } from './privilege_space_table';
1212

@@ -52,16 +52,16 @@ const buildProps = (customProps = {}) => {
5252

5353
describe('<ImpactedSpacesFlyout>', () => {
5454
it('renders without crashing', () => {
55-
expect(shallow(<ImpactedSpacesFlyout {...buildProps()} />)).toMatchSnapshot();
55+
expect(shallowWithIntl(<ImpactedSpacesFlyout {...buildProps()} />)).toMatchSnapshot();
5656
});
5757

5858
it('does not immediately show the flyout', () => {
59-
const wrapper = mount(<ImpactedSpacesFlyout {...buildProps()} />);
59+
const wrapper = mountWithIntl(<ImpactedSpacesFlyout {...buildProps()} />);
6060
expect(wrapper.find(EuiFlyout)).toHaveLength(0);
6161
});
6262

6363
it('shows the flyout after clicking the link', () => {
64-
const wrapper = mount(<ImpactedSpacesFlyout {...buildProps()} />);
64+
const wrapper = mountWithIntl(<ImpactedSpacesFlyout {...buildProps()} />);
6565
wrapper.find(EuiLink).simulate('click');
6666
expect(wrapper.find(EuiFlyout)).toHaveLength(1);
6767
});
@@ -82,7 +82,7 @@ describe('<ImpactedSpacesFlyout>', () => {
8282
},
8383
});
8484

85-
const wrapper = shallow(<ImpactedSpacesFlyout {...props} />);
85+
const wrapper = shallowWithIntl(<ImpactedSpacesFlyout {...props} />);
8686
wrapper.find(EuiLink).simulate('click');
8787

8888
const table = wrapper.find(PrivilegeSpaceTable);
@@ -112,7 +112,7 @@ describe('<ImpactedSpacesFlyout>', () => {
112112
},
113113
});
114114

115-
const wrapper = shallow(<ImpactedSpacesFlyout {...props} />);
115+
const wrapper = shallowWithIntl(<ImpactedSpacesFlyout {...props} />);
116116
wrapper.find(EuiLink).simulate('click');
117117

118118
const table = wrapper.find(PrivilegeSpaceTable);
@@ -141,7 +141,7 @@ describe('<ImpactedSpacesFlyout>', () => {
141141
},
142142
});
143143

144-
const wrapper = shallow(<ImpactedSpacesFlyout {...props} />);
144+
const wrapper = shallowWithIntl(<ImpactedSpacesFlyout {...props} />);
145145
wrapper.find(EuiLink).simulate('click');
146146

147147
const table = wrapper.find(PrivilegeSpaceTable);

x-pack/plugins/spaces/public/components/__snapshots__/manage_spaces_button.test.tsx.snap

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ exports[`ManageSpacesButton renders as expected 1`] = `
1111
size="s"
1212
type="button"
1313
>
14-
Manage spaces
14+
<FormattedMessage
15+
defaultMessage="Manage spaces"
16+
id="xpack.spaces.manageSpacesButton.manageSpacesButtonLabel"
17+
values={Object {}}
18+
/>
1519
</EuiButton>
1620
`;

x-pack/plugins/spaces/public/components/manage_spaces_button.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6-
import { shallow } from 'enzyme';
76
import React from 'react';
7+
import { shallowWithIntl } from 'test_utils/enzyme_helpers';
88
import { UserProfileProvider } from '../../../xpack_main/public/services/user_profile';
99
import { ManageSpacesButton } from './manage_spaces_button';
1010

@@ -15,11 +15,11 @@ const buildUserProfile = (canManageSpaces: boolean) => {
1515
describe('ManageSpacesButton', () => {
1616
it('renders as expected', () => {
1717
const component = <ManageSpacesButton userProfile={buildUserProfile(true)} />;
18-
expect(shallow(component)).toMatchSnapshot();
18+
expect(shallowWithIntl(component)).toMatchSnapshot();
1919
});
2020

2121
it(`doesn't render if user profile forbids managing spaces`, () => {
2222
const component = <ManageSpacesButton userProfile={buildUserProfile(false)} />;
23-
expect(shallow(component)).toMatchSnapshot();
23+
expect(shallowWithIntl(component)).toMatchSnapshot();
2424
});
2525
});

x-pack/plugins/spaces/public/components/manage_spaces_button.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
import { EuiButton } from '@elastic/eui';
8+
import { FormattedMessage } from '@kbn/i18n/react';
89
import React, { Component, CSSProperties } from 'react';
910
import { UserProfile } from '../../../xpack_main/public/services/user_profile';
1011
import { MANAGE_SPACES_URL } from '../lib/constants';
@@ -32,7 +33,10 @@ export class ManageSpacesButton extends Component<Props, {}> {
3233
onClick={this.navigateToManageSpaces}
3334
style={this.props.style}
3435
>
35-
Manage spaces
36+
<FormattedMessage
37+
id="xpack.spaces.manageSpacesButton.manageSpacesButtonLabel"
38+
defaultMessage="Manage spaces"
39+
/>
3640
</EuiButton>
3741
);
3842
}

x-pack/plugins/spaces/public/lib/spaces_manager.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6+
import { i18n } from '@kbn/i18n';
67
import { toastNotifications } from 'ui/notify';
78

89
import { IHttpResponse } from 'angular';
@@ -66,8 +67,12 @@ export class SpacesManager extends EventEmitter {
6667

6768
public _displayError() {
6869
toastNotifications.addDanger({
69-
title: 'Unable to change your Space',
70-
text: 'please try again later',
70+
title: i18n.translate('xpack.spaces.spacesManager.unableToChangeSpaceWarningTitle', {
71+
defaultMessage: 'Unable to change your Space',
72+
}),
73+
text: i18n.translate('xpack.spaces.spacesManager.unableToChangeSpaceWarningDescription', {
74+
defaultMessage: 'please try again later',
75+
}),
7176
});
7277
}
7378
}

x-pack/plugins/spaces/public/views/management/components/__snapshots__/confirm_delete_modal.test.tsx.snap

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,15 @@ exports[`ConfirmDeleteModal renders as expected 1`] = `
1111
<EuiModalHeaderTitle
1212
data-test-subj="confirmModalTitleText"
1313
>
14-
Delete space
15-
'My Space'
14+
<FormattedMessage
15+
defaultMessage="Delete space {spaceName}"
16+
id="xpack.spaces.management.confirmDeleteModal.confirmDeleteSpaceButtonLabel"
17+
values={
18+
Object {
19+
"spaceName": "'My Space'",
20+
}
21+
}
22+
/>
1623
</EuiModalHeaderTitle>
1724
</EuiModalHeader>
1825
<EuiModalBody>
@@ -22,12 +29,21 @@ exports[`ConfirmDeleteModal renders as expected 1`] = `
2229
size="m"
2330
>
2431
<p>
25-
Deleting a space permanently removes the space and
26-
27-
<strong>
28-
all of its contents
29-
</strong>
30-
. You can't undo this action.
32+
<FormattedMessage
33+
defaultMessage="Deleting a space permanently removes the space and {allContents}. You can't undo this action."
34+
id="xpack.spaces.management.confirmDeleteModal.deletingSpaceWarningMessage"
35+
values={
36+
Object {
37+
"allContents": <strong>
38+
<FormattedMessage
39+
defaultMessage="all of its contents"
40+
id="xpack.spaces.management.confirmDeleteModal.allContentsText"
41+
values={Object {}}
42+
/>
43+
</strong>,
44+
}
45+
}
46+
/>
3147
</p>
3248
<EuiFormRow
3349
describedByIds={Array []}
@@ -54,15 +70,21 @@ exports[`ConfirmDeleteModal renders as expected 1`] = `
5470
grow={true}
5571
size="m"
5672
>
57-
You are about to delete your current space
58-
<span>
59-
(
60-
<strong>
61-
My Space
62-
</strong>
63-
)
64-
</span>
65-
. You will be redirected to choose a different space if you continue.
73+
<FormattedMessage
74+
defaultMessage="You are about to delete your current space {name}. You will be redirected to choose a different space if you continue."
75+
id="xpack.spaces.management.confirmDeleteModal.redirectAfterDeletingCurrentSpaceWarningMessage"
76+
values={
77+
Object {
78+
"name": <span>
79+
(
80+
<strong>
81+
My Space
82+
</strong>
83+
)
84+
</span>,
85+
}
86+
}
87+
/>
6688
</EuiText>
6789
</EuiCallOut>
6890
</EuiText>
@@ -76,7 +98,11 @@ exports[`ConfirmDeleteModal renders as expected 1`] = `
7698
onClick={[MockFunction]}
7799
type="button"
78100
>
79-
Cancel
101+
<FormattedMessage
102+
defaultMessage="Cancel"
103+
id="xpack.spaces.management.confirmDeleteModal.cancelButtonLabel"
104+
values={Object {}}
105+
/>
80106
</EuiButtonEmpty>
81107
<EuiButton
82108
color="danger"
@@ -87,7 +113,11 @@ exports[`ConfirmDeleteModal renders as expected 1`] = `
87113
onClick={[Function]}
88114
type="button"
89115
>
90-
Delete space and all contents
116+
<FormattedMessage
117+
defaultMessage=" Delete space and all contents"
118+
id="xpack.spaces.management.confirmDeleteModal.deleteSpaceAndAllContentsButtonLabel"
119+
values={Object {}}
120+
/>
91121
</EuiButton>
92122
</EuiModalFooter>
93123
</EuiModal>

x-pack/plugins/spaces/public/views/management/components/__snapshots__/unauthorized_prompt.test.tsx.snap

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,22 @@ exports[`UnauthorizedPrompt renders as expected 1`] = `
66
<p
77
data-test-subj="permissionDeniedMessage"
88
>
9-
You do not have permission to manage spaces.
9+
<FormattedMessage
10+
defaultMessage="You do not have permission to manage spaces."
11+
id="xpack.spaces.management.unauthorizedPrompt.permissionDeniedDescription"
12+
values={Object {}}
13+
/>
1014
</p>
1115
}
1216
iconColor="danger"
1317
iconType="spacesApp"
1418
title={
1519
<h2>
16-
Permission denied
20+
<FormattedMessage
21+
defaultMessage="Permission denied"
22+
id="xpack.spaces.management.unauthorizedPrompt.permissionDeniedTitle"
23+
values={Object {}}
24+
/>
1725
</h2>
1826
}
1927
/>

x-pack/plugins/spaces/public/views/management/components/advanced_settings_subtitle/__snapshots__/advanced_settings_subtitle.test.tsx.snap

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,17 @@ exports[`AdvancedSettingsSubtitle renders as expected 1`] = `
1111
size="m"
1212
title={
1313
<p>
14-
The settings on this page apply to the
15-
<strong>
16-
My Space
17-
</strong>
18-
space, unless otherwise specified.
14+
<FormattedMessage
15+
defaultMessage="The settings on this page apply to the {spaceName} space, unless otherwise specified."
16+
id="xpack.spaces.management.advancedSettingsSubtitle.applyingSettingsOnPageToSpaceDescription"
17+
values={
18+
Object {
19+
"spaceName": <strong>
20+
My Space
21+
</strong>,
22+
}
23+
}
24+
/>
1925
</p>
2026
}
2127
/>

x-pack/plugins/spaces/public/views/management/components/advanced_settings_subtitle/advanced_settings_subtitle.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* or more contributor license agreements. Licensed under the Elastic License;
44
* you may not use this file except in compliance with the Elastic License.
55
*/
6-
import { shallow } from 'enzyme';
76
import React from 'react';
7+
import { shallowWithIntl } from 'test_utils/enzyme_helpers';
88
import { AdvancedSettingsSubtitle } from './advanced_settings_subtitle';
99

1010
describe('AdvancedSettingsSubtitle', () => {
@@ -13,6 +13,6 @@ describe('AdvancedSettingsSubtitle', () => {
1313
id: 'my-space',
1414
name: 'My Space',
1515
};
16-
expect(shallow(<AdvancedSettingsSubtitle space={space} />)).toMatchSnapshot();
16+
expect(shallowWithIntl(<AdvancedSettingsSubtitle space={space} />)).toMatchSnapshot();
1717
});
1818
});

0 commit comments

Comments
 (0)