From 1b76c4fd0c5f388214b91e667bc526f27e32ed29 Mon Sep 17 00:00:00 2001 From: Andrey Vasnetsov Date: Tue, 10 Sep 2024 00:28:49 +0200 Subject: [PATCH] hide jwt page if special key is used (#232) * hide jwt page if special key is used * fmt --- src/components/Sidebar/Sidebar.jsx | 6 ++++-- src/pages/Home.jsx | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/Sidebar/Sidebar.jsx b/src/components/Sidebar/Sidebar.jsx index 1191d816..087ccc21 100644 --- a/src/components/Sidebar/Sidebar.jsx +++ b/src/components/Sidebar/Sidebar.jsx @@ -57,7 +57,7 @@ const Drawer = styled(MuiDrawer, { }), })); -export default function Sidebar({ open, version, jwtEnabled }) { +export default function Sidebar({ open, version, jwtEnabled, jwtVisible }) { return ( @@ -69,7 +69,8 @@ export default function Sidebar({ open, version, jwtEnabled }) { {sidebarItem('Datasets', , '/datasets', open)} - {sidebarItem('Access Tokens', , '/jwt', open, jwtEnabled)} + + {jwtVisible && sidebarItem('Access Tokens', , '/jwt', open, jwtEnabled)} @@ -116,4 +117,5 @@ Sidebar.propTypes = { open: PropTypes.bool, version: PropTypes.string, jwtEnabled: PropTypes.bool, + jwtVisible: PropTypes.bool, }; diff --git a/src/pages/Home.jsx b/src/pages/Home.jsx index 7d69d48f..c8501e8d 100644 --- a/src/pages/Home.jsx +++ b/src/pages/Home.jsx @@ -28,6 +28,7 @@ export default function MiniDrawer() { const [open, setOpen] = React.useState(false); const [version, setVersion] = useState('???'); const [jwtEnabled, setJwtEnabled] = useState(false); + const [jwtVisible, setJwtVisible] = useState(true); const colorMode = React.useContext(ColorModeContext); const [apiKeyDialogOpen, setApiKeyDialogOpen] = useState(false); @@ -38,6 +39,10 @@ export default function MiniDrawer() { const telemetry = await qdrantClient.api('service').telemetry(); setVersion(telemetry.data.result.app.version); setJwtEnabled(telemetry.data.result.app?.jwt_rbac || false); + + if (telemetry.data.result.app?.hide_jwt_dashboard) { + setJwtVisible(false); + } } catch (error) { if (error.status === 403 || error.status === 401) { setApiKeyDialogOpen(true); @@ -98,7 +103,7 @@ export default function MiniDrawer() { - +