permissionAlert.tsx 880 B

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