getStarted.tsx 4.1 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 {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.url}))}
  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. 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. `;