permissionAlert.tsx 801 B

123456789101112131415161718192021222324252627282930313233
  1. import type {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. import type {Scope} from 'sentry/types';
  6. type Props = React.ComponentPropsWithoutRef<typeof Alert> & {
  7. access?: Scope[];
  8. message?: ReactNode;
  9. };
  10. function PermissionAlert({
  11. access = ['org:write'],
  12. message = t(
  13. 'These settings can only be edited by users with the organization owner or manager role.'
  14. ),
  15. ...props
  16. }: Props) {
  17. return (
  18. <Access access={access}>
  19. {({hasAccess}) =>
  20. !hasAccess && (
  21. <Alert data-test-id="org-permission-alert" type="warning" showIcon {...props}>
  22. {message}
  23. </Alert>
  24. )
  25. }
  26. </Access>
  27. );
  28. }
  29. export default PermissionAlert;