From 8a743b2e2fee3516c0d3d1e8df444ca632a82708 Mon Sep 17 00:00:00 2001 From: Sonia Aguilar <33540275+soniaAguilarPeiron@users.noreply.github.com> Date: Fri, 13 Sep 2024 13:33:26 +0200 Subject: [PATCH] Alerting: Fix reseting secure fields (#93278) fix reseting secure fields --- .../unified/components/receivers/form/ChannelSubForm.tsx | 6 +++--- public/app/types/alerting.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/public/app/features/alerting/unified/components/receivers/form/ChannelSubForm.tsx b/public/app/features/alerting/unified/components/receivers/form/ChannelSubForm.tsx index 9a767ebedb9..a239b3400db 100644 --- a/public/app/features/alerting/unified/components/receivers/form/ChannelSubForm.tsx +++ b/public/app/features/alerting/unified/components/receivers/form/ChannelSubForm.tsx @@ -1,7 +1,7 @@ import { css } from '@emotion/css'; import { sortBy } from 'lodash'; -import { useCallback, useEffect, useMemo, useState } from 'react'; import * as React from 'react'; +import { useCallback, useEffect, useMemo, useState } from 'react'; import { Controller, FieldErrors, FieldValues, useFormContext } from 'react-hook-form'; import { GrafanaTheme2, SelectableValue } from '@grafana/data'; @@ -90,12 +90,12 @@ export function ChannelSubForm({ return () => subscription.unsubscribe(); }, [selectedType, initialValues, setValue, fieldName, watch]); - const [_secureFields, setSecureFields] = useState(secureFields ?? {}); + const [_secureFields, setSecureFields] = useState>(secureFields ?? {}); const onResetSecureField = (key: string) => { if (_secureFields[key]) { const updatedSecureFields = { ..._secureFields }; - delete updatedSecureFields[key]; + updatedSecureFields[key] = ''; setSecureFields(updatedSecureFields); setValue(`${pathPrefix}.secureFields`, updatedSecureFields); } diff --git a/public/app/types/alerting.ts b/public/app/types/alerting.ts index 3d86f9e3d5b..ac0ad119cce 100644 --- a/public/app/types/alerting.ts +++ b/public/app/types/alerting.ts @@ -111,7 +111,7 @@ export interface NotificationChannelDTO { } export type NotificationChannelSecureSettings = Record; -export type NotificationChannelSecureFields = Record; +export type NotificationChannelSecureFields = Record; export interface ChannelTypeSettings { [key: string]: any;