Download web/src/components/AdminOnly.tsx from EnergyVenom/patchwise-agent-studio: direct link, hf CLI and curl.
- Browser
- Download file 1.31 kB
-
https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/web/src/components/AdminOnly.tsx
- Command line
-
hf download hf://spaces/EnergyVenom/patchwise-agent-studio/web/src/components/AdminOnly.tsx
-
curl -L -o AdminOnly.tsx https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/web/src/components/AdminOnly.tsx
1.31 kB
| import { Button, Stack, Text } from '@mantine/core'; | |
| import { IconLock } from '@/components/icons'; | |
| import type { ReactNode } from 'react'; | |
| import { Link } from 'react-router-dom'; | |
| import { useAuth } from '../auth/AuthContext'; | |
| import { PageHeader } from './common'; | |
| /** Admin pages: everyone else gets a proper page that says why and leads back to Home. */ | |
| export function AdminOnly({ children, title = 'Settings' }: { children: ReactNode; title?: string }) { | |
| const { can, user } = useAuth(); | |
| if (can('admin')) return <>{children}</>; | |
| return ( | |
| <Stack gap="md"> | |
| <PageHeader crumbs={[{ label: 'Home', to: '/' }, { label: title }]} title={title} /> | |
| <div className="fpt-card" role="alert" style={{ padding: 20, display: 'flex', gap: 14, alignItems: 'flex-start' }} data-testid="admin-only"> | |
| <span className="trio-tile" aria-hidden><IconLock size={19} stroke={1.7} /></span> | |
| <div> | |
| <Text fw={600}>This page needs the admin role</Text> | |
| <Text size="sm" c="dimmed" mt={2}>You are signed in as {user?.username ?? 'a user'} ({user?.role ?? 'no role'}). Ask an administrator if you need access.</Text> | |
| <Button component={Link} to="/" variant="default" mt="sm">Back to Home</Button> | |
| </div> | |
| </div> | |
| </Stack> | |
| ); | |
| } | |