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

add boolean properties in UserMenu component (issue 1402) #1404

Merged
merged 3 commits into from
Jan 25, 2017
Merged
Changes from all 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
24 changes: 20 additions & 4 deletions web/client/components/security/UserMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const UserMenu = React.createClass({
// PROPS
user: React.PropTypes.object,
displayName: React.PropTypes.string,
showAccountInfo: React.PropTypes.bool,
showPasswordChange: React.PropTypes.bool,
showLogout: React.PropTypes.bool,
/**
* displayAttributes function to filter attributes to show
*/
Expand All @@ -40,6 +43,9 @@ const UserMenu = React.createClass({
return {
user: {
},
showAccountInfo: true,
showPasswordChange: true,
showLogout: true,
onLogout: () => {},
onPasswordChange: () => {},
displayName: "name",
Expand All @@ -58,13 +64,23 @@ const UserMenu = React.createClass({
},
renderLoggedTools() {
let DropDown = this.props.nav ? NavDropdown : DropdownButton;
let itemArray = [];
if (this.props.showAccountInfo) {
itemArray.push(<MenuItem key="accountInfo" onClick={this.props.onShowAccountInfo}> <Glyphicon glyph="user" /><Message msgId="user.info"/></MenuItem>);
}
if (this.props.showPasswordChange) {
itemArray.push(<MenuItem key="passwordChange" onClick={this.props.onShowChangePassword}> <Glyphicon glyph="asterisk" /> <Message msgId="user.changePwd"/></MenuItem>);
}
if (this.props.showLogout) {
if (itemArray.length > 0) {
itemArray.push(<MenuItem key="divider" divider />);
}
itemArray.push(<MenuItem key="logout" onClick={this.props.onLogout}><Glyphicon glyph="log-out" /> <Message msgId="user.logout"/></MenuItem>);
}
return (
<DropDown id="loginButton" className={this.props.className} pullRight bsStyle="success" title={this.renderButtonText()} {...this.props.menuProps} >
<span key="logged-user"><MenuItem header>{this.props.user.name}</MenuItem></span>
<MenuItem key="accountInfo" onClick={this.props.onShowAccountInfo}> <Glyphicon glyph="user" /><Message msgId="user.info"/></MenuItem>
<MenuItem key="passwordChange" onClick={this.props.onShowChangePassword}> <Glyphicon glyph="asterisk" /> <Message msgId="user.changePwd"/></MenuItem>
<MenuItem key="divider" divider />
<MenuItem key="logout" onClick={this.props.onLogout}><Glyphicon glyph="log-out" /> <Message msgId="user.logout"/></MenuItem>
{itemArray}
</DropDown>);
},
renderButtonText() {
Expand Down