fix open password removing

This commit is contained in:
Alexander Zobnin
2020-06-02 09:25:32 +03:00
parent 3e379b01df
commit a9c96c2634
2 changed files with 12 additions and 6 deletions

View File

@@ -16,6 +16,17 @@ export const ConfigEditor = (props: Props) => {
// Apply some defaults on initial render
useEffect(() => {
const { jsonData, secureJsonFields } = options;
// Set secureJsonFields.password to password and then remove it from config
const { password, ...restJsonData } = jsonData;
if (!secureJsonFields?.password) {
if (!options.secureJsonData) {
options.secureJsonData = {};
}
options.secureJsonData.password = password;
}
onOptionsChange({
...options,
jsonData: {
@@ -23,7 +34,7 @@ export const ConfigEditor = (props: Props) => {
trendsFrom: '',
trendsRange: '',
cacheTTL: '',
...options.jsonData,
...restJsonData,
},
});
@@ -231,10 +242,6 @@ const secureJsonDataChangeHandler = (
) => {
onChange({
...value,
jsonData: {
...value.jsonData,
password: '',
},
secureJsonData: {
...value.secureJsonData,
[key]: event.currentTarget.value,