missingReleasesButtons.tsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 ConfigStore from 'sentry/stores/configStore';
  7. import type {Organization} from 'sentry/types/organization';
  8. import type {PlatformKey} from 'sentry/types/project';
  9. import {trackAnalytics} from 'sentry/utils/analytics';
  10. import {RELEASES_TOUR_STEPS} from 'sentry/views/releases/list/releasesPromo';
  11. const DOCS_URL = 'https://docs.sentry.io/product/releases/';
  12. const DOCS_HEALTH_URL = 'https://docs.sentry.io/product/releases/health/';
  13. type Props = {
  14. organization: Organization;
  15. health?: boolean;
  16. platform?: PlatformKey;
  17. projectId?: string;
  18. };
  19. function MissingReleasesButtons({organization, health, projectId, platform}: Props) {
  20. function handleTourAdvance(step: number, duration: number) {
  21. trackAnalytics('project_detail.releases_tour.advance', {
  22. organization,
  23. project_id: projectId ?? '',
  24. step,
  25. duration,
  26. });
  27. }
  28. function handleClose(step: number, duration: number) {
  29. trackAnalytics('project_detail.releases_tour.close', {
  30. organization,
  31. project_id: projectId ?? '',
  32. step,
  33. duration,
  34. });
  35. }
  36. const isSelfHostedErrorsOnly = ConfigStore.get('isSelfHostedErrorsOnly');
  37. const setupDisabled =
  38. (health && platform && !releaseHealth.includes(platform)) || isSelfHostedErrorsOnly;
  39. const setupDisabledTooltip = isSelfHostedErrorsOnly
  40. ? t('Release health is not available for errors only self-hosted.')
  41. : t('Release Health is not yet supported on this platform.');
  42. return (
  43. <ButtonBar gap={1}>
  44. <Button
  45. size="sm"
  46. priority="primary"
  47. external
  48. href={health ? DOCS_HEALTH_URL : DOCS_URL}
  49. disabled={setupDisabled}
  50. title={setupDisabled ? setupDisabledTooltip : undefined}
  51. >
  52. {t('Start Setup')}
  53. </Button>
  54. {!health && (
  55. <FeatureTourModal
  56. steps={RELEASES_TOUR_STEPS}
  57. onAdvance={handleTourAdvance}
  58. onCloseModal={handleClose}
  59. doneText={t('Start Setup')}
  60. doneUrl={health ? DOCS_HEALTH_URL : DOCS_URL}
  61. >
  62. {({showModal}) => (
  63. <Button size="sm" onClick={showModal}>
  64. {t('Get Tour')}
  65. </Button>
  66. )}
  67. </FeatureTourModal>
  68. )}
  69. </ButtonBar>
  70. );
  71. }
  72. export default MissingReleasesButtons;