platformPickerPanel.tsx 2.7 KB

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