platformPickerPanel.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. export function PlatformPickerPanel({onSelect}: Props) {
  40. return (
  41. <OnboardingPanel image={<img src={onboardingImg} />}>
  42. <OnboardingTitle>{t('Monitor Your Cron Jobs')}</OnboardingTitle>
  43. <p>
  44. {t(
  45. "We'll tell you if your recurring jobs are running on schedule, failing, or succeeding."
  46. )}
  47. </p>
  48. <SectionTitle>{t('Platforms')}</SectionTitle>
  49. <Actions>
  50. {CRON_SDK_PLATFORMS.map(({platform, label}) => (
  51. <PlatformOption key={platform}>
  52. <PlatformButton
  53. priority="default"
  54. onClick={() => onSelect(platform)}
  55. aria-label={t('Create %s Monitor', platform)}
  56. >
  57. <PlatformIcon platform={platform} format="lg" size="100%" />
  58. </PlatformButton>
  59. <div>{label}</div>
  60. </PlatformOption>
  61. ))}
  62. </Actions>
  63. <SectionTitle>{t('Generic')}</SectionTitle>
  64. <Actions>
  65. <NewMonitorButton size="sm" priority="default">
  66. Sentry CLI
  67. </NewMonitorButton>
  68. <NewMonitorButton size="sm" priority="default">
  69. HTTP (cURL)
  70. </NewMonitorButton>
  71. </Actions>
  72. </OnboardingPanel>
  73. );
  74. }
  75. const OnboardingTitle = styled('h3')`
  76. margin-bottom: ${space(1)};
  77. `;
  78. const SectionTitle = styled('h5')`
  79. font-size: ${p => p.theme.fontSizeSmall};
  80. color: ${p => p.theme.subText};
  81. text-transform: uppercase;
  82. margin-bottom: ${space(1)};
  83. margin-top: ${space(4)};
  84. `;
  85. const Actions = styled('div')`
  86. display: flex;
  87. gap: ${space(2)};
  88. flex-wrap: wrap;
  89. `;
  90. const PlatformButton = styled(Button)`
  91. width: 80px;
  92. height: 80px;
  93. padding: ${space(1.5)};
  94. `;
  95. const PlatformOption = styled('div')`
  96. display: flex;
  97. flex-direction: column;
  98. gap: ${space(0.5)};
  99. align-items: center;
  100. color: ${p => p.theme.subText};
  101. `;