Browse Source

fix(alerts): Metric alert rule save error msg when missing rule name (#34729)

* use flexible control state instead of hiding and update error msg

* remove ms from cls
Taylan Gocmen 2 years ago
parent
commit
c664d1d426

+ 7 - 1
static/app/views/alerts/rules/metric/ruleForm.tsx

@@ -476,7 +476,13 @@ class RuleFormContainer extends AsyncComponent<Props, State> {
     }
 
     if (!validRule || !validTriggers) {
-      addErrorMessage(t('Alert not valid'));
+      const missingFields = [
+        !validRule && t('name'),
+        !validRule && !validTriggers && t('and'),
+        !validTriggers && t('critical threshold'),
+      ].filter(x => x);
+
+      addErrorMessage(t(`Alert not valid: missing %s`, missingFields.join(' ')));
       return;
     }
 

+ 2 - 2
static/app/views/alerts/rules/metric/ruleNameOwnerForm.tsx

@@ -29,7 +29,7 @@ export default function RuleNameOwnerForm({disabled, project, hasAlertWizardV3}:
         hasAlertWizardV3 ? t('Enter Alert Name') : t('Something really bad happened')
       }
       required
-      hideControlState
+      flexibleControlStateSize
     />
   );
 
@@ -41,7 +41,7 @@ export default function RuleNameOwnerForm({disabled, project, hasAlertWizardV3}:
       label={hasAlertWizardV3 ? null : t('Team')}
       help={hasAlertWizardV3 ? null : t('The team that can edit this alert.')}
       disabled={disabled}
-      hideControlState
+      flexibleControlStateSize
     >
       {({model}) => {
         const owner = model.getValue('owner');

+ 5 - 0
static/app/views/alerts/rules/metric/triggers/form.tsx

@@ -157,6 +157,11 @@ class TriggerFormContainer extends Component<TriggerFormContainerProps> {
   };
 
   getThresholdUnits(aggregate: string, comparisonType: AlertRuleComparisonType) {
+    // cls is a number not a measurement of time
+    if (aggregate.includes('measurements.cls')) {
+      return '';
+    }
+
     if (aggregate.includes('duration') || aggregate.includes('measurements')) {
       return 'ms';
     }