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 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
EuiSpacer,
EuiTitle,
} from '@elastic/eui';
import { injectI18n } from '@kbn/i18n/react';
import React, { Component, Fragment } from 'react';
import './collapsible_panel.less';

Expand All @@ -25,7 +26,7 @@ interface State {
collapsed: boolean;
}

export class CollapsiblePanel extends Component<Props, State> {
export class CollapsiblePanelUI extends Component<Props, State> {
public state = {
collapsed: false,
};
Expand All @@ -40,6 +41,8 @@ export class CollapsiblePanel extends Component<Props, State> {
}

public getTitle = () => {
const { intl } = this.props;

return (
// @ts-ignore
<EuiFlexGroup alignItems={'baseline'} gutterSize="s" responsive={false}>
Expand All @@ -56,7 +59,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
? intl.formatMessage({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use FormattedMessage here. So you do not need to use injectI18n

id:
'xpack.security.views.management.editRoles.components.collapsiblePanel.showTitle',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

showTitle => showLinkText

defaultMessage: 'show',
})
: intl.formatMessage({
id:
'xpack.security.views.management.editRoles.components.collapsiblePanel.hideTitle',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hideTitle => hideLinkText

defaultMessage: 'hide',
})}
</EuiLink>
</EuiFlexItem>
</EuiFlexGroup>
);
Expand All @@ -81,3 +96,5 @@ export class CollapsiblePanel extends Component<Props, State> {
});
};
}

export const CollapsiblePanel = injectI18n(CollapsiblePanelUI);
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, injectI18n } from '@kbn/i18n/react';
import React, { Component, Fragment } from 'react';

interface Props {
Expand All @@ -22,7 +23,7 @@ interface State {
showModal: boolean;
}

export class DeleteRoleButton extends Component<Props, State> {
export class DeleteRoleButtonUI extends Component<Props, State> {
public state = {
showModal: false,
};
Expand All @@ -35,29 +36,55 @@ 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.deleteRoleButton"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=> 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={intl.formatMessage({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if title property supports JSX. I mean try to use FormattedMessage. If it works, then do not use injectI18n

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={intl.formatMessage({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same as above

id:
'xpack.security.views.management.editRoles.components.deleteRoleButton.dontDeleteButton',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dontDeleteButton => cancelButtonLabel

defaultMessage: "No, don't delete",
})}
confirmButtonText={intl.formatMessage({
id:
'xpack.security.views.management.editRoles.components.deleteRoleButton.yesDeleteButton',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yesDeleteButton => 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.areYouSureTitle"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

areYouSureTitle => deletingRoleConfirmationText

defaultMessage="Are you sure you want to delete this role?"
/>
</p>
<p>
<FormattedMessage
id="xpack.security.views.management.editRoles.components.deleteRoleButton.actionCannotUndoneTitle"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actionCannotUndoneTitle => deletingRoleWarningText

defaultMessage="This action cannot be undone!"
/>
</p>
</EuiConfirmModal>
</EuiOverlayMask>
);
Expand All @@ -80,3 +107,5 @@ export class DeleteRoleButton extends Component<Props, State> {
this.props.onDelete();
};
}

export const DeleteRoleButton = injectI18n(DeleteRoleButtonUI);
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,18 @@ export class EditRolePage extends Component<Props, State> {
}

public render() {
const { intl } = this.props;
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.`;
? intl.formatMessage({
id:
'xpack.security.views.management.editRoles.components.editRoles.accessToYourKibanaTitle',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

editRoles => editRole for all ids in this file

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accessToYourKibanaTitle => setPrivilegesToKibanaSpacesDescription

defaultMessage:
'Set privileges on your Elasticsearch data and control access to your Kibana spaces.',
})
: intl.formatMessage({
id: 'xpack.security.views.management.editRoles.components.editRoles.accessToKibanaTitle',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accessToKibanaTitle => setPrivilegesToKibanaDescription

defaultMessage: 'Set privileges on your Elasticsearch data and control access to Kibana.',
});

return (
<EuiPage className="editRolePage" restrictWidth>
Expand All @@ -86,7 +97,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.editRoles.reversedRolesTitle"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In most cases text in p tag - it is description, not title.

reversedRolesTitle => modifyingReversedRolesDescription

defaultMessage="Reserved roles are built-in and cannot be removed or modified."
/>
</p>
</EuiText>
</Fragment>
Expand All @@ -110,17 +124,27 @@ export class EditRolePage extends Component<Props, State> {
}

public getFormTitle = () => {
const { intl } = this.props;
let titleText;
const props: HTMLProps<HTMLDivElement> = {
tabIndex: 0,
};
if (isReservedRole(this.props.role)) {
titleText = 'Viewing role';
titleText = intl.formatMessage({
id: 'xpack.security.components.management.user.editUser.viewingRoleTitle',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check ids in this file. Why some of them have .user.editUser? I looks like it should be xpack.security.views.management.editRole.components.editRolePage

defaultMessage: 'Viewing role',
});
props['aria-describedby'] = 'reservedRoleDescription';
} else if (this.editingExistingRole()) {
titleText = 'Edit role';
titleText = intl.formatMessage({
id: 'xpack.security.components.management.user.editUser.editRoleTitle',
defaultMessage: 'Edit role',
});
} else {
titleText = 'Create role';
titleText = intl.formatMessage({
id: 'xpack.security.components.management.user.editUser.createRoleTitle',
defaultMessage: 'Create role',
});
}

return (
Expand All @@ -145,13 +169,22 @@ export class EditRolePage extends Component<Props, State> {
};

public getRoleName = () => {
const { intl } = this.props;

return (
<EuiPanel>
<EuiFormRow
label={'Role name'}
label={intl.formatMessage({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use FormattedMessage instead of intl.formatMessage

id: 'xpack.security.views.management.editRoles.components.editRoles.roleNameTitle',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

roleNameTitle => roleNameFormRowTitle

defaultMessage: 'Role name',
})}
helpText={
!isReservedRole(this.props.role) && this.editingExistingRole()
? "A role's name cannot be changed once it has been created."
? intl.formatMessage({
id:
'xpack.security.views.management.editRoles.components.editRoles.cannotChangeNameTitle',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cannotChangeNameTitle => 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 @@ -224,11 +257,27 @@ export class EditRolePage extends Component<Props, State> {
};

public getFormButtons = () => {
const { intl } = this.props;
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.editRoles.returnToListTitle"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returnToListTitle => returnToRoleListButtonLabel

defaultMessage="Return to role list"
/>
</EuiButton>
);
}

const saveText = this.editingExistingRole() ? 'Update role' : 'Create role';
const saveText = this.editingExistingRole()
? intl.formatMessage({
id: 'xpack.security.views.management.editRoles.components.editRoles.updateRoleOneTitle',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updateRoleOneTitle => updateRoleText

defaultMessage: 'Update role',
})
: intl.formatMessage({
id: 'xpack.security.views.management.editRoles.components.editRoles.createRoleOneTitle',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createRoleOneTitle => createRoleText

defaultMessage: 'Create role',
});

return (
<EuiFlexGroup responsive={false}>
Expand All @@ -244,7 +293,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.editRoles.cancelTitle"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cancelTitle => cancelButtonLabel

defaultMessage="Cancel"
/>
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={true} />
Expand Down Expand Up @@ -274,7 +326,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 +339,12 @@ 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.savedRoleTitle',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

savedRoleTitle => roleSuccessfullySavedNotificationMessage

defaultMessage: 'Saved role',
})
);
this.backToRoleList();
})
.catch((error: any) => {
Expand All @@ -297,11 +354,16 @@ 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.deletedRoleTitle',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deletedRoleTitle => roleSuccessfullyDeletedNotificationMessage

defaultMessage: 'Deleted role',
})
);
this.backToRoleList();
})
.catch((error: any) => {
Expand All @@ -313,3 +375,5 @@ export class EditRolePage extends Component<Props, State> {
window.location.hash = ROLES_PATH;
};
}

export const EditRolePage = injectI18n(EditRolePageUI);
Loading