[v11.3.x] Alerting: Fix contact points secrets validation (#95777)

Alerting: Fix contact points secrets validation (#95651)

Add new condition to the determineRequired function

(cherry picked from commit e43bec2cd8)

Co-authored-by: Konrad Lalik <konrad.lalik@grafana.com>
pull/95793/head
grafana-delivery-bot[bot] 8 months ago committed by GitHub
parent 28f9eb3221
commit e31c4fc59b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 11
      public/app/features/alerting/unified/components/receivers/form/fields/OptionField.tsx

@ -294,14 +294,17 @@ const validateOption = (value: string, validationRule: string, required: boolean
};
const determineRequired = (option: NotificationChannelOption, getValues: any, pathIndex: string) => {
const secureFields = getValues(`${pathIndex}secureFields`);
const secureSettings = getValues(`${pathIndex}secureSettings`);
if (!option.dependsOn) {
return option.required ? 'Required' : false;
}
if (isEmpty(getValues(`${pathIndex}secureFields`))) {
const dependentOn = getValues(`${pathIndex}secureSettings.${option.dependsOn}`);
return !Boolean(dependentOn) && option.required ? 'Required' : false;
if (isEmpty(secureFields) || !secureFields[option.dependsOn]) {
const dependentOn = Boolean(secureSettings[option.dependsOn]);
return !dependentOn && option.required ? 'Required' : false;
} else {
const dependentOn: boolean = getValues(`${pathIndex}secureFields.${option.dependsOn}`);
const dependentOn = Boolean(secureFields[option.dependsOn]);
return !dependentOn && option.required ? 'Required' : false;
}
};

Loading…
Cancel
Save