sentryAppRuleModal.tsx 1.5 KB

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