platformPickerPanel.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. interface SDKPlatformInfo {
  19. label: string;
  20. platform: SupportedPlatform;
  21. }
  22. export const CRON_SDK_PLATFORMS: SDKPlatformInfo[] = [
  23. {platform: 'python-celery', label: 'Celery'},
  24. {platform: 'php', label: 'PHP'},
  25. {platform: 'php-laravel', label: 'Laravel'},
  26. {platform: 'python', label: 'Python'},
  27. {platform: 'node', label: 'Node'},
  28. {platform: 'go', label: 'Go'},
  29. {platform: 'java', label: 'Java'},
  30. {platform: 'java-spring-boot', label: 'Spring Boot'},
  31. ];
  32. interface Props {
  33. onSelect: (platform: SupportedPlatform | null) => void;
  34. }
  35. export function PlatformPickerPanel({onSelect}: Props) {
  36. return (
  37. <OnboardingPanel image={<img src={onboardingImg} />}>
  38. <OnboardingTitle>{t('Monitor Your Cron Jobs')}</OnboardingTitle>
  39. <p>
  40. {t(
  41. "We'll tell you if your recurring jobs are running on schedule, failing, or succeeding."
  42. )}
  43. </p>
  44. <SectionTitle>{t('Platforms')}</SectionTitle>
  45. <Actions>
  46. {CRON_SDK_PLATFORMS.map(({platform, label}) => (
  47. <PlatformOption key={platform}>
  48. <PlatformButton
  49. priority="default"
  50. onClick={() => onSelect(platform)}
  51. aria-label={t('Create %s Monitor', platform)}
  52. >
  53. <PlatformIcon platform={platform} format="lg" size="100%" />
  54. </PlatformButton>
  55. <div>{label}</div>
  56. </PlatformOption>
  57. ))}
  58. </Actions>
  59. <SectionTitle>{t('Generic')}</SectionTitle>
  60. <Actions>
  61. <NewMonitorButton size="sm" priority="default">
  62. Sentry CLI
  63. </NewMonitorButton>
  64. <NewMonitorButton size="sm" priority="default">
  65. HTTP (cURL)
  66. </NewMonitorButton>
  67. </Actions>
  68. </OnboardingPanel>
  69. );
  70. }
  71. const OnboardingTitle = styled('h3')`
  72. margin-bottom: ${space(1)};
  73. `;
  74. const SectionTitle = styled('h5')`
  75. font-size: ${p => p.theme.fontSizeSmall};
  76. color: ${p => p.theme.subText};
  77. text-transform: uppercase;
  78. margin-bottom: ${space(1)};
  79. margin-top: ${space(4)};
  80. `;
  81. const Actions = styled('div')`
  82. display: flex;
  83. gap: ${space(2)};
  84. flex-wrap: wrap;
  85. `;
  86. const PlatformButton = styled(Button)`
  87. width: 80px;
  88. height: 80px;
  89. padding: ${space(1.5)};
  90. `;
  91. const PlatformOption = styled('div')`
  92. display: flex;
  93. flex-direction: column;
  94. gap: ${space(0.5)};
  95. align-items: center;
  96. color: ${p => p.theme.subText};
  97. `;