From 31d03ff5e57263f6d3c51197886a115aa0080575 Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Tue, 24 Sep 2019 17:10:50 -0300 Subject: [PATCH] [FIX] Show admin panel button logic (#1220) --- app/views/SidebarView/index.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/views/SidebarView/index.js b/app/views/SidebarView/index.js index 1341e284f..9e008071c 100644 --- a/app/views/SidebarView/index.js +++ b/app/views/SidebarView/index.js @@ -40,7 +40,8 @@ class Sidebar extends Component { Site_Name: PropTypes.string.isRequired, user: PropTypes.object, logout: PropTypes.func.isRequired, - activeItemKey: PropTypes.string + activeItemKey: PropTypes.string, + loadingServer: PropTypes.bool } constructor(props) { @@ -58,14 +59,17 @@ class Sidebar extends Component { } componentWillReceiveProps(nextProps) { - const { user } = this.props; + const { user, loadingServer } = this.props; if (nextProps.user && user && user.language !== nextProps.user.language) { this.setStatus(); } + if (loadingServer && nextProps.loadingServer !== loadingServer) { + this.setIsAdmin(); + } } shouldComponentUpdate(nextProps, nextState) { - const { status, showStatus } = this.state; + const { status, showStatus, isAdmin } = this.state; const { Site_Name, user, baseUrl, activeItemKey } = this.props; @@ -98,6 +102,9 @@ class Sidebar extends Component { if (!equal(nextState.status, status)) { return true; } + if (nextState.isAdmin !== isAdmin) { + return true; + } return false; } @@ -288,7 +295,8 @@ const mapStateToProps = state => ({ token: state.login.user && state.login.user.token, roles: state.login.user && state.login.user.roles }, - baseUrl: state.settings.Site_Url || state.server ? state.server.server : '' + baseUrl: state.settings.Site_Url || state.server ? state.server.server : '', + loadingServer: state.server.loading }); const mapDispatchToProps = dispatch => ({