permissionAlert.tsx 748 B

12345678910111213141516171819202122232425
  1. import * as React from 'react';
  2. import Access from 'app/components/acl/access';
  3. import Alert from 'app/components/alert';
  4. import {IconWarning} from 'app/icons';
  5. import {t} from 'app/locale';
  6. type Props = React.ComponentPropsWithoutRef<typeof Alert> &
  7. Pick<React.ComponentProps<typeof Access>, 'access'>;
  8. const PermissionAlert = ({access = ['project:write'], ...props}: Props) => (
  9. <Access access={access}>
  10. {({hasAccess}) =>
  11. !hasAccess && (
  12. <Alert type="warning" icon={<IconWarning size="xs" />} {...props}>
  13. {t(
  14. 'These settings can only be edited by users with the organization owner, manager, or admin role.'
  15. )}
  16. </Alert>
  17. )
  18. }
  19. </Access>
  20. );
  21. export default PermissionAlert;