mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Fix reseting secure fields (#93278)
fix reseting secure fields
This commit is contained in:
parent
48dd1af524
commit
8a743b2e2f
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user