sentryAppRuleModal.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import type {ModalRenderProps} from 'sentry/actionCreators/modal';
  4. import {closeModal} from 'sentry/actionCreators/modal';
  5. import {tct} from 'sentry/locale';
  6. import {space} from 'sentry/styles/space';
  7. import type {SchemaFormConfig} from 'sentry/views/settings/organizationIntegrations/sentryAppExternalForm';
  8. import SentryAppExternalForm from 'sentry/views/settings/organizationIntegrations/sentryAppExternalForm';
  9. type Props = ModalRenderProps & {
  10. appName: string;
  11. config: SchemaFormConfig;
  12. onSubmitSuccess: React.ComponentProps<typeof SentryAppExternalForm>['onSubmitSuccess'];
  13. resetValues: {[key: string]: any};
  14. sentryAppInstallationUuid: string;
  15. };
  16. function SentryAppRuleModal({
  17. Header,
  18. Body,
  19. sentryAppInstallationUuid,
  20. appName,
  21. config,
  22. resetValues,
  23. onSubmitSuccess,
  24. }: Props) {
  25. return (
  26. <Fragment>
  27. <Header closeButton>
  28. <div>{tct('[name] Settings', {name: appName})}</div>
  29. {config.description && <Description>{config.description}</Description>}
  30. </Header>
  31. <Body>
  32. <SentryAppExternalForm
  33. sentryAppInstallationUuid={sentryAppInstallationUuid}
  34. appName={appName}
  35. config={resetValues?.formFields || config}
  36. element="alert-rule-action"
  37. action="create"
  38. onSubmitSuccess={(...params) => {
  39. onSubmitSuccess(...params);
  40. closeModal();
  41. }}
  42. resetValues={{settings: resetValues?.settings}}
  43. />
  44. </Body>
  45. </Fragment>
  46. );
  47. }
  48. const Description = styled('div')`
  49. padding-top: ${space(0)};
  50. color: ${p => p.theme.subText};
  51. `;
  52. export default SentryAppRuleModal;