Commit 31d03ff5 authored by Djorkaeff Alexandre's avatar Djorkaeff Alexandre Committed by Diego Mello
Browse files

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

parent f29b9aaa
......@@ -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 => ({
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment