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/users component #23940

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
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 @@ -9,7 +9,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 @@ -7,52 +7,86 @@
import React, { Component, Fragment } from 'react';
import { EuiOverlayMask, EuiConfirmModal } from '@elastic/eui';
import { toastNotifications } from 'ui/notify';
export class ConfirmDelete extends Component {
import { FormattedMessage, injectI18n } from '@kbn/i18n/react';

export class ConfirmDeleteUI extends Component {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove export.

deleteUsers = () => {
const { usersToDelete, apiClient, callback } = this.props;
const errors = [];
usersToDelete.forEach(async username => {
try {
await apiClient.deleteUser(username);
toastNotifications.addSuccess(`Deleted user ${username}`);
toastNotifications.addSuccess(
this.props.intl.formatMessage({
id: "xpack.security.components.management.users.confirmDelete.userSuccessfullyDeletedNotificationMessage",
Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove components. from all ids here and in Roles PR.

defaultMessage: "Deleted user {username}"
}, { username })
);
} catch (e) {
errors.push(username);
toastNotifications.addDanger(`Error deleting user ${username}`);
toastNotifications.addDanger(
this.props.intl.formatMessage({
id: "xpack.security.components.management.users.confirmDelete.userDeletingErrorNotificationMessage",
defaultMessage: "Error deleting user {username}"
}, { username })
);
}
if (callback) {
callback(usersToDelete, errors);
}
});
};
render() {
const { usersToDelete, onCancel } = this.props;
const { usersToDelete, onCancel, intl } = this.props;
const moreThanOne = usersToDelete.length > 1;
const title = moreThanOne
? `Delete ${usersToDelete.length} users`
: `Delete user '${usersToDelete[0]}'`;
? intl.formatMessage({
id: "xpack.security.components.management.users.confirmDelete.deleteMultipleUsersTitle",
defaultMessage: "Delete {userLength} users"
}, { userLength: usersToDelete.length })
: intl.formatMessage({
id: "xpack.security.components.management.users.confirmDelete.deleteOneUserTitle",
defaultMessage: "Delete user {userLength}"
}, { userLength: usersToDelete[0] });
return (
<EuiOverlayMask>
<EuiConfirmModal
title={title}
onCancel={onCancel}
onConfirm={this.deleteUsers}
cancelButtonText="Cancel"
confirmButtonText="Delete"
cancelButtonText={intl.formatMessage({
id: "xpack.security.components.management.users.confirmDelete.cancelButtonLabel",
defaultMessage: "Cancel"
})}
confirmButtonText={intl.formatMessage({
id: "xpack.security.components.management.users.confirmDelete.confirmButtonLabel",
defaultMessage: "Delete"
})}
buttonColor="danger"
>
<div>
{moreThanOne ? (
<Fragment>
<p>
You are about to delete these users:
<FormattedMessage
id="xpack.security.components.management.users.confirmDelete.removingUsersDescription"
defaultMessage="You are about to delete these users:"
/>
</p>
<ul>{usersToDelete.map(username => <li key={username}>{username}</li>)}</ul>
</Fragment>
) : null}
<p>This operation cannot be undone.</p>
<p>
<FormattedMessage
id="xpack.security.components.management.users.confirmDelete.removingUsersWarningMessage"
defaultMessage="This operation cannot be undone."
/>
</p>
</div>
</EuiConfirmModal>
</EuiOverlayMask>
);
}
}

export const ConfirmDelete = injectI18n(ConfirmDeleteUI);
Loading