index.tsx 826 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 {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, organization, project}: Props) {
  12. return (
  13. <Access access={['project:write']} project={project}>
  14. {({hasAccess}) => (
  15. <Fragment>
  16. {isValidElement(children) &&
  17. cloneElement<any>(children, {
  18. organization,
  19. canEditRule: hasAccess,
  20. })}
  21. </Fragment>
  22. )}
  23. </Access>
  24. );
  25. }
  26. export default ProjectAlerts;