newSecretHandler.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. import type {MouseEventHandler} from 'react';
  2. import styled from '@emotion/styled';
  3. import {Button} from 'sentry/components/button';
  4. import {Alert} from 'sentry/components/core/alert';
  5. import {PROVIDER_TO_SETUP_WEBHOOK_URL} from 'sentry/components/events/featureFlags/utils';
  6. import FieldGroup from 'sentry/components/forms/fieldGroup';
  7. import ExternalLink from 'sentry/components/links/externalLink';
  8. import PanelItem from 'sentry/components/panels/panelItem';
  9. import TextCopyInput from 'sentry/components/textCopyInput';
  10. import {t, tct} from 'sentry/locale';
  11. import {space} from 'sentry/styles/space';
  12. import useOrganization from 'sentry/utils/useOrganization';
  13. function NewSecretHandler({
  14. secret,
  15. provider,
  16. onGoBack,
  17. }: {
  18. onGoBack: MouseEventHandler;
  19. provider: string;
  20. secret: string;
  21. }) {
  22. const organization = useOrganization();
  23. return (
  24. <div>
  25. <Alert type="success" showIcon system>
  26. {t('The secret has been posted.')}
  27. </Alert>
  28. <StyledPanelItem>
  29. <InputWrapper>
  30. <StyledFieldGroup
  31. label={t('Webhook URL')}
  32. help={tct(
  33. "Create a webhook integration with your [link:feature flag service]. When you do so, you'll need to enter this URL.",
  34. {
  35. link: (
  36. <ExternalLink
  37. href={
  38. PROVIDER_TO_SETUP_WEBHOOK_URL[
  39. provider.toLowerCase() as keyof typeof PROVIDER_TO_SETUP_WEBHOOK_URL
  40. ]
  41. }
  42. />
  43. ),
  44. }
  45. )}
  46. inline
  47. flexibleControlStateSize
  48. >
  49. <TextCopyInput
  50. aria-label={t('Webhook URL')}
  51. >{`https://sentry.io/api/0/organizations/${organization.slug}/flags/hooks/provider/${provider.toLowerCase()}/`}</TextCopyInput>
  52. </StyledFieldGroup>
  53. <StyledFieldGroup
  54. label={t('Secret')}
  55. help={t(
  56. 'The secret should not be shared and will not be retrievable once you leave this page.'
  57. )}
  58. inline
  59. flexibleControlStateSize
  60. >
  61. <TextCopyInput aria-label={t('Secret')}>{secret}</TextCopyInput>
  62. </StyledFieldGroup>
  63. </InputWrapper>
  64. </StyledPanelItem>
  65. <StyledPanelItem>
  66. <ButtonWrapper>
  67. <Button onClick={onGoBack} priority="primary">
  68. {t('Done')}
  69. </Button>
  70. </ButtonWrapper>
  71. </StyledPanelItem>
  72. </div>
  73. );
  74. }
  75. const InputWrapper = styled('div')`
  76. flex: 1;
  77. `;
  78. const StyledFieldGroup = styled(FieldGroup)`
  79. padding: ${space(1)};
  80. `;
  81. const ButtonWrapper = styled('div')`
  82. margin-left: auto;
  83. display: flex;
  84. flex-direction: column;
  85. align-items: flex-end;
  86. font-size: ${p => p.theme.fontSizeSmall};
  87. gap: ${space(1)};
  88. `;
  89. const StyledPanelItem = styled(PanelItem)`
  90. padding: ${space(1.5)};
  91. `;
  92. export default NewSecretHandler;