getStarted.tsx 4.3 KB

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