Skip to content

Commit

Permalink
hide jwt page if special key is used (#232)
Browse files Browse the repository at this point in the history
* hide jwt page if special key is used

* fmt
  • Loading branch information
generall authored Sep 9, 2024
1 parent 54f9e8c commit 1b76c4f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/components/Sidebar/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const Drawer = styled(MuiDrawer, {
}),
}));

export default function Sidebar({ open, version, jwtEnabled }) {
export default function Sidebar({ open, version, jwtEnabled, jwtVisible }) {
return (
<Drawer variant="permanent" open={open}>
<DrawerHeader />
Expand All @@ -69,7 +69,8 @@ export default function Sidebar({ open, version, jwtEnabled }) {
<SidebarTutorialSection isSidebarOpen={open} />
</ListItem>
{sidebarItem('Datasets', <Animation />, '/datasets', open)}
{sidebarItem('Access Tokens', <Key />, '/jwt', open, jwtEnabled)}

{jwtVisible && sidebarItem('Access Tokens', <Key />, '/jwt', open, jwtEnabled)}
</List>
<List style={{ marginTop: `auto` }}>
<ListItem>
Expand Down Expand Up @@ -116,4 +117,5 @@ Sidebar.propTypes = {
open: PropTypes.bool,
version: PropTypes.string,
jwtEnabled: PropTypes.bool,
jwtVisible: PropTypes.bool,
};
7 changes: 6 additions & 1 deletion src/pages/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -98,7 +103,7 @@ export default function MiniDrawer() {
</Tooltip>
</Toolbar>
</AppBar>
<Sidebar open={open} version={version} jwtEnabled={jwtEnabled} />
<Sidebar open={open} version={version} jwtEnabled={jwtEnabled} jwtVisible={jwtVisible} />
<Box component="main" sx={{ flexGrow: 1, overflow: 'hidden' }}>
<DrawerHeader />
<Outlet />
Expand Down

0 comments on commit 1b76c4f

Please sign in to comment.