platform.tsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import {useEffect, useState} from 'react';
  2. import styled from '@emotion/styled';
  3. import {motion} from 'framer-motion';
  4. import ExternalLink from 'sentry/components/links/externalLink';
  5. import MultiPlatformPicker from 'sentry/components/multiPlatformPicker';
  6. import {PlatformKey} from 'sentry/data/platformCategories';
  7. import {t, tct} from 'sentry/locale';
  8. import testableTransition from 'sentry/utils/testableTransition';
  9. import StepHeading from 'sentry/views/onboarding/components/stepHeading';
  10. import CreateProjectsFooter from './components/createProjectsFooter';
  11. import {StepProps} from './types';
  12. import {usePersistedOnboardingState} from './utils';
  13. function OnboardingPlatform(props: StepProps) {
  14. const [selectedPlatforms, setSelectedPlatforms] = useState<PlatformKey[]>([]);
  15. const addPlatform = (platform: PlatformKey) => {
  16. setSelectedPlatforms([...selectedPlatforms, platform]);
  17. };
  18. const removePlatform = (platform: PlatformKey) => {
  19. setSelectedPlatforms(selectedPlatforms.filter(p => p !== platform));
  20. };
  21. const [clientState] = usePersistedOnboardingState();
  22. useEffect(() => {
  23. if (clientState) {
  24. setSelectedPlatforms(clientState.selectedPlatforms);
  25. }
  26. }, [clientState]);
  27. const clearPlatforms = () => setSelectedPlatforms([]);
  28. return (
  29. <Wrapper>
  30. <StepHeading step={props.stepIndex}>
  31. {t('Select the platforms you want to monitor')}
  32. </StepHeading>
  33. <motion.div
  34. transition={testableTransition()}
  35. variants={{
  36. initial: {y: 30, opacity: 0},
  37. animate: {y: 0, opacity: 1},
  38. exit: {opacity: 0},
  39. }}
  40. >
  41. <p>
  42. {tct(
  43. `Variety is the spice of application monitoring. Identify what’s broken
  44. faster by selecting all the platforms that support your application.
  45. [link:View the full list].`,
  46. {link: <ExternalLink href="https://docs.sentry.io/platforms/" />}
  47. )}
  48. </p>
  49. <MultiPlatformPicker
  50. noAutoFilter
  51. source="targeted-onboarding"
  52. {...props}
  53. removePlatform={removePlatform}
  54. addPlatform={addPlatform}
  55. platforms={selectedPlatforms}
  56. />
  57. </motion.div>
  58. <CreateProjectsFooter
  59. {...props}
  60. clearPlatforms={clearPlatforms}
  61. platforms={selectedPlatforms}
  62. />
  63. </Wrapper>
  64. );
  65. }
  66. export default OnboardingPlatform;
  67. const Wrapper = styled('div')`
  68. max-width: 850px;
  69. margin-left: auto;
  70. margin-right: auto;
  71. width: 100%;
  72. `;