From bd6f961d0305179a6b23833f2f6d6b67b21b2249 Mon Sep 17 00:00:00 2001 From: hexxa Date: Wed, 25 Aug 2021 14:49:06 +0800 Subject: [PATCH] fix(ui/topbar): admin panel is not refreshed in loading --- src/client/web/src/components/topbar.tsx | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/client/web/src/components/topbar.tsx b/src/client/web/src/components/topbar.tsx index 6b92482..13c51aa 100644 --- a/src/client/web/src/components/topbar.tsx +++ b/src/client/web/src/components/topbar.tsx @@ -18,9 +18,24 @@ export class TopBar extends React.Component { this.props.update(updater().updatePanes); }; - showAdmin = () => { - updater().displayPane("admin"); - this.props.update(updater().updatePanes); + showAdmin = async () => { + return updater() + .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() {