index.tsx 687 B

12345678910111213141516171819202122232425
  1. import {cloneElement, isValidElement} from 'react';
  2. import NoProjectMessage from 'sentry/components/noProjectMessage';
  3. import useOrganization from 'sentry/utils/useOrganization';
  4. type Props = {
  5. children: React.ReactNode;
  6. };
  7. function AlertsContainer({children}: Props) {
  8. const organization = useOrganization();
  9. const hasMetricAlerts = organization.features.includes('incidents');
  10. const content =
  11. children && isValidElement(children)
  12. ? cloneElement<any>(children, {
  13. organization,
  14. hasMetricAlerts,
  15. })
  16. : children;
  17. return <NoProjectMessage organization={organization}>{content}</NoProjectMessage>;
  18. }
  19. export default AlertsContainer;