Files
pterodactyl-panel/resources/scripts/components/elements/PermissionRoute.tsx
T
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00

23 lines
603 B
TypeScript

import React from 'react';
import Can from '@/components/elements/Can';
import { AccessDenied } from '@/components/elements/ScreenBlock';
interface Props {
permission: string | string[] | null;
children?: React.ReactNode;
}
const accessDenied = <AccessDenied message={'You do not have permission to access this page.'} />;
export default function PermissionRoute({ permission, children }: Props) {
if (!permission) {
return <>{children}</>;
}
return (
<Can matchAny action={permission} renderOnError={accessDenied}>
{children}
</Can>
);
}