From 5ab3ce77746376fa6a0b11b3c6d0d6d4bf48277d Mon Sep 17 00:00:00 2001 From: diegosanmartino Date: Wed, 25 Jan 2017 15:32:16 +0100 Subject: [PATCH 1/3] add boolean properties in UserMenu component --- web/client/components/security/UserMenu.jsx | 24 ++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/web/client/components/security/UserMenu.jsx b/web/client/components/security/UserMenu.jsx index a7eb560a3f..a043217488 100644 --- a/web/client/components/security/UserMenu.jsx +++ b/web/client/components/security/UserMenu.jsx @@ -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 */ @@ -40,6 +43,9 @@ const UserMenu = React.createClass({ return { user: { }, + showAccountInfo: true, + showPasswordChange: true, + showLogout: true, onLogout: () => {}, onPasswordChange: () => {}, displayName: "name", @@ -58,13 +64,25 @@ const UserMenu = React.createClass({ }, renderLoggedTools() { let DropDown = this.props.nav ? NavDropdown : DropdownButton; + let showAccountInfoItem = null; + if (this.props.showAccountInfo) { + showAccountInfoItem = ; + } + let passwordChangeItem = null; + if (this.props.showPasswordChange) { + passwordChangeItem = ; + } + let logoutItem = null; + if (this.props.showLogout) { + logoutItem = ; + } return ( {this.props.user.name} - - + {showAccountInfoItem} + {passwordChangeItem} - + {logoutItem} ); }, renderButtonText() { From fd243ef396e82726a14769004000535703ee82c6 Mon Sep 17 00:00:00 2001 From: diegosanmartino Date: Wed, 25 Jan 2017 16:05:54 +0100 Subject: [PATCH 2/3] used item array --- web/client/components/security/UserMenu.jsx | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/web/client/components/security/UserMenu.jsx b/web/client/components/security/UserMenu.jsx index a043217488..131eb2381d 100644 --- a/web/client/components/security/UserMenu.jsx +++ b/web/client/components/security/UserMenu.jsx @@ -64,25 +64,21 @@ const UserMenu = React.createClass({ }, renderLoggedTools() { let DropDown = this.props.nav ? NavDropdown : DropdownButton; - let showAccountInfoItem = null; + let itemArray = []; if (this.props.showAccountInfo) { - showAccountInfoItem = ; + itemArray.push( ); } - let passwordChangeItem = null; if (this.props.showPasswordChange) { - passwordChangeItem = ; + itemArray.push( ); } - let logoutItem = null; if (this.props.showLogout) { - logoutItem = ; + itemArray.push(); + itemArray.push( ); } return ( {this.props.user.name} - {showAccountInfoItem} - {passwordChangeItem} - - {logoutItem} + {itemArray} ); }, renderButtonText() { From 998e1a0e2213ff4433d357a4dfda63b18f18114b Mon Sep 17 00:00:00 2001 From: diegosanmartino Date: Wed, 25 Jan 2017 16:27:40 +0100 Subject: [PATCH 3/3] add check for divider item --- web/client/components/security/UserMenu.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web/client/components/security/UserMenu.jsx b/web/client/components/security/UserMenu.jsx index 131eb2381d..93316baaa6 100644 --- a/web/client/components/security/UserMenu.jsx +++ b/web/client/components/security/UserMenu.jsx @@ -72,7 +72,9 @@ const UserMenu = React.createClass({ itemArray.push( ); } if (this.props.showLogout) { - itemArray.push(); + if (itemArray.length > 0) { + itemArray.push(); + } itemArray.push( ); } return (