fix(ui/topbar): admin panel is not refreshed in loading

This commit is contained in:
hexxa 2021-08-25 14:49:06 +08:00 committed by Hexxa
parent 9cd6d6f84b
commit bd6f961d03

View file

@ -18,9 +18,24 @@ export class TopBar extends React.Component<Props, State, {}> {
this.props.update(updater().updatePanes); this.props.update(updater().updatePanes);
}; };
showAdmin = () => { showAdmin = async () => {
updater().displayPane("admin"); return updater()
this.props.update(updater().updatePanes); .self()
.then(() => {
// TODO: use props instead
// TODO: remove hardcode role
if (
updater().props.login.authed &&
updater().props.panes.userRole === "admin"
) {
return Promise.all([updater().listRoles(), updater().listUsers()]);
}
})
.then(() => {
updater().displayPane("admin");
this.props.update(updater().updateAdmin);
this.props.update(updater().updatePanes);
});
}; };
render() { render() {