missingReleasesButtons.tsx 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import Button from 'sentry/components/button';
  2. import ButtonBar from 'sentry/components/buttonBar';
  3. import FeatureTourModal from 'sentry/components/modals/featureTourModal';
  4. import {t} from 'sentry/locale';
  5. import {Organization} from 'sentry/types';
  6. import {trackAnalyticsEvent} from 'sentry/utils/analytics';
  7. import {RELEASES_TOUR_STEPS} from 'sentry/views/releases/list/releasesPromo';
  8. const DOCS_URL = 'https://docs.sentry.io/product/releases/';
  9. const DOCS_HEALTH_URL = 'https://docs.sentry.io/product/releases/health/';
  10. type Props = {
  11. organization: Organization;
  12. health?: boolean;
  13. projectId?: string;
  14. };
  15. function MissingReleasesButtons({organization, health, projectId}: Props) {
  16. function handleTourAdvance(step: number, duration: number) {
  17. trackAnalyticsEvent({
  18. eventKey: 'project_detail.releases_tour.advance',
  19. eventName: 'Project Detail: Releases Tour Advance',
  20. organization_id: parseInt(organization.id, 10),
  21. project_id: projectId && parseInt(projectId, 10),
  22. step,
  23. duration,
  24. });
  25. }
  26. function handleClose(step: number, duration: number) {
  27. trackAnalyticsEvent({
  28. eventKey: 'project_detail.releases_tour.close',
  29. eventName: 'Project Detail: Releases Tour Close',
  30. organization_id: parseInt(organization.id, 10),
  31. project_id: projectId && parseInt(projectId, 10),
  32. step,
  33. duration,
  34. });
  35. }
  36. return (
  37. <ButtonBar gap={1}>
  38. <Button
  39. size="sm"
  40. priority="primary"
  41. external
  42. href={health ? DOCS_HEALTH_URL : DOCS_URL}
  43. >
  44. {t('Start Setup')}
  45. </Button>
  46. {!health && (
  47. <FeatureTourModal
  48. steps={RELEASES_TOUR_STEPS}
  49. onAdvance={handleTourAdvance}
  50. onCloseModal={handleClose}
  51. doneText={t('Start Setup')}
  52. doneUrl={health ? DOCS_HEALTH_URL : DOCS_URL}
  53. >
  54. {({showModal}) => (
  55. <Button size="sm" onClick={showModal}>
  56. {t('Get Tour')}
  57. </Button>
  58. )}
  59. </FeatureTourModal>
  60. )}
  61. </ButtonBar>
  62. );
  63. }
  64. export default MissingReleasesButtons;