fix open password removing
This commit is contained in:
@@ -212,7 +212,6 @@ func (ds *ZabbixDatasource) GetDatasource(pluginContext backend.PluginContext) (
|
||||
|
||||
ds.logger.Debug(fmt.Sprintf("Datasource cache miss (Org %d Id %d '%s' %s)", pluginContext.OrgID, dsSettings.ID, dsSettings.Name, dsInfoHash))
|
||||
|
||||
ds.logger.Debug("DS config", "settings", pluginContext.DataSourceInstanceSettings)
|
||||
dsInstance, err := ds.NewZabbixDatasource(pluginContext.DataSourceInstanceSettings)
|
||||
if err != nil {
|
||||
ds.logger.Error("Error initializing datasource", "error", err)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user