platformPickerPanel.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import styled from '@emotion/styled';
  2. import {PlatformIcon} from 'platformicons';
  3. import onboardingImg from 'sentry-images/spot/onboarding-preview.svg';
  4. import {Button} from 'sentry/components/button';
  5. import OnboardingPanel from 'sentry/components/onboardingPanel';
  6. import {t} from 'sentry/locale';
  7. import {space} from 'sentry/styles/space';
  8. import {NewMonitorButton} from './newMonitorButton';
  9. export type SupportedPlatform =
  10. | 'python-celery'
  11. | 'php'
  12. | 'php-laravel'
  13. | 'python'
  14. | 'node'
  15. | 'go'
  16. | 'java'
  17. | 'java-spring-boot'
  18. | 'ruby'
  19. | 'ruby-rails';
  20. interface SDKPlatformInfo {
  21. label: string;
  22. platform: SupportedPlatform;
  23. }
  24. export const CRON_SDK_PLATFORMS: SDKPlatformInfo[] = [
  25. {platform: 'python-celery', label: 'Celery'},
  26. {platform: 'php', label: 'PHP'},
  27. {platform: 'php-laravel', label: 'Laravel'},
  28. {platform: 'python', label: 'Python'},
  29. {platform: 'node', label: 'Node'},
  30. {platform: 'go', label: 'Go'},
  31. {platform: 'java', label: 'Java'},
  32. {platform: 'java-spring-boot', label: 'Spring Boot'},
  33. {platform: 'ruby', label: 'Ruby'},
  34. {platform: 'ruby-rails', label: 'Rails'},
  35. ];
  36. interface Props {
  37. onSelect: (platform: SupportedPlatform | null) => void;
  38. /**
  39. * TODO(epurkhiser): Remove once crons exists only in alerts
  40. */
  41. linkToAlerts?: boolean;
  42. }
  43. export function PlatformPickerPanel({onSelect, linkToAlerts}: Props) {
  44. return (
  45. <OnboardingPanel image={<img src={onboardingImg} />}>
  46. <OnboardingTitle>{t('Monitor Your Cron Jobs')}</OnboardingTitle>
  47. <p>
  48. {t(
  49. "We'll tell you if your recurring jobs are running on schedule, failing, or succeeding."
  50. )}
  51. </p>
  52. <SectionTitle>{t('Platforms')}</SectionTitle>
  53. <Actions>
  54. {CRON_SDK_PLATFORMS.map(({platform, label}) => (
  55. <PlatformOption key={platform}>
  56. <PlatformButton
  57. priority="default"
  58. onClick={() => onSelect(platform)}
  59. aria-label={t('Create %s Monitor', platform)}
  60. >
  61. <PlatformIcon platform={platform} format="lg" size="100%" />
  62. </PlatformButton>
  63. <div>{label}</div>
  64. </PlatformOption>
  65. ))}
  66. </Actions>
  67. <SectionTitle>{t('Generic')}</SectionTitle>
  68. <Actions>
  69. <NewMonitorButton linkToAlerts={linkToAlerts} size="sm" priority="default">
  70. Sentry CLI
  71. </NewMonitorButton>
  72. <NewMonitorButton linkToAlerts={linkToAlerts} size="sm" priority="default">
  73. HTTP (cURL)
  74. </NewMonitorButton>
  75. </Actions>
  76. </OnboardingPanel>
  77. );
  78. }
  79. const OnboardingTitle = styled('h3')`
  80. margin-bottom: ${space(1)};
  81. `;
  82. const SectionTitle = styled('h5')`
  83. font-size: ${p => p.theme.fontSizeSmall};
  84. color: ${p => p.theme.subText};
  85. text-transform: uppercase;
  86. margin-bottom: ${space(1)};
  87. margin-top: ${space(4)};
  88. `;
  89. const Actions = styled('div')`
  90. display: flex;
  91. gap: ${space(2)};
  92. flex-wrap: wrap;
  93. `;
  94. const PlatformButton = styled(Button)`
  95. width: 80px;
  96. height: 80px;
  97. padding: ${space(1.5)};
  98. `;
  99. const PlatformOption = styled('div')`
  100. display: flex;
  101. flex-direction: column;
  102. gap: ${space(0.5)};
  103. align-items: center;
  104. color: ${p => p.theme.subText};
  105. `;