messagingIntegrationModal.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import type {ModalRenderProps} from 'sentry/actionCreators/modal';
  4. import {space} from 'sentry/styles/space';
  5. import type {IntegrationProvider} from 'sentry/types/integrations';
  6. import AddIntegrationRow from 'sentry/views/alerts/rules/issue/addIntegrationRow';
  7. import {IntegrationContext} from 'sentry/views/settings/organizationIntegrations/integrationContext';
  8. type Props = ModalRenderProps & {
  9. headerContent: React.ReactNode;
  10. providers: IntegrationProvider[];
  11. bodyContent?: React.ReactNode;
  12. modalParams?: {[key: string]: string};
  13. onAddIntegration?: () => void;
  14. };
  15. function MessagingIntegrationModal({
  16. closeModal,
  17. Header,
  18. Body,
  19. headerContent,
  20. bodyContent,
  21. providers,
  22. modalParams,
  23. onAddIntegration,
  24. }: Props) {
  25. return (
  26. <Fragment>
  27. <Header closeButton>
  28. <h1>{headerContent}</h1>
  29. </Header>
  30. <Body>
  31. <p>{bodyContent}</p>
  32. <IntegrationsWrapper>
  33. {providers.map(provider => {
  34. return (
  35. <IntegrationContext.Provider
  36. key={provider.key}
  37. value={{
  38. provider: provider,
  39. type: 'first_party',
  40. installStatus: 'Not Installed',
  41. analyticsParams: {
  42. already_installed: false,
  43. view: 'messaging_integration_onboarding',
  44. },
  45. onAddIntegration: onAddIntegration,
  46. ...(modalParams && {modalParams}),
  47. }}
  48. >
  49. <AddIntegrationRow onClick={closeModal} />
  50. </IntegrationContext.Provider>
  51. );
  52. })}
  53. </IntegrationsWrapper>
  54. </Body>
  55. </Fragment>
  56. );
  57. }
  58. const IntegrationsWrapper = styled('div')`
  59. display: flex;
  60. flex-direction: column;
  61. gap: ${space(2)};
  62. `;
  63. export default MessagingIntegrationModal;