publicKey.tsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import {useContext} from 'react';
  2. import {motion} from 'framer-motion';
  3. import LoadingIndicator from 'sentry/components/loadingIndicator';
  4. import {IconFile} from 'sentry/icons/iconFile';
  5. import {t} from 'sentry/locale';
  6. import testableTransition from 'sentry/utils/testableTransition';
  7. import ContinueButton from 'sentry/views/relocation/components/continueButton';
  8. import RelocationCodeBlock from 'sentry/views/relocation/components/relocationCodeBlock';
  9. import StepHeading from 'sentry/views/relocation/components/stepHeading';
  10. import Wrapper from 'sentry/views/relocation/components/wrapper';
  11. import {RelocationOnboardingContext} from 'sentry/views/relocation/relocationOnboardingContext';
  12. import type {StepProps} from './types';
  13. export function PublicKey({publicKeys, onComplete}: StepProps) {
  14. const relocationOnboardingContext = useContext(RelocationOnboardingContext);
  15. const {regionUrl} = relocationOnboardingContext.data;
  16. const publicKey = publicKeys.get(regionUrl);
  17. const handleContinue = (event: any) => {
  18. event.preventDefault();
  19. onComplete();
  20. };
  21. return (
  22. <Wrapper data-test-id="public-key">
  23. <StepHeading step={2}>{t("Save Sentry's public key to your machine")}</StepHeading>
  24. {publicKey ? (
  25. <motion.div
  26. transition={testableTransition()}
  27. variants={{
  28. initial: {y: 30, opacity: 0},
  29. animate: {y: 0, opacity: 1},
  30. exit: {opacity: 0},
  31. }}
  32. >
  33. <p>
  34. {t(
  35. "To do so, you'll need to save the following public key to a file accessible from wherever your self-hosted repository is currently installed. You'll need to have this public key file available for the next step."
  36. )}
  37. </p>
  38. <RelocationCodeBlock
  39. dark
  40. filename="key.pub"
  41. icon={<IconFile />}
  42. hideCopyButton={false}
  43. >
  44. {publicKey}
  45. </RelocationCodeBlock>
  46. <ContinueButton priority="primary" type="submit" onClick={handleContinue} />
  47. </motion.div>
  48. ) : (
  49. <motion.div
  50. transition={testableTransition()}
  51. variants={{
  52. initial: {y: 30, opacity: 0},
  53. animate: {y: 0, opacity: 1},
  54. exit: {opacity: 0},
  55. }}
  56. >
  57. <LoadingIndicator />
  58. </motion.div>
  59. )}
  60. </Wrapper>
  61. );
  62. }
  63. export default PublicKey;