getStarted.tsx 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. import {useContext, useState} from 'react';
  2. import styled from '@emotion/styled';
  3. import {motion} from 'framer-motion';
  4. import {Button} from 'sentry/components/button';
  5. import SelectControl from 'sentry/components/forms/controls/selectControl';
  6. import Input from 'sentry/components/input';
  7. import {RelocationOnboardingContext} from 'sentry/components/onboarding/relocationOnboardingContext';
  8. import {t} from 'sentry/locale';
  9. import ConfigStore from 'sentry/stores/configStore';
  10. import {space} from 'sentry/styles/space';
  11. import testableTransition from 'sentry/utils/testableTransition';
  12. import StepHeading from 'sentry/views/relocation/components/stepHeading';
  13. import {StepProps} from './types';
  14. function GetStarted(props: StepProps) {
  15. const regions = ConfigStore.get('regions');
  16. const [region, setRegion] = useState('');
  17. const [orgSlugs, setOrgSlugs] = useState('');
  18. const relocationOnboardingContext = useContext(RelocationOnboardingContext);
  19. const handleContinue = (event: any) => {
  20. event.preventDefault();
  21. relocationOnboardingContext.setData({orgSlugs, region});
  22. props.onComplete();
  23. };
  24. // TODO(getsentry/team-ospo#214): Make a popup to warn users about data region selection
  25. return (
  26. <Wrapper>
  27. <StepHeading step={1}>{t('Basic information needed to get started')}</StepHeading>
  28. <motion.div
  29. transition={testableTransition()}
  30. variants={{
  31. initial: {y: 30, opacity: 0},
  32. animate: {y: 0, opacity: 1},
  33. exit: {opacity: 0},
  34. }}
  35. >
  36. <Form onSubmit={handleContinue}>
  37. <p>
  38. {t(
  39. 'In order to best facilitate the process some basic information will be required to ensure sucess with the relocation process of you self-hosted instance'
  40. )}
  41. </p>
  42. <RequiredLabel>{t('Organization slugs being relocated')}</RequiredLabel>
  43. <Input
  44. type="text"
  45. name="orgs"
  46. aria-label="org-slugs"
  47. onChange={evt => setOrgSlugs(evt.target.value)}
  48. required
  49. minLength={3}
  50. placeholder="org-slug-1, org-slug-2, ..."
  51. />
  52. <Label>{t('Choose a datacenter region')}</Label>
  53. <RegionSelect
  54. value={region}
  55. name="region"
  56. aria-label="region"
  57. placeholder="Select Region"
  58. options={regions.map(r => ({label: r.name, value: r.name}))}
  59. onChange={opt => setRegion(opt.value)}
  60. />
  61. {region && <p>{t('This is an important decision and cannot be changed.')}</p>}
  62. <ContinueButton
  63. disabled={!orgSlugs || !region}
  64. size="md"
  65. priority="primary"
  66. type="submit"
  67. >
  68. {t('Continue')}
  69. </ContinueButton>
  70. </Form>
  71. </motion.div>
  72. </Wrapper>
  73. );
  74. }
  75. export default GetStarted;
  76. const AnimatedContentWrapper = styled(motion.div)`
  77. overflow: hidden;
  78. `;
  79. AnimatedContentWrapper.defaultProps = {
  80. initial: {
  81. height: 0,
  82. },
  83. animate: {
  84. height: 'auto',
  85. },
  86. exit: {
  87. height: 0,
  88. },
  89. };
  90. const DocsWrapper = styled(motion.div)``;
  91. DocsWrapper.defaultProps = {
  92. initial: {opacity: 0, y: 40},
  93. animate: {opacity: 1, y: 0},
  94. exit: {opacity: 0},
  95. };
  96. const Wrapper = styled('div')`
  97. margin-left: auto;
  98. margin-right: auto;
  99. padding: ${space(4)};
  100. background-color: ${p => p.theme.surface400};
  101. z-index: 100;
  102. box-shadow: 0 5px 10px rgba(0, 0, 0, 0.05);
  103. border-radius: 10px;
  104. max-width: 769px;
  105. max-height: 525px;
  106. color: ${p => p.theme.gray300};
  107. h2 {
  108. color: ${p => p.theme.gray500};
  109. }
  110. `;
  111. const ContinueButton = styled(Button)`
  112. margin-top: ${space(4)};
  113. `;
  114. const Form = styled('form')`
  115. position: relative;
  116. `;
  117. const Label = styled('label')`
  118. display: block;
  119. text-transform: uppercase;
  120. color: ${p => p.theme.gray500};
  121. margin-top: ${space(2)};
  122. `;
  123. const RequiredLabel = styled('label')`
  124. display: block;
  125. text-transform: uppercase;
  126. color: ${p => p.theme.gray500};
  127. margin-top: ${space(2)};
  128. &:after {
  129. content: '•';
  130. width: 6px;
  131. color: ${p => p.theme.red300};
  132. }
  133. `;
  134. const RegionSelect = styled(SelectControl)`
  135. padding-bottom: ${space(2)};
  136. button {
  137. width: 709px;
  138. }
  139. `;