misc_pterodactyl-panel/resources/scripts/hoc/RequireServerPermission.tsx

26 lines
673 B
TypeScript
Raw Normal View History

2022-11-25 20:25:03 +00:00
import type { ReactNode } from 'react';
import Can from '@/components/elements/Can';
2021-01-31 02:01:32 +00:00
import { ServerError } from '@/components/elements/ScreenBlock';
export interface RequireServerPermissionProps {
2022-11-25 20:25:03 +00:00
children?: ReactNode;
permissions: string | string[];
}
2022-11-25 20:25:03 +00:00
function RequireServerPermission({ children, permissions }: RequireServerPermissionProps) {
return (
<Can
action={permissions}
renderOnError={
<ServerError title={'Access Denied'} message={'You do not have permission to access this page.'} />
}
>
{children}
</Can>
);
2022-11-25 20:25:03 +00:00
}
export default RequireServerPermission;