diff --git a/.betterer.results b/.betterer.results index 5dd551c925b..04f8011111b 100644 --- a/.betterer.results +++ b/.betterer.results @@ -3337,11 +3337,9 @@ exports[`better eslint`] = { [0, 0, 0, "Unexpected any. Specify a different type.", "1"] ], "public/app/features/alerting/unified/components/receivers/form/ChannelOptions.tsx:5381": [ - [0, 0, 0, "Do not use any type assertions.", "0"], - [0, 0, 0, "Unexpected any. Specify a different type.", "1"], - [0, 0, 0, "Unexpected any. Specify a different type.", "2"], - [0, 0, 0, "Do not use any type assertions.", "3"], - [0, 0, 0, "Unexpected any. Specify a different type.", "4"] + [0, 0, 0, "Unexpected any. Specify a different type.", "0"], + [0, 0, 0, "Do not use any type assertions.", "1"], + [0, 0, 0, "Unexpected any. Specify a different type.", "2"] ], "public/app/features/alerting/unified/components/receivers/form/ReceiverForm.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"], diff --git a/public/app/features/alerting/unified/components/receivers/form/ChannelOptions.tsx b/public/app/features/alerting/unified/components/receivers/form/ChannelOptions.tsx index 9ca8b98f086..9cdfc9747ea 100644 --- a/public/app/features/alerting/unified/components/receivers/form/ChannelOptions.tsx +++ b/public/app/features/alerting/unified/components/receivers/form/ChannelOptions.tsx @@ -29,14 +29,17 @@ export function ChannelOptions({ readOnly = false, }: Props): JSX.Element { const { watch } = useFormContext>(); - const currentFormValues = watch() as Record; // react hook form types ARE LYING! + const currentFormValues = watch(); // react hook form types ARE LYING! return ( <> {selectedChannelOptions.map((option: NotificationChannelOption, index: number) => { const key = `${option.label}-${index}`; // Some options can be dependent on other options, this determines what is selected in the dependency options // I think this needs more thought. - const selectedOptionValue = currentFormValues[`${pathPrefix}settings.${option.showWhen.field}`]; + // pathPrefix = items.index. + const paths = pathPrefix.split('.'); + const selectedOptionValue = + paths.length >= 2 ? currentFormValues.items[Number(paths[1])].settings[option.showWhen.field] : undefined; if (option.showWhen.field && selectedOptionValue !== option.showWhen.is) { return null;