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 => ({