mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 02:09:32 -04:00
* translate login/logout visualization component * Update login/logout component - change injecti18n name to injectI18n * Update login/logout component - make needed changes * update one snapshot * update login translation * update one snapshot * Fix * Fix unit test * Localize logout tooltip
This commit is contained in:
parent
75bc6e9c2b
commit
005bf4d900
9 changed files with 116 additions and 76 deletions
|
@ -16,9 +16,11 @@
|
||||||
<div class="kuiBar kuiVerticalRhythm">
|
<div class="kuiBar kuiVerticalRhythm">
|
||||||
<!-- Title -->
|
<!-- Title -->
|
||||||
<div class="kuiBarSection">
|
<div class="kuiBarSection">
|
||||||
<h1 class="kuiTitle">
|
<h1
|
||||||
Account Settings
|
class="kuiTitle"
|
||||||
</h1>
|
i18n-id="xpack.security.account.accountSettingsTitle"
|
||||||
|
i18n-default-message="Account Settings"
|
||||||
|
></h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Empty section to push content left -->
|
<!-- Empty section to push content left -->
|
||||||
|
@ -27,9 +29,11 @@
|
||||||
|
|
||||||
<!-- Username -->
|
<!-- Username -->
|
||||||
<div class="kuiFormSection kuiVerticalRhythm">
|
<div class="kuiFormSection kuiVerticalRhythm">
|
||||||
<label class="kuiFormLabel">
|
<label
|
||||||
Username
|
class="kuiFormLabel"
|
||||||
</label>
|
i18n-id="xpack.security.account.usernameLabel"
|
||||||
|
i18n-default-message="Username"
|
||||||
|
></label>
|
||||||
<div class="euiText">
|
<div class="euiText">
|
||||||
<p ng-bind="::user.username"></p>
|
<p ng-bind="::user.username"></p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -37,9 +41,11 @@
|
||||||
|
|
||||||
<!-- Email -->
|
<!-- Email -->
|
||||||
<div class="kuiFormSection">
|
<div class="kuiFormSection">
|
||||||
<label class="kuiFormLabel">
|
<label
|
||||||
Email
|
class="kuiFormLabel"
|
||||||
</label>
|
i18n-id="xpack.security.account.emailLabel"
|
||||||
|
i18n-default-message="Email"
|
||||||
|
></label>
|
||||||
<div class="euiText">
|
<div class="euiText">
|
||||||
<p ng-bind="::accountController.getEmail()"></p>
|
<p ng-bind="::accountController.getEmail()"></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -25,7 +25,7 @@ routes.when('/account', {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
controllerAs: 'accountController',
|
controllerAs: 'accountController',
|
||||||
controller($scope, $route, Notifier) {
|
controller($scope, $route, Notifier, i18n) {
|
||||||
$scope.user = $route.current.locals.user;
|
$scope.user = $route.current.locals.user;
|
||||||
|
|
||||||
const notifier = new Notifier();
|
const notifier = new Notifier();
|
||||||
|
@ -38,7 +38,11 @@ routes.when('/account', {
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.user.$changePassword()
|
$scope.user.$changePassword()
|
||||||
.then(() => toastNotifications.addSuccess('Updated password'))
|
.then(() => toastNotifications.addSuccess({
|
||||||
|
title: i18n('xpack.security.account.updatedPasswordTitle', {
|
||||||
|
defaultMessage: 'Updated password'
|
||||||
|
}),
|
||||||
|
}))
|
||||||
.then(onSuccess)
|
.then(onSuccess)
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
if (error.status === 401) {
|
if (error.status === 401) {
|
||||||
|
@ -50,7 +54,9 @@ routes.when('/account', {
|
||||||
|
|
||||||
this.getEmail = () => {
|
this.getEmail = () => {
|
||||||
if ($scope.user.email) return $scope.user.email;
|
if ($scope.user.email) return $scope.user.email;
|
||||||
return '(No email)';
|
return i18n('xpack.security.account.noEmailMessage', {
|
||||||
|
defaultMessage: '(No email)'
|
||||||
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`<KibanaPrivileges> renders without crashing 1`] = `
|
exports[`<KibanaPrivileges> renders without crashing 1`] = `
|
||||||
<I18nProvider>
|
|
||||||
<CollapsiblePanel
|
<CollapsiblePanel
|
||||||
iconType="logoKibana"
|
iconType="logoKibana"
|
||||||
title="Kibana"
|
title="Kibana"
|
||||||
|
@ -54,5 +53,4 @@ exports[`<KibanaPrivileges> renders without crashing 1`] = `
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</CollapsiblePanel>
|
</CollapsiblePanel>
|
||||||
</I18nProvider>
|
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { I18nProvider } from '@kbn/i18n/react';
|
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { Space } from '../../../../../../../../spaces/common/model/space';
|
import { Space } from '../../../../../../../../spaces/common/model/space';
|
||||||
import { UserProfile } from '../../../../../../../../xpack_main/public/services/user_profile';
|
import { UserProfile } from '../../../../../../../../xpack_main/public/services/user_profile';
|
||||||
|
@ -29,11 +28,9 @@ interface Props {
|
||||||
export class KibanaPrivileges extends Component<Props, {}> {
|
export class KibanaPrivileges extends Component<Props, {}> {
|
||||||
public render() {
|
public render() {
|
||||||
return (
|
return (
|
||||||
<I18nProvider>
|
|
||||||
<CollapsiblePanel iconType={'logoKibana'} title={'Kibana'}>
|
<CollapsiblePanel iconType={'logoKibana'} title={'Kibana'}>
|
||||||
{this.getForm()}
|
{this.getForm()}
|
||||||
</CollapsiblePanel>
|
</CollapsiblePanel>
|
||||||
</I18nProvider>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,12 +34,15 @@ const buildProps = (customProps = {}) => {
|
||||||
onChange: jest.fn(),
|
onChange: jest.fn(),
|
||||||
onDelete: jest.fn(),
|
onDelete: jest.fn(),
|
||||||
validator: new RoleValidator(),
|
validator: new RoleValidator(),
|
||||||
|
intl: {} as any,
|
||||||
...customProps,
|
...customProps,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
describe('<PrivilegeSpaceForm>', () => {
|
describe('<PrivilegeSpaceForm>', () => {
|
||||||
it('renders without crashing', () => {
|
it('renders without crashing', () => {
|
||||||
expect(shallowWithIntl(<PrivilegeSpaceForm {...buildProps()} />)).toMatchSnapshot();
|
expect(
|
||||||
|
shallowWithIntl(<PrivilegeSpaceForm.WrappedComponent {...buildProps()} />)
|
||||||
|
).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiFormRow } from '@elastic/eui';
|
import { EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiFormRow } from '@elastic/eui';
|
||||||
import { FormattedMessage } from '@kbn/i18n/react';
|
import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { Space } from '../../../../../../../../spaces/common/model/space';
|
import { Space } from '../../../../../../../../spaces/common/model/space';
|
||||||
import { KibanaPrivilege } from '../../../../../../../common/model/kibana_privilege';
|
import { KibanaPrivilege } from '../../../../../../../common/model/kibana_privilege';
|
||||||
|
@ -26,9 +26,10 @@ interface Props {
|
||||||
) => void;
|
) => void;
|
||||||
onDelete: () => void;
|
onDelete: () => void;
|
||||||
validator: RoleValidator;
|
validator: RoleValidator;
|
||||||
|
intl: InjectedIntl;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class PrivilegeSpaceForm extends Component<Props, {}> {
|
class PrivilegeSpaceFormUI extends Component<Props, {}> {
|
||||||
public render() {
|
public render() {
|
||||||
const {
|
const {
|
||||||
availableSpaces,
|
availableSpaces,
|
||||||
|
@ -36,6 +37,7 @@ export class PrivilegeSpaceForm extends Component<Props, {}> {
|
||||||
availablePrivileges,
|
availablePrivileges,
|
||||||
selectedPrivilege,
|
selectedPrivilege,
|
||||||
validator,
|
validator,
|
||||||
|
intl,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -78,7 +80,11 @@ export class PrivilegeSpaceForm extends Component<Props, {}> {
|
||||||
<EuiFlexItem grow={false}>
|
<EuiFlexItem grow={false}>
|
||||||
<EuiFormRow hasEmptyLabelSpace>
|
<EuiFormRow hasEmptyLabelSpace>
|
||||||
<EuiButtonIcon
|
<EuiButtonIcon
|
||||||
aria-label={'Delete space privilege'}
|
aria-label={intl.formatMessage({
|
||||||
|
id:
|
||||||
|
'xpack.security.management.editRoles.privilegeSpaceForm.deleteSpacePrivilegeAriaLabel',
|
||||||
|
defaultMessage: 'Delete space privilege',
|
||||||
|
})}
|
||||||
color={'danger'}
|
color={'danger'}
|
||||||
onClick={this.props.onDelete}
|
onClick={this.props.onDelete}
|
||||||
iconType={'trash'}
|
iconType={'trash'}
|
||||||
|
@ -103,3 +109,5 @@ export class PrivilegeSpaceForm extends Component<Props, {}> {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const PrivilegeSpaceForm = injectI18n(PrivilegeSpaceFormUI);
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<global-nav-link
|
<global-nav-link
|
||||||
kbn-route="'/logout'"
|
kbn-route="'/logout'"
|
||||||
icon="'plugins/security/images/logout.svg'"
|
icon="'plugins/security/images/logout.svg'"
|
||||||
tooltip-content="formatTooltip('Logout')"
|
tooltip-content="formatTooltip(logoutLabel)"
|
||||||
label="logoutLabel"
|
label="logoutLabel"
|
||||||
></global-nav-link>
|
></global-nav-link>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { I18nProvider } from '@kbn/i18n/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
import { constant } from 'lodash';
|
import { constant } from 'lodash';
|
||||||
|
@ -83,7 +84,12 @@ chromeHeaderNavControlsRegistry.register((ShieldUser, kbnBaseUrl, Private) => ({
|
||||||
|
|
||||||
props.user.$promise.then(() => {
|
props.user.$promise.then(() => {
|
||||||
// Wait for the user to be propogated before rendering into the DOM.
|
// Wait for the user to be propogated before rendering into the DOM.
|
||||||
ReactDOM.render(<SecurityNavControl {...props} />, el);
|
ReactDOM.render(
|
||||||
|
<I18nProvider>
|
||||||
|
<SecurityNavControl {...props} />
|
||||||
|
</I18nProvider>,
|
||||||
|
el
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
return () => ReactDOM.unmountComponentAtNode(el);
|
return () => ReactDOM.unmountComponentAtNode(el);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
* you may not use this file except in compliance with the Elastic License.
|
* you may not use this file except in compliance with the Elastic License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { FormattedMessage } from '@kbn/i18n/react';
|
||||||
import React, {
|
import React, {
|
||||||
Component,
|
Component,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
|
@ -51,7 +52,12 @@ export class SecurityNavControl extends Component {
|
||||||
aria-controls="headerUserMenu"
|
aria-controls="headerUserMenu"
|
||||||
aria-expanded={this.state.isOpen}
|
aria-expanded={this.state.isOpen}
|
||||||
aria-haspopup="true"
|
aria-haspopup="true"
|
||||||
aria-label="Account menu"
|
aria-label={
|
||||||
|
<FormattedMessage
|
||||||
|
id="xpack.security.navControlComponent.accountMenuAriaLabel"
|
||||||
|
defaultMessage="Account menu"
|
||||||
|
/>
|
||||||
|
}
|
||||||
onClick={this.onMenuButtonClick}
|
onClick={this.onMenuButtonClick}
|
||||||
>
|
>
|
||||||
<EuiAvatar name={name} size="s" />
|
<EuiAvatar name={name} size="s" />
|
||||||
|
@ -86,11 +92,21 @@ export class SecurityNavControl extends Component {
|
||||||
<EuiFlexItem>
|
<EuiFlexItem>
|
||||||
<EuiFlexGroup justifyContent="spaceBetween">
|
<EuiFlexGroup justifyContent="spaceBetween">
|
||||||
<EuiFlexItem grow={false}>
|
<EuiFlexItem grow={false}>
|
||||||
<EuiLink href={route}>Edit profile</EuiLink>
|
<EuiLink href={route}>
|
||||||
|
<FormattedMessage
|
||||||
|
id="xpack.security.navControlComponent.editProfileLinkText"
|
||||||
|
defaultMessage="Edit profile"
|
||||||
|
/>
|
||||||
|
</EuiLink>
|
||||||
</EuiFlexItem>
|
</EuiFlexItem>
|
||||||
|
|
||||||
<EuiFlexItem grow={false}>
|
<EuiFlexItem grow={false}>
|
||||||
<EuiLink href="/logout">Log out</EuiLink>
|
<EuiLink href="/logout">
|
||||||
|
<FormattedMessage
|
||||||
|
id="xpack.security.navControlComponent.logoutLinkText"
|
||||||
|
defaultMessage="Log out"
|
||||||
|
/>
|
||||||
|
</EuiLink>
|
||||||
</EuiFlexItem>
|
</EuiFlexItem>
|
||||||
</EuiFlexGroup>
|
</EuiFlexGroup>
|
||||||
</EuiFlexItem>
|
</EuiFlexItem>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue