diff --git a/frontend/src/container/FormAlertRules/BasicInfo.tsx b/frontend/src/container/FormAlertRules/BasicInfo.tsx
index f4d99126ec..595e6facd6 100644
--- a/frontend/src/container/FormAlertRules/BasicInfo.tsx
+++ b/frontend/src/container/FormAlertRules/BasicInfo.tsx
@@ -1,6 +1,7 @@
import { Form, Select } from 'antd';
import { useTranslation } from 'react-i18next';
import { AlertDef, Labels } from 'types/api/alerts/def';
+import { requireErrorMessage } from 'utils/form/requireErrorMessage';
import ChannelSelect from './ChannelSelect';
import LabelSelect from './labels';
@@ -54,7 +55,15 @@ function BasicInfo({ alertDef, setAlertDef }: BasicInfoProps): JSX.Element {
-
+
{
setAlertDef({
@@ -97,10 +106,10 @@ function BasicInfo({ alertDef, setAlertDef }: BasicInfoProps): JSX.Element {
{
+ onSelectChannels={(preferredChannels): void => {
setAlertDef({
...alertDef,
- preferredChannels: s,
+ preferredChannels,
});
}}
/>
diff --git a/frontend/src/container/FormAlertRules/index.tsx b/frontend/src/container/FormAlertRules/index.tsx
index f131fe60ba..9eec5ad9d0 100644
--- a/frontend/src/container/FormAlertRules/index.tsx
+++ b/frontend/src/container/FormAlertRules/index.tsx
@@ -201,10 +201,6 @@ function FormAlertRules({
const isFormValid = useCallback((): boolean => {
if (!alertDef.alert || alertDef.alert === '') {
- notifications.error({
- message: 'Error',
- description: t('alertname_required'),
- });
return false;
}
@@ -217,14 +213,7 @@ function FormAlertRules({
}
return validateQBParams();
- }, [
- t,
- validateQBParams,
- validateChQueryParams,
- alertDef,
- validatePromParams,
- notifications,
- ]);
+ }, [validateQBParams, validateChQueryParams, alertDef, validatePromParams]);
const preparePostData = (): AlertDef => {
const postableAlert: AlertDef = {
@@ -328,9 +317,7 @@ function FormAlertRules({
title: t('confirm_save_title'),
centered: true,
content,
- onOk() {
- saveRule();
- },
+ onOk: saveRule,
});
}, [t, saveRule, currentQuery]);
@@ -407,6 +394,8 @@ function FormAlertRules({
const isNewRule = ruleId === 0;
+ const isAlertNameMissing = !formInstance.getFieldValue('alert');
+
const isAlertAvialableToSave =
isAlertAvialable &&
isNewRule &&
@@ -448,7 +437,7 @@ function FormAlertRules({
type="primary"
onClick={onSaveHandler}
icon={}
- disabled={isAlertAvialableToSave}
+ disabled={isAlertNameMissing || isAlertAvialableToSave}
>
{isNewRule ? t('button_createrule') : t('button_savechanges')}