Alerting: Fix reseting secure fields (#93278)

fix reseting secure fields
This commit is contained in:
Sonia Aguilar 2024-09-13 13:33:26 +02:00 committed by GitHub
parent 48dd1af524
commit 8a743b2e2f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -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<R extends ChannelValues>({
return () => subscription.unsubscribe();
}, [selectedType, initialValues, setValue, fieldName, watch]);
const [_secureFields, setSecureFields] = useState(secureFields ?? {});
const [_secureFields, setSecureFields] = useState<Record<string, boolean | ''>>(secureFields ?? {});
const onResetSecureField = (key: string) => {
if (_secureFields[key]) {
const updatedSecureFields = { ..._secureFields };
delete updatedSecureFields[key];
updatedSecureFields[key] = '';
setSecureFields(updatedSecureFields);
setValue(`${pathPrefix}.secureFields`, updatedSecureFields);
}

View File

@ -111,7 +111,7 @@ export interface NotificationChannelDTO {
}
export type NotificationChannelSecureSettings = Record<string, string | number>;
export type NotificationChannelSecureFields = Record<string, boolean>;
export type NotificationChannelSecureFields = Record<string, boolean | ''>;
export interface ChannelTypeSettings {
[key: string]: any;