From 33da55c5076bf9e79866ea69ba535d89f4eae9fb Mon Sep 17 00:00:00 2001 From: Yulya Artyukhina Date: Fri, 18 Aug 2023 12:12:29 +0200 Subject: [PATCH] Improve getting/updating contact points for Grafana Alerting integration (#2742) This PR improves Grafana Alerting integration: - get alerting contact points "on fly" instead of keeping them in db - add ability to connect more than one contact point - add ability to create new contact point on create Grafana Alerting integration - show warnings in integration settings for non-active contact points - remove creation alerting notification policies on create Grafana Alerting integration ## Checklist - [x] Unit, integration, and e2e (if applicable) tests updated - [x] Documentation added (or `pr:no public docs` PR label added if not required) - [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required) --------- Co-authored-by: Rares Mardare --- src/assets/style/utils.css | 23 +- src/components/GForm/GForm.tsx | 55 ++- src/components/GForm/GForm.types.ts | 3 + ...IntegrationCollapsibleTreeView.module.scss | 6 + .../IntegrationContactPoint.tsx | 340 +++++++++++++ .../IntegrationHowToConnect.tsx | 117 +++++ .../IntegrationSendDemoAlertModal.tsx | 134 +++++ ...llapsedIntegrationRouteDisplay.module.scss | 4 - .../IntegrationForm/IntegrationForm.config.ts | 19 + ...module.css => IntegrationForm.module.scss} | 22 + .../IntegrationForm/IntegrationForm.tsx | 465 +++++++++++++----- .../alert_receive_channel.ts | 72 +++ .../alert_receive_channel.types.ts | 7 + src/pages/integration/Integration.helper.ts | 10 +- src/pages/integration/Integration.module.scss | 39 +- src/pages/integration/Integration.tsx | 302 +++--------- src/pages/integrations/Integrations.tsx | 2 +- src/types.ts | 4 + 18 files changed, 1245 insertions(+), 379 deletions(-) create mode 100644 src/components/IntegrationContactPoint/IntegrationContactPoint.tsx create mode 100644 src/components/IntegrationHowToConnect/IntegrationHowToConnect.tsx create mode 100644 src/components/IntegrationSendDemoAlertModal/IntegrationSendDemoAlertModal.tsx rename src/containers/IntegrationForm/{IntegrationForm.module.css => IntegrationForm.module.scss} (76%) diff --git a/src/assets/style/utils.css b/src/assets/style/utils.css index 2955184968..b48abdd0de 100644 --- a/src/assets/style/utils.css +++ b/src/assets/style/utils.css @@ -16,6 +16,10 @@ align-items: center; } +.u-flex-space-between { + justify-content: space-between; +} + .u-flex-grow-1 { flex-grow: 1; } @@ -33,7 +37,11 @@ } .u-padding-top-md { - padding-top: 16px; + padding-top: 12px; +} + +.u-margin-bottom-none { + margin-bottom: 0; } .u-pull-right { @@ -108,3 +116,16 @@ .buttons { padding-bottom: 24px; } + +/* ----- + * Icons + */ + +.icon-exclamation { + color: var(--error-text-color); +} + +.loadingPlaceholder { + margin-bottom: 0; + margin-right: 4px; +} diff --git a/src/components/GForm/GForm.tsx b/src/components/GForm/GForm.tsx index 4a4fc5a963..2d179af17a 100644 --- a/src/components/GForm/GForm.tsx +++ b/src/components/GForm/GForm.tsx @@ -9,6 +9,7 @@ import { FormItem, FormItemType } from 'components/GForm/GForm.types'; import MonacoEditor from 'components/MonacoEditor/MonacoEditor'; import { MONACO_READONLY_CONFIG } from 'components/MonacoEditor/MonacoEditor.config'; import GSelect from 'containers/GSelect/GSelect'; +import { CustomFieldSectionRendererProps } from 'containers/IntegrationForm/IntegrationForm'; import RemoteSelect from 'containers/RemoteSelect/RemoteSelect'; import styles from './GForm.module.scss'; @@ -19,6 +20,8 @@ interface GFormProps { form: { name: string; fields: FormItem[] }; data: any; onSubmit: (data: any) => void; + + customFieldSectionRenderer?: React.FC; onFieldRender?: ( formItem: FormItem, disabled: boolean, @@ -36,19 +39,24 @@ function renderFormControl( formItem: FormItem, register: any, control: any, - disabled, + disabled: boolean, onChangeFn: (field, value) => void ) { switch (formItem.type) { case FormItemType.Input: return ( - onChangeFn(undefined, value)} /> + onChangeFn(undefined, value)} + /> ); case FormItemType.Password: return ( onChangeFn(undefined, value)} /> @@ -58,6 +66,7 @@ function renderFormControl( return (