index.tsx 844 B

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