newMonitorButton.tsx 938 B

12345678910111213141516171819202122232425262728293031
  1. import type {LinkButtonProps} from 'sentry/components/button';
  2. import {LinkButton} from 'sentry/components/button';
  3. import useOrganization from 'sentry/utils/useOrganization';
  4. import usePageFilters from 'sentry/utils/usePageFilters';
  5. interface Props extends Omit<LinkButtonProps, 'to' | 'external'> {
  6. /**
  7. * TODO(epurkhiser): Remove once crons exists only in alerts
  8. */
  9. linkToAlerts?: boolean;
  10. }
  11. export function NewMonitorButton({linkToAlerts, ...props}: Props) {
  12. const organization = useOrganization();
  13. const {selection} = usePageFilters();
  14. return (
  15. <LinkButton
  16. to={{
  17. pathname: linkToAlerts
  18. ? `/organizations/${organization.slug}/alerts/new/crons/`
  19. : `/organizations/${organization.slug}/crons/create/`,
  20. query: linkToAlerts ? undefined : {project: selection.projects},
  21. }}
  22. priority="primary"
  23. {...props}
  24. >
  25. {props.children}
  26. </LinkButton>
  27. );
  28. }