permissionAlert.tsx 727 B

123456789101112131415161718192021222324252627282930
  1. import {ReactNode} from 'react';
  2. import Access from 'sentry/components/acl/access';
  3. import Alert from 'sentry/components/alert';
  4. import {t} from 'sentry/locale';
  5. type Props = React.ComponentPropsWithoutRef<typeof Alert> &
  6. Pick<React.ComponentProps<typeof Access>, 'access'> & {
  7. message?: ReactNode;
  8. };
  9. const PermissionAlert = ({
  10. access = ['org:write'],
  11. message = t(
  12. 'These settings can only be edited by users with the organization owner or manager role.'
  13. ),
  14. ...props
  15. }: Props) => (
  16. <Access access={access}>
  17. {({hasAccess}) =>
  18. !hasAccess && (
  19. <Alert type="warning" showIcon {...props}>
  20. {message}
  21. </Alert>
  22. )
  23. }
  24. </Access>
  25. );
  26. export default PermissionAlert;