platformSelection.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 useOrganization from 'sentry/utils/useOrganization';
  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. export function PlatformSelection(props: StepProps) {
  14. const organization = useOrganization();
  15. const [selectedPlatform, setSelectedPlatform] = useState<PlatformKey | undefined>(
  16. undefined
  17. );
  18. const [clientState, _setClientState] = usePersistedOnboardingState();
  19. useEffect(() => {
  20. if (!clientState) {
  21. return;
  22. }
  23. if (selectedPlatform === undefined) {
  24. setSelectedPlatform(clientState.selectedPlatforms[0]);
  25. }
  26. }, [clientState, selectedPlatform]);
  27. return (
  28. <Wrapper>
  29. <StepHeading step={props.stepIndex}>
  30. {t('Select the platform you want to monitor')}
  31. </StepHeading>
  32. <motion.div
  33. transition={testableTransition()}
  34. variants={{
  35. initial: {y: 30, opacity: 0},
  36. animate: {y: 0, opacity: 1},
  37. exit: {opacity: 0},
  38. }}
  39. >
  40. <p>
  41. {t(
  42. // TODO(Priscila): Shall we create a doc for this onboarding and link it here too?
  43. '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.'
  44. )}
  45. </p>
  46. <PlatformPicker
  47. noAutoFilter
  48. source="targeted-onboarding"
  49. platform={selectedPlatform}
  50. setPlatform={platformKey => {
  51. setSelectedPlatform(platformKey ?? undefined);
  52. }}
  53. organization={organization}
  54. />
  55. </motion.div>
  56. <CreateProjectsFooter
  57. {...props}
  58. organization={organization}
  59. clearPlatforms={() => setSelectedPlatform(undefined)}
  60. platforms={selectedPlatform ? [selectedPlatform] : []}
  61. />
  62. </Wrapper>
  63. );
  64. }
  65. const Wrapper = styled('div')`
  66. max-width: 850px;
  67. margin-left: auto;
  68. margin-right: auto;
  69. width: 100%;
  70. `;