Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate security/roles component #23984

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2630186
Translate security/roles component
tibmt Oct 12, 2018
5eb9c92
Merge branch 'master' into feature/translations/security/roles
tibmt Oct 12, 2018
bbac404
update Translation of Security Roles visualization components
tibmt Oct 19, 2018
0cc02a5
Merge branch 'master' into feature/translations/security/roles
tibmt Oct 23, 2018
d088841
update translation of security/roles component
tibmt Oct 23, 2018
81c9c9f
update i18nrc.json
tibmt Oct 23, 2018
321da7e
Merge branch 'master' into feature/translations/security/roles
maryia-lapata Oct 24, 2018
0dd7da6
update translation of security/roles components
tibmt Oct 25, 2018
ba4ed34
Update delete_role_button.tsx
tibmt Oct 25, 2018
b73e3c4
update login_page.tsx
tibmt Oct 25, 2018
a6194c0
Update snapshots
maryia-lapata Oct 26, 2018
2f1460d
update security/roles translation - intl type
tibmt Oct 26, 2018
ff29818
update security/roles translation - remove view/components id namespace
tibmt Oct 26, 2018
4ba759b
Merge branch 'master' into feature/translations/security/roles
tibmt Oct 26, 2018
30aebd2
update security/roles translation
tibmt Oct 26, 2018
39afaa9
update security/roles translation
tibmt Oct 26, 2018
18a70a5
fix review comment
pavel06081991 Oct 30, 2018
273373b
Merge branch 'master' into feature/translations/security/roles
pavel06081991 Oct 30, 2018
31ae437
remove export for components wrapped by injectIntl
pavel06081991 Oct 30, 2018
6d6f1e6
use separate tags for translations
pavel06081991 Nov 1, 2018
bfe526d
Merge branch 'master' into feature/translations/security/roles
pavel06081991 Nov 1, 2018
6dd7add
update ids
pavel06081991 Nov 1, 2018
ee2ad70
Merge branch 'master' into feature/translations/security/roles
maryia-lapata Nov 1, 2018
143202b
Update unit tests
maryia-lapata Nov 1, 2018
fd21a0e
Merge branch 'master' into feature/translations/security/roles
pavel06081991 Nov 6, 2018
d051135
fix tests
pavel06081991 Nov 6, 2018
626d0ef
fix ts path for enzyme test helpers
pavel06081991 Nov 8, 2018
00e5b82
Merge branch 'master' into feature/translations/security/roles
pavel06081991 Nov 8, 2018
1cc23d0
fix path to enzyme helpers test functions
pavel06081991 Nov 8, 2018
092eddd
Merge branch 'master' into feature/translations/security/roles
pavel06081991 Nov 8, 2018
e9ca6e0
Merge branch 'master' into feature/translations/security/roles
pavel06081991 Nov 9, 2018
399bf4d
Update unit tests
maryia-lapata Nov 9, 2018
2537432
Merge branch 'master' into feature/translations/security/roles
maryia-lapata Nov 13, 2018
bd0f87f
Merge branch 'master' into feature/translations/security/roles
pavel06081991 Nov 19, 2018
a86f3d4
fix path to enzyme helpers
pavel06081991 Nov 19, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"statusPage": "src/core_plugins/status_page",
"tagCloud": "src/core_plugins/tagcloud",
"xpack.idxMgmt": "x-pack/plugins/index_management",
"xpack.watcher": "x-pack/plugins/watcher"
"xpack.watcher": "x-pack/plugins/watcher",
"xpack.security": "x-pack/plugins/security"
},
"exclude": [
"src/ui/ui_render/bootstrap/app_bootstrap.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
EuiSpacer,
EuiTitle,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import React, { Component, Fragment } from 'react';
import './collapsible_panel.less';

Expand Down Expand Up @@ -56,7 +57,19 @@ export class CollapsiblePanel extends Component<Props, State> {
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiLink onClick={this.toggleCollapsed}>{this.state.collapsed ? 'show' : 'hide'}</EuiLink>
<EuiLink onClick={this.toggleCollapsed}>
{this.state.collapsed ? (
<FormattedMessage
id="xpack.security.views.management.editRoles.components.collapsiblePanel.showLinkText"
defaultMessage="show"
/>
) : (
<FormattedMessage
id="xpack.security.views.management.editRoles.components.collapsiblePanel.hideLinkText"
defaultMessage="hide"
/>
)}
</EuiLink>
</EuiFlexItem>
</EuiFlexGroup>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
// @ts-ignore
EuiOverlayMask,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import React, { Component, Fragment } from 'react';

interface Props {
Expand All @@ -35,29 +36,58 @@ export class DeleteRoleButton extends Component<Props, State> {
return (
<Fragment>
<EuiButtonEmpty color={'danger'} onClick={this.showModal}>
Delete role
<FormattedMessage
id="xpack.security.views.management.editRoles.components.deleteRoleButton.deleteRoleButtonLabel"
defaultMessage="Delete role"
/>
</EuiButtonEmpty>
{this.maybeShowModal()}
</Fragment>
);
}

public maybeShowModal = () => {
const { intl } = this.props;
if (!this.state.showModal) {
return null;
}
return (
<EuiOverlayMask>
<EuiConfirmModal
title={'Delete Role'}
title={
<FormattedMessage
id="xpack.security.views.management.editRoles.components.deleteRoleButton.deleteRoleTitle"
defaultMessage="Delete Role"
/>
}
onCancel={this.closeModal}
onConfirm={this.onConfirmDelete}
cancelButtonText={"No, don't delete"}
confirmButtonText={'Yes, delete role'}
cancelButtonText={
<FormattedMessage
id="xpack.security.views.management.editRoles.components.deleteRoleButton.cancelButtonLabel"
defaultMessage="No, don't delete"
/>
}
confirmButtonText={
<FormattedMessage
id="xpack.security.views.management.editRoles.components.deleteRoleButton.confirmButtonLabel"
defaultMessage="Yes, delete role"
/>
}
buttonColor={'danger'}
>
<p>Are you sure you want to delete this role?</p>
<p>This action cannot be undone!</p>
<p>
<FormattedMessage
id="xpack.security.views.management.editRoles.components.deleteRoleButton.deletingRoleConfirmationText"
defaultMessage="Are you sure you want to delete this role?"
/>
</p>
<p>
<FormattedMessage
id="xpack.security.views.management.editRoles.components.deleteRoleButton.deletingRoleWarningText"
defaultMessage="This action cannot be undone!"
/>
</p>
</EuiConfirmModal>
</EuiOverlayMask>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import {
EuiButton,
EuiButtonEmpty,
Expand All @@ -19,6 +20,7 @@ import {
EuiText,
EuiTitle,
} from '@elastic/eui';
import { FormattedMessage, injectI18n } from '@kbn/i18n/react';
import { get } from 'lodash';
import React, { ChangeEvent, Component, Fragment, HTMLProps } from 'react';
import { toastNotifications } from 'ui/notify';
Expand Down Expand Up @@ -54,7 +56,7 @@ interface State {
formError: RoleValidationResult | null;
}

export class EditRolePage extends Component<Props, State> {
export class EditRolePageUI extends Component<Props, State> {
private validator: RoleValidator;

constructor(props: Props) {
Expand All @@ -67,9 +69,17 @@ export class EditRolePage extends Component<Props, State> {
}

public render() {
const description = this.props.spacesEnabled
? `Set privileges on your Elasticsearch data and control access to your Kibana spaces.`
: `Set privileges on your Elasticsearch data and control access to Kibana.`;
const description = this.props.spacesEnabled ? (
<FormattedMessage
id="xpack.security.views.management.editRoles.components.editRole.setPrivilegesToKibanaSpacesDescription"
defaultMessage="Set privileges on your Elasticsearch data and control access to your Kibana spaces."
/>
) : (
<FormattedMessage
id="xpack.security.views.management.editRoles.components.editRole.setPrivilegesToKibanaDescription"
defaultMessage="Set privileges on your Elasticsearch data and control access to Kibana."
/>
);

return (
<EuiPage className="editRolePage" restrictWidth>
Expand All @@ -86,7 +96,10 @@ export class EditRolePage extends Component<Props, State> {
<EuiSpacer size="s" />
<EuiText size="s" color="subdued">
<p id="reservedRoleDescription" tabIndex={1}>
Reserved roles are built-in and cannot be removed or modified.
<FormattedMessage
id="xpack.security.views.management.editRoles.components.editRole.modifyingReversedRolesDescription"
defaultMessage="Reserved roles are built-in and cannot be removed or modified."
/>
</p>
</EuiText>
</Fragment>
Expand Down Expand Up @@ -115,12 +128,27 @@ export class EditRolePage extends Component<Props, State> {
tabIndex: 0,
};
if (isReservedRole(this.props.role)) {
titleText = 'Viewing role';
titleText = (
<FormattedMessage
id="xpack.security.views.management.editRoles.components.editRole.viewingRoleTitle"
defaultMessage="Viewing role"
/>
);
props['aria-describedby'] = 'reservedRoleDescription';
} else if (this.editingExistingRole()) {
titleText = 'Edit role';
titleText = (
<FormattedMessage
id="xpack.security.views.management.editRoles.components.editRole.editRoleTitle"
defaultMessage="Edit role"
/>
);
} else {
titleText = 'Create role';
titleText = (
<FormattedMessage
id="xpack.security.views.management.editRoles.components.editRole.createRoleTitle"
defaultMessage="Create role"
/>
);
}

return (
Expand Down Expand Up @@ -148,11 +176,21 @@ export class EditRolePage extends Component<Props, State> {
return (
<EuiPanel>
<EuiFormRow
label={'Role name'}
label={
<FormattedMessage
id="xpack.security.views.management.editRoles.components.editRole.roleNameFormRowTitle"
defaultMessage="Role name"
/>
}
helpText={
!isReservedRole(this.props.role) && this.editingExistingRole()
? "A role's name cannot be changed once it has been created."
: undefined
!isReservedRole(this.props.role) && this.editingExistingRole() ? (
<FormattedMessage
id="xpack.security.views.management.editRoles.components.editRole.roleNameFormRowHelpText"
defaultMessage="A role's name cannot be changed once it has been created."
/>
) : (
undefined
)
}
{...this.validator.validateRoleName(this.state.role)}
>
Expand Down Expand Up @@ -225,10 +263,27 @@ export class EditRolePage extends Component<Props, State> {

public getFormButtons = () => {
if (isReservedRole(this.props.role)) {
return <EuiButton onClick={this.backToRoleList}>Return to role list</EuiButton>;
return (
<EuiButton onClick={this.backToRoleList}>
<FormattedMessage
id="xpack.security.views.management.editRoles.components.editRole.returnToRoleListButtonLabel"
defaultMessage="Return to role list"
/>
</EuiButton>
);
}

const saveText = this.editingExistingRole() ? 'Update role' : 'Create role';
const saveText = this.editingExistingRole() ? (
<FormattedMessage
id="xpack.security.views.management.editRoles.components.editRole.updateRoleText"
defaultMessage="Update role"
/>
) : (
<FormattedMessage
id="xpack.security.views.management.editRoles.components.editRole.createRoleText"
defaultMessage="Create role"
/>
);

return (
<EuiFlexGroup responsive={false}>
Expand All @@ -244,7 +299,10 @@ export class EditRolePage extends Component<Props, State> {
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonEmpty data-test-subj={`roleFormCancelButton`} onClick={this.backToRoleList}>
Cancel
<FormattedMessage
id="xpack.security.views.management.editRoles.components.editRole.cancelButtonLabel"
defaultMessage="Cancel"
/>
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={true} />
Expand Down Expand Up @@ -274,7 +332,7 @@ export class EditRolePage extends Component<Props, State> {
formError: null,
});

const { httpClient } = this.props;
const { httpClient, intl } = this.props;

const role = {
...this.state.role,
Expand All @@ -287,7 +345,13 @@ export class EditRolePage extends Component<Props, State> {

saveRole(httpClient, role)
.then(() => {
toastNotifications.addSuccess('Saved role');
toastNotifications.addSuccess(
intl.formatMessage({
id:
'xpack.security.views.management.editRoles.components.editRoles.roleSuccessfullySavedNotificationMessage',
defaultMessage: 'Saved role',
})
);
this.backToRoleList();
})
.catch((error: any) => {
Expand All @@ -297,11 +361,17 @@ export class EditRolePage extends Component<Props, State> {
};

public handleDeleteRole = () => {
const { httpClient, role } = this.props;
const { httpClient, role, intl } = this.props;

deleteRole(httpClient, role.name)
.then(() => {
toastNotifications.addSuccess('Deleted role');
toastNotifications.addSuccess(
intl.formatMessage({
id:
'xpack.security.views.management.editRoles.components.editRoles.roleSuccessfullyDeletedNotificationMessage',
defaultMessage: 'Deleted role',
})
);
this.backToRoleList();
})
.catch((error: any) => {
Expand All @@ -313,3 +383,5 @@ export class EditRolePage extends Component<Props, State> {
window.location.hash = ROLES_PATH;
};
}

export const EditRolePage = injectI18n(EditRolePageUI);
Loading