permissionAlert.tsx 932 B

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