Skip to content

Commit

Permalink
Redirect Director Metrics if Not Admin
Browse files Browse the repository at this point in the history
- Redirect director metrics if not admin
- Hide navigation options if not admin
- Update AuthenicatedContent to consume static lists to enable easier SSR
  • Loading branch information
CannonLock committed Dec 4, 2024
1 parent 60787ac commit 65b8bd6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
6 changes: 5 additions & 1 deletion web_ui/frontend/app/director/metrics/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import AuthenticatedContent from '@/components/layout/AuthenticatedContent';

const Page = () => {
return (
<AuthenticatedContent allowedRoles={['admin']} trustThenValidate={true} redirect={true}>
<AuthenticatedContent
allowedRoles={['admin']}
trustThenValidate={true}
redirect={true}
>
<Grid container spacing={1} direction={'row'}>
<Grid item xs={5} display={'flex'}>
<Grid container spacing={1}>
Expand Down
5 changes: 1 addition & 4 deletions web_ui/frontend/app/origin/globus/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ import { GlobusExportTable } from '@/components/GlobusExportTable';

export default function Home() {
return (
<AuthenticatedContent
redirect={true}
allowedRoles={['admin']}
>
<AuthenticatedContent redirect={true} allowedRoles={['admin']}>
<Box width={'100%'}>
<Typography variant='h4' mb={2}>
Globus Exports
Expand Down
5 changes: 1 addition & 4 deletions web_ui/frontend/app/origin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ export default function Home() {
};

return (
<AuthenticatedContent
redirect={true}
allowedRoles={['admin']}
>
<AuthenticatedContent redirect={true} allowedRoles={['admin']}>
<Box width={'100%'}>
<Grid container spacing={2}>
<Grid item xs={12} lg={6}>
Expand Down
21 changes: 12 additions & 9 deletions web_ui/frontend/components/DataExportTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
Pagination,
Paper,
Alert,
IconButton, LinearProgress,
IconButton,
LinearProgress,
} from '@mui/material';
import React, { ReactElement, useEffect, useMemo, useState } from 'react';
import { Skeleton } from '@mui/material';
Expand Down Expand Up @@ -353,16 +354,16 @@ export const getExportData = async (): Promise<ExportRes> => {

export const DataExportTable = ({ boxProps }: { boxProps?: BoxProps }) => {
const [pending, setPending] = useState<boolean>(false);
const [ fromUrl, setFromUrl ] = useState<string | undefined>(undefined);
const [fromUrl, setFromUrl] = useState<string | undefined>(undefined);
const { data, error, mutate } = useSWR('getDataExport', getExportData, {
refreshInterval: 10000
refreshInterval: 10000,
});

useEffect(() => {
setFromUrl(window.location.href);
setPending(true);
setTimeout(() => {
mutate()
mutate();
setPending(false);
}, 5000);
}, []);
Expand Down Expand Up @@ -405,12 +406,14 @@ export const DataExportTable = ({ boxProps }: { boxProps?: BoxProps }) => {

return (
<Box {...boxProps}>
{pending &&
<Box display={"flex"} flexDirection={"column"}>
<LinearProgress sx={{mb:1, w: "100%"}} />
<Typography variant={'subtitle2'} color={grey[400]} mx={"auto"}>Checking Registry for Updates</Typography>
{pending && (
<Box display={'flex'} flexDirection={'column'}>
<LinearProgress sx={{ mb: 1, w: '100%' }} />
<Typography variant={'subtitle2'} color={grey[400]} mx={'auto'}>
Checking Registry for Updates
</Typography>
</Box>
}
)}
<Typography pb={1} variant={'h5'} component={'h3'}>
Origin
</Typography>
Expand Down
2 changes: 1 addition & 1 deletion web_ui/frontend/components/layout/AuthenticatedContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const AuthenticatedContent = ({
trustThenValidate = false,
children,
boxProps,
allowedRoles
allowedRoles,
}: AuthenticatedContentProps) => {
if (redirect && promptLogin) {
throw new Error('redirect XOR promptLogin must be true');
Expand Down

0 comments on commit 65b8bd6

Please sign in to comment.