diff --git a/grafana-plugin/src/components/AlertTemplates/AlertTemplatesForm.config.ts b/grafana-plugin/src/components/AlertTemplates/AlertTemplatesForm.config.ts index 01999f95e5..219bf295f3 100644 --- a/grafana-plugin/src/components/AlertTemplates/AlertTemplatesForm.config.ts +++ b/grafana-plugin/src/components/AlertTemplates/AlertTemplatesForm.config.ts @@ -1,6 +1,6 @@ import { AppFeature } from 'state/features'; -import { Template, TemplateForEdit, commonTemplateForEdit } from './CommonAlertTemplatesForm.config'; +import { TemplateForEdit, commonTemplateForEdit } from './CommonAlertTemplatesForm.config'; export const getTemplatesForEdit = (features: Record) => { if (features[AppFeature.MsTeams]) { @@ -42,165 +42,4 @@ const additionalTemplateForEdit: { [id: string]: TemplateForEdit } = { }, }; -export const getTemplatesToRender = (features: Record) => { - if (features[AppFeature.MsTeams]) { - return templatesToRenderWithMsTeams; - } - return templatesToRender; -}; - -export const templatesToRender: Template[] = [ - { - name: 'web_title_template', - group: 'web', - }, - { - name: 'slack_title_template', - group: 'slack', - }, - { - name: 'sms_title_template', - group: 'sms', - }, - { - name: 'phone_call_title_template', - group: 'phone', - }, - { - name: 'email_title_template', - group: 'email', - }, - { - name: 'telegram_title_template', - group: 'telegram', - }, - { - name: 'slack_message_template', - group: 'slack', - }, - { - name: 'web_message_template', - group: 'web', - }, - { - name: 'email_message_template', - group: 'email', - }, - { - name: 'telegram_message_template', - group: 'telegram', - }, - { - name: 'slack_image_url_template', - group: 'slack', - }, - { - name: 'web_image_url_template', - group: 'web', - }, - { - name: 'telegram_image_url_template', - group: 'telegram', - }, - { - name: 'grouping_id_template', - group: 'alert behaviour', - }, - { - name: 'acknowledge_condition_template', - group: 'alert behaviour', - }, - { - name: 'resolve_condition_template', - group: 'alert behaviour', - }, - { - name: 'source_link_template', - group: 'alert behaviour', - }, -]; - -export const templatesToRenderWithMsTeams: Template[] = [ - { - name: 'web_title_template', - group: 'web', - }, - { - name: 'slack_title_template', - group: 'slack', - }, - { - name: 'sms_title_template', - group: 'sms', - }, - { - name: 'phone_call_title_template', - group: 'phone', - }, - { - name: 'email_title_template', - group: 'email', - }, - { - name: 'telegram_title_template', - group: 'telegram', - }, - { - name: 'msteams_title_template', - group: 'microsoft teams', - }, - { - name: 'msteams_message_template', - group: 'microsoft teams', - }, - { - name: 'msteams_image_url_template', - group: 'microsoft teams', - }, - { - name: 'slack_message_template', - group: 'slack', - }, - { - name: 'web_message_template', - group: 'web', - }, - { - name: 'email_message_template', - group: 'email', - }, - { - name: 'telegram_message_template', - group: 'telegram', - }, - { - name: 'slack_image_url_template', - group: 'slack', - }, - { - name: 'web_image_url_template', - group: 'web', - }, - { - name: 'telegram_image_url_template', - group: 'telegram', - }, - { - name: 'grouping_id_template', - group: 'alert behaviour', - }, - { - name: 'acknowledge_condition_template', - group: 'alert behaviour', - }, - { - name: 'resolve_condition_template', - group: 'alert behaviour', - }, - { - name: 'source_link_template', - group: 'alert behaviour', - }, -]; - export const FORM_NAME = 'AlertTemplates'; diff --git a/grafana-plugin/src/components/AlertTemplates/AlertTemplatesForm.module.css b/grafana-plugin/src/components/AlertTemplates/AlertTemplatesForm.module.css deleted file mode 100644 index 924951cfa4..0000000000 --- a/grafana-plugin/src/components/AlertTemplates/AlertTemplatesForm.module.css +++ /dev/null @@ -1,59 +0,0 @@ -.select { - width: 300px; -} - -.templates { - width: 50%; -} - -.borderLeftRightBottom { - border-left: 1px solid rgba(204, 204, 220, 0.15); - border-bottom: 1px solid rgba(204, 204, 220, 0.15); - border-right: 1px solid rgba(204, 204, 220, 0.15); - border-radius: 2px; -} - -.borderRightBottom { - border-bottom: 1px solid rgba(204, 204, 220, 0.15); - border-right: 1px solid rgba(204, 204, 220, 0.15); - border-radius: 2px; -} - -.template-form { - width: 100%; -} - -.templatesInfo { - display: flex; - flex-direction: row; -} - -.templates-editors { - width: 50%; -} - -.select-template { - width: 50% !important; -} - -.collapse { - flex-grow: 1; - width: 100%; -} - -.typographyText { - margin-bottom: 24px; - margin-top: 8px; -} - -.autoresolve-condition section { - border: 1px solid var(--primary-text-link); -} - -.autoresolve-label { - margin-bottom: 0 !important; -} - -.web-title-message { - margin-top: 8px; -} diff --git a/grafana-plugin/src/components/AlertTemplates/AlertTemplatesForm.tsx b/grafana-plugin/src/components/AlertTemplates/AlertTemplatesForm.tsx deleted file mode 100644 index 34e21f15cc..0000000000 --- a/grafana-plugin/src/components/AlertTemplates/AlertTemplatesForm.tsx +++ /dev/null @@ -1,284 +0,0 @@ -import React, { useCallback, useEffect, useMemo, useState } from 'react'; - -import { SelectableValue } from '@grafana/data'; -import { Label, Button, HorizontalGroup, VerticalGroup, Select, LoadingPlaceholder } from '@grafana/ui'; -import { capitalCase } from 'change-case'; -import cn from 'classnames/bind'; -import { omit } from 'lodash-es'; - -import { templatesToRender } from 'components/AlertTemplates/AlertTemplatesForm.config'; -import { getLabelFromTemplateName } from 'components/AlertTemplates/AlertTemplatesForm.helper'; -import { Template } from 'components/AlertTemplates/CommonAlertTemplatesForm.config'; -import Block from 'components/GBlock/Block'; -import MonacoEditor from 'components/MonacoEditor/MonacoEditor'; -import SourceCode from 'components/SourceCode/SourceCode'; -import Text from 'components/Text/Text'; -import TemplatePreview, { TEMPLATE_PAGE } from 'containers/TemplatePreview/TemplatePreview'; -import { WithPermissionControlTooltip } from 'containers/WithPermissionControl/WithPermissionControlTooltip'; -import { AlertReceiveChannel } from 'models/alert_receive_channel/alert_receive_channel.types'; -import { Alert } from 'models/alertgroup/alertgroup.types'; -import { makeRequest } from 'network'; -import LocationHelper from 'utils/LocationHelper'; -import { UserActions, isUserActionAllowed } from 'utils/authorization'; - -import styles from './AlertTemplatesForm.module.css'; - -const cx = cn.bind(styles); - -interface AlertTemplatesFormProps { - templates: any; - onUpdateTemplates: (values: any) => void; - alertReceiveChannelId: AlertReceiveChannel['id']; - alertGroupId?: Alert['pk']; - demoAlertEnabled: boolean; - handleSendDemoAlertClick: () => void; - templatesRefreshing: boolean; - selectedTemplateName?: string; -} - -const AlertTemplatesForm = (props: AlertTemplatesFormProps) => { - const { - onUpdateTemplates, - templates, - alertReceiveChannelId, - alertGroupId, - demoAlertEnabled, - handleSendDemoAlertClick, - templatesRefreshing, - selectedTemplateName, - } = props; - - const [tempValues, setTempValues] = useState<{ - [key: string]: string | null; - }>({}); - const [activeGroup, setActiveGroup] = useState(); - const [activeTemplate, setActiveTemplate] = useState