index.tsx 759 B

123456789101112131415161718192021222324252627
  1. import {cloneElement, Fragment, isValidElement} from 'react';
  2. import type {RouteComponentProps} from 'react-router';
  3. import Access from 'sentry/components/acl/access';
  4. import {Organization} from 'sentry/types';
  5. interface Props
  6. extends RouteComponentProps<{organizationId: string; projectId: string}, {}> {
  7. children: React.ReactNode;
  8. organization: Organization;
  9. }
  10. const ProjectAlerts = ({children, organization}: Props) => (
  11. <Access organization={organization} access={['project:write']}>
  12. {({hasAccess}) => (
  13. <Fragment>
  14. {isValidElement(children) &&
  15. cloneElement(children, {
  16. organization,
  17. canEditRule: hasAccess,
  18. })}
  19. </Fragment>
  20. )}
  21. </Access>
  22. );
  23. export default ProjectAlerts;