deprecatedPlatform.tsx 2.6 KB

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