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

23 lines
646 B
TypeScript
Raw Permalink Normal View History

import React 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 {
permissions: string | string[];
}
const RequireServerPermission: React.FC<RequireServerPermissionProps> = ({ children, permissions }) => {
return (
<Can
action={permissions}
renderOnError={
<ServerError title={'Access Denied'} message={'You do not have permission to access this page.'} />
}
>
{children}
</Can>
);
};
export default RequireServerPermission;