getStarted.tsx 4.1 KB

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