permissionAlert.tsx 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. import Access from 'sentry/components/acl/access';
  2. import {Alert} from 'sentry/components/alert';
  3. import {t} from 'sentry/locale';
  4. import type {Scope} from 'sentry/types/core';
  5. import type {Team} from 'sentry/types/organization';
  6. import type {Project} from 'sentry/types/project';
  7. interface Props extends React.ComponentPropsWithoutRef<typeof Alert> {
  8. access?: Scope[];
  9. project?: Project | null | undefined;
  10. team?: Team | null | undefined;
  11. }
  12. export const permissionAlertText = t(
  13. 'These settings can only be edited by users with the organization-level owner, manager, or team-level admin roles.'
  14. );
  15. function PermissionAlert({access = ['project:write'], project, team, ...props}: Props) {
  16. return (
  17. <Access access={access} project={project} team={team}>
  18. {({hasAccess}) =>
  19. !hasAccess && (
  20. <Alert data-test-id="project-permission-alert" type="warning" {...props}>
  21. {permissionAlertText}
  22. </Alert>
  23. )
  24. }
  25. </Access>
  26. );
  27. }
  28. export default PermissionAlert;