[FIX] Show admin panel button logic (#1220)
This commit is contained in:
parent
f29b9aaa75
commit
31d03ff5e5
|
@ -40,7 +40,8 @@ class Sidebar extends Component {
|
||||||
Site_Name: PropTypes.string.isRequired,
|
Site_Name: PropTypes.string.isRequired,
|
||||||
user: PropTypes.object,
|
user: PropTypes.object,
|
||||||
logout: PropTypes.func.isRequired,
|
logout: PropTypes.func.isRequired,
|
||||||
activeItemKey: PropTypes.string
|
activeItemKey: PropTypes.string,
|
||||||
|
loadingServer: PropTypes.bool
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -58,14 +59,17 @@ class Sidebar extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
const { user } = this.props;
|
const { user, loadingServer } = this.props;
|
||||||
if (nextProps.user && user && user.language !== nextProps.user.language) {
|
if (nextProps.user && user && user.language !== nextProps.user.language) {
|
||||||
this.setStatus();
|
this.setStatus();
|
||||||
}
|
}
|
||||||
|
if (loadingServer && nextProps.loadingServer !== loadingServer) {
|
||||||
|
this.setIsAdmin();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps, nextState) {
|
shouldComponentUpdate(nextProps, nextState) {
|
||||||
const { status, showStatus } = this.state;
|
const { status, showStatus, isAdmin } = this.state;
|
||||||
const {
|
const {
|
||||||
Site_Name, user, baseUrl, activeItemKey
|
Site_Name, user, baseUrl, activeItemKey
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
@ -98,6 +102,9 @@ class Sidebar extends Component {
|
||||||
if (!equal(nextState.status, status)) {
|
if (!equal(nextState.status, status)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (nextState.isAdmin !== isAdmin) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +295,8 @@ const mapStateToProps = state => ({
|
||||||
token: state.login.user && state.login.user.token,
|
token: state.login.user && state.login.user.token,
|
||||||
roles: state.login.user && state.login.user.roles
|
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 => ({
|
const mapDispatchToProps = dispatch => ({
|
||||||
|
|
Loading…
Reference in New Issue