permissionAlert.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import Access from 'sentry/components/acl/access';
  2. import type {AlertProps} from 'sentry/components/alert';
  3. import {Alert} from 'sentry/components/alert';
  4. import {t} from 'sentry/locale';
  5. import type {Scope} from 'sentry/types/core';
  6. import type {Team} from 'sentry/types/organization';
  7. import type {Project} from 'sentry/types/project';
  8. interface PermissionAlertProps extends Omit<AlertProps, 'type'> {
  9. access?: Scope[];
  10. project?: Project;
  11. team?: Team;
  12. }
  13. export const permissionAlertText = t(
  14. 'These settings can only be edited by users with the organization-level owner, manager, or team-level admin roles.'
  15. );
  16. /**
  17. * @deprecated Use `ProjectPermissionAlert` instead.
  18. */
  19. function PermissionAlert({
  20. access = ['project:write'],
  21. project,
  22. team,
  23. ...props
  24. }: PermissionAlertProps) {
  25. return (
  26. <Access access={access} project={project} team={team}>
  27. {({hasAccess}) =>
  28. !hasAccess && (
  29. <Alert data-test-id="project-permission-alert" type="warning" {...props}>
  30. {permissionAlertText}
  31. </Alert>
  32. )
  33. }
  34. </Access>
  35. );
  36. }
  37. export default PermissionAlert;