platformSelection.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import {useEffect, useState} from 'react';
  2. import styled from '@emotion/styled';
  3. import {motion} from 'framer-motion';
  4. import PlatformPicker from 'sentry/components/platformPicker';
  5. import {PlatformKey} from 'sentry/data/platformCategories';
  6. import {t} from 'sentry/locale';
  7. import testableTransition from 'sentry/utils/testableTransition';
  8. import StepHeading from 'sentry/views/onboarding/components/stepHeading';
  9. import CreateProjectsFooter from './components/createProjectsFooter';
  10. import {StepProps} from './types';
  11. import {usePersistedOnboardingState} from './utils';
  12. export function PlatformSelection(props: StepProps) {
  13. const [selectedPlatform, setSelectedPlatform] = useState<PlatformKey | undefined>(
  14. undefined
  15. );
  16. const [clientState] = usePersistedOnboardingState();
  17. useEffect(() => {
  18. if (clientState) {
  19. setSelectedPlatform(clientState.selectedPlatforms[0]);
  20. }
  21. }, [clientState]);
  22. return (
  23. <Wrapper>
  24. <StepHeading step={props.stepIndex}>
  25. {t('Select the platform you want to monitor')}
  26. </StepHeading>
  27. <motion.div
  28. transition={testableTransition()}
  29. variants={{
  30. initial: {y: 30, opacity: 0},
  31. animate: {y: 0, opacity: 1},
  32. exit: {opacity: 0},
  33. }}
  34. >
  35. <p>
  36. {t(
  37. // TODO(Priscila): Shall we create a doc for this onboarding and link it here too?
  38. 'Set up a separate project for each part of your application (for example, your API server and frontend client), to quickly pinpoint which part of your application errors are coming from.'
  39. )}
  40. </p>
  41. <PlatformPicker
  42. noAutoFilter
  43. source="targeted-onboarding"
  44. platform={selectedPlatform}
  45. setPlatform={platformKey => {
  46. setSelectedPlatform(platformKey ?? undefined);
  47. }}
  48. organization={props.organization}
  49. />
  50. </motion.div>
  51. <CreateProjectsFooter
  52. {...props}
  53. clearPlatforms={() => setSelectedPlatform(undefined)}
  54. platforms={selectedPlatform ? [selectedPlatform] : []}
  55. />
  56. </Wrapper>
  57. );
  58. }
  59. const Wrapper = styled('div')`
  60. max-width: 850px;
  61. margin-left: auto;
  62. margin-right: auto;
  63. width: 100%;
  64. `;