mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix: Dynamically add ShowWhen fields to the form watch (#28135)
This commit is contained in:
parent
4ab90f9397
commit
87d6f90acb
@ -36,9 +36,22 @@ export const NotificationChannelForm: FC<Props> = ({
|
||||
}) => {
|
||||
const styles = getStyles(useTheme());
|
||||
|
||||
/*
|
||||
Finds fields that have dependencies on other fields and removes duplicates.
|
||||
Needs to be prefixed with settings.
|
||||
*/
|
||||
const fieldsToWatch =
|
||||
new Set(
|
||||
selectedChannel?.options
|
||||
.filter(o => o.showWhen.field)
|
||||
.map(option => {
|
||||
return `settings.${option.showWhen.field}`;
|
||||
})
|
||||
) || [];
|
||||
|
||||
useEffect(() => {
|
||||
watch(['type', 'settings.priority', 'sendReminder', 'uploadImage']);
|
||||
}, []);
|
||||
watch(['type', 'sendReminder', 'uploadImage', ...fieldsToWatch]);
|
||||
}, [fieldsToWatch]);
|
||||
|
||||
const currentFormValues = getValues();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user