mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Fix contact points secrets validation (#95651)
Add new condition to the determineRequired function
This commit is contained in:
parent
0802ebcd1a
commit
e43bec2cd8
@ -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…
Reference in New Issue
Block a user