newTokenHandler.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import type {MouseEventHandler} from 'react';
  2. import styled from '@emotion/styled';
  3. import Alert from 'sentry/components/alert';
  4. import {Button} from 'sentry/components/button';
  5. import FieldGroup from 'sentry/components/forms/fieldGroup';
  6. import PanelItem from 'sentry/components/panels/panelItem';
  7. import TextCopyInput from 'sentry/components/textCopyInput';
  8. import {t} from 'sentry/locale';
  9. import {space} from 'sentry/styles/space';
  10. function NewTokenHandler({
  11. token,
  12. handleGoBack,
  13. }: {
  14. handleGoBack: MouseEventHandler;
  15. token: string;
  16. }) {
  17. return (
  18. <div>
  19. <Alert type="warning" showIcon system>
  20. {t("Please copy this token to a safe place — it won't be shown again!")}
  21. </Alert>
  22. <PanelItem>
  23. <InputWrapper>
  24. <FieldGroupNoPadding
  25. label={t('Token')}
  26. help={t('You can only view this token when it was created.')}
  27. inline
  28. flexibleControlStateSize
  29. >
  30. <TextCopyInput aria-label={t('Generated token')}>{token}</TextCopyInput>
  31. </FieldGroupNoPadding>
  32. </InputWrapper>
  33. </PanelItem>
  34. <PanelItem>
  35. <ButtonWrapper>
  36. <Button onClick={handleGoBack} priority="primary">
  37. {t('Done')}
  38. </Button>
  39. </ButtonWrapper>
  40. </PanelItem>
  41. </div>
  42. );
  43. }
  44. const InputWrapper = styled('div')`
  45. flex: 1;
  46. `;
  47. const FieldGroupNoPadding = styled(FieldGroup)`
  48. padding: 0;
  49. `;
  50. const ButtonWrapper = styled('div')`
  51. margin-left: auto;
  52. display: flex;
  53. flex-direction: column;
  54. align-items: flex-end;
  55. font-size: ${p => p.theme.fontSizeSmall};
  56. gap: ${space(1)};
  57. `;
  58. export default NewTokenHandler;