Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hide jwt page if special key is used #232

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading