missingReleasesButtons.tsx 2.2 KB

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