sentryAppRuleModal.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 type {SchemaFormConfig} from 'sentry/views/settings/organizationIntegrations/sentryAppExternalForm';
  7. import SentryAppExternalForm from 'sentry/views/settings/organizationIntegrations/sentryAppExternalForm';
  8. type Props = ModalRenderProps & {
  9. appName: string;
  10. config: SchemaFormConfig;
  11. onSubmitSuccess: React.ComponentProps<typeof SentryAppExternalForm>['onSubmitSuccess'];
  12. resetValues: {[key: string]: any};
  13. sentryAppInstallationUuid: string;
  14. };
  15. function SentryAppRuleModal({
  16. Header,
  17. Body,
  18. sentryAppInstallationUuid,
  19. appName,
  20. config,
  21. resetValues,
  22. onSubmitSuccess,
  23. }: Props) {
  24. return (
  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. }
  47. const Description = styled('div')`
  48. padding-top: 0;
  49. color: ${p => p.theme.subText};
  50. `;
  51. export default SentryAppRuleModal;