2021-01-01 17:21:13 +00:00
|
|
|
import React from 'react';
|
|
|
|
import Can from '@/components/elements/Can';
|
2021-01-31 02:01:32 +00:00
|
|
|
import { ServerError } from '@/components/elements/ScreenBlock';
|
|
|
|
|
2021-01-01 17:21:13 +00:00
|
|
|
export interface RequireServerPermissionProps {
|
|
|
|
permissions: string | string[]
|
|
|
|
}
|
|
|
|
|
|
|
|
const RequireServerPermission: React.FC<RequireServerPermissionProps> = ({ children, permissions }) => {
|
|
|
|
return (
|
|
|
|
<Can
|
|
|
|
action={permissions}
|
|
|
|
renderOnError={
|
2021-01-31 02:01:32 +00:00
|
|
|
<ServerError
|
2021-01-01 17:21:13 +00:00
|
|
|
title={'Access Denied'}
|
|
|
|
message={'You do not have permission to access this page.'}
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</Can>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default RequireServerPermission;
|