[FIX] Show admin panel button logic (#1220)

This commit is contained in:
Djorkaeff Alexandre 2019-09-24 17:10:50 -03:00 committed by Diego Mello
parent f29b9aaa75
commit 31d03ff5e5
1 changed files with 12 additions and 4 deletions

View File

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