missingReleasesButtons.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import {Button} from 'sentry/components/button';
  2. import ButtonBar from 'sentry/components/buttonBar';
  3. import FeatureTourModal from 'sentry/components/modals/featureTourModal';
  4. import {releaseHealth} from 'sentry/data/platformCategories';
  5. import {t} from 'sentry/locale';
  6. import type {Organization} from 'sentry/types/organization';
  7. import type {PlatformKey} from 'sentry/types/project';
  8. import {trackAnalytics} from 'sentry/utils/analytics';
  9. import {RELEASES_TOUR_STEPS} from 'sentry/views/releases/list/releasesPromo';
  10. const DOCS_URL = 'https://docs.sentry.io/product/releases/';
  11. const DOCS_HEALTH_URL = 'https://docs.sentry.io/product/releases/health/';
  12. type Props = {
  13. organization: Organization;
  14. health?: boolean;
  15. platform?: PlatformKey;
  16. projectId?: string;
  17. };
  18. function MissingReleasesButtons({organization, health, projectId, platform}: Props) {
  19. function handleTourAdvance(step: number, duration: number) {
  20. trackAnalytics('project_detail.releases_tour.advance', {
  21. organization,
  22. project_id: projectId ?? '',
  23. step,
  24. duration,
  25. });
  26. }
  27. function handleClose(step: number, duration: number) {
  28. trackAnalytics('project_detail.releases_tour.close', {
  29. organization,
  30. project_id: projectId ?? '',
  31. step,
  32. duration,
  33. });
  34. }
  35. const setupDisabled = health && platform && !releaseHealth.includes(platform);
  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. disabled={setupDisabled}
  44. title={
  45. setupDisabled
  46. ? t('Release Health is not yet supported on this platform.')
  47. : undefined
  48. }
  49. >
  50. {t('Start Setup')}
  51. </Button>
  52. {!health && (
  53. <FeatureTourModal
  54. steps={RELEASES_TOUR_STEPS}
  55. onAdvance={handleTourAdvance}
  56. onCloseModal={handleClose}
  57. doneText={t('Start Setup')}
  58. doneUrl={health ? DOCS_HEALTH_URL : DOCS_URL}
  59. >
  60. {({showModal}) => (
  61. <Button size="sm" onClick={showModal}>
  62. {t('Get Tour')}
  63. </Button>
  64. )}
  65. </FeatureTourModal>
  66. )}
  67. </ButtonBar>
  68. );
  69. }
  70. export default MissingReleasesButtons;