index.tsx 789 B

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