Skip to content

Commit

Permalink
Check for permission when displaying debug bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
jvorcak committed Oct 25, 2024
1 parent 147fbd4 commit 5759a0d
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 41 deletions.
62 changes: 34 additions & 28 deletions frontend/src/components/pages/admin/AdminPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,41 +47,47 @@ export default class AdminPage extends PageComponent {
if (api.adminInfo === undefined) return DefaultSkeleton;
const hasAdminPermissions = api.adminInfo !== null;

const items = [
{
key: 'users',
name: 'Users',
component: <AdminUsers />
},
{
key: 'roles',
name: 'Roles',
component: <AdminRoles />
},
{
key: 'permissionsDebug',
name: 'Permissions debug',
component: <code><pre>{toJson(api.adminInfo, 4)}</pre></code>
},
]

if(api.userData?.canViewDebugBundle) {
items.push({
key: 'debugBundle',
name: 'Debug bundle',
component: <AdminDebugBundle/>
});
}

items.push({
key: 'licenses',
name: 'License details',
component: <AdminLicenses />
})

return <PageContent>
<Section>
{hasAdminPermissions ?
<Tabs size="lg" items={[
{
key: 'users',
name: 'Users',
component: <AdminUsers />
},
{
key: 'roles',
name: 'Roles',
component: <AdminRoles />
},
{
key: 'permissionsDebug',
name: 'Permissions debug',
component: <code><pre>{toJson(api.adminInfo, 4)}</pre></code>
},
{
key: 'debugBundle',
name: 'Debug bundle',
component: <AdminDebugBundle />
},
{
key: 'licenses',
name: 'License details',
component: <AdminLicenses />
},
]} />
<Tabs size="lg" items={items} />

: <div>
<Alert status="error">
<AlertIcon />
You do not have the neccesary permissions to view this page.
You do not have the necessary permissions to view this page.
</Alert>
</div>
}
Expand Down
28 changes: 15 additions & 13 deletions frontend/src/components/pages/overview/ClusterHealthOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,21 @@ const ClusterHealthOverview = () => {
</Flex>
</Grid>
</ListItem>}
<ListItem>
<Grid
templateColumns={{sm: '1fr', md: '1fr 1fr'}}
gap={4}
>
<Box fontWeight="bold">Debug bundle</Box>
<Flex gap={2}>
{api.isDebugBundleInProgress && <Button px={0} as={ReactRouterLink} variant="link" to={`/admin/debug-bundle/progress/${api.debugBundleStatus?.jobId}`}>Bundle generation in progress...</Button>}
{api.isDebugBundleReady && <DebugBundleLink statuses={api.debugBundleStatuses} showDatetime={false} />}
{!api.isDebugBundleInProgress && <Button px={0} as={ReactRouterLink} variant="link" to="/admin/debug-bundle/new">Generate new</Button>}
</Flex>
</Grid>
</ListItem>
{api.userData?.canViewDebugBundle &&
<ListItem>
<Grid
templateColumns={{sm: '1fr', md: '1fr 1fr'}}
gap={4}
>
<Box fontWeight="bold">Debug bundle</Box>
<Flex gap={2}>
{api.isDebugBundleInProgress && <Button px={0} as={ReactRouterLink} variant="link" to={`/admin/debug-bundle/progress/${api.debugBundleStatus?.jobId}`}>Bundle generation in progress...</Button>}
{api.isDebugBundleReady && <DebugBundleLink statuses={api.debugBundleStatuses} showDatetime={false}/>}
{!api.isDebugBundleInProgress && <Button px={0} as={ReactRouterLink} variant="link" to="/admin/debug-bundle/new">Generate new</Button>}
</Flex>
</Grid>
</ListItem>
}
</List>
</Box>
);
Expand Down
1 change: 1 addition & 0 deletions frontend/src/state/restInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ export interface UserData {
canCreateSchemas: boolean;
canDeleteSchemas: boolean;
canManageSchemaRegistry: boolean;
canViewDebugBundle: boolean;

canListTransforms: boolean;
canCreateTransforms: boolean;
Expand Down

0 comments on commit 5759a0d

Please sign in to comment.