mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Azure Monitor: Standardize Config Editor Implementation (#20455)
* initial changes - removal from state, remove anon functions, reset secrets empty * post testing cleanup * init promise cancellation, other cleanup * workspaces response parser, remove version incrementing * update datasource funcs - DRYer * remove prop mutation * func to modify root config opt * fix version issue * update snapshot
This commit is contained in:
@@ -272,6 +272,64 @@ export abstract class DataSourceApi<
|
||||
interpolateVariablesInQueries?(queries: TQuery[]): TQuery[];
|
||||
}
|
||||
|
||||
export function updateDatasourcePluginOption(props: DataSourcePluginOptionsEditorProps, key: string, val: any) {
|
||||
let config = props.options;
|
||||
|
||||
config = {
|
||||
...config,
|
||||
[key]: val,
|
||||
};
|
||||
|
||||
props.onOptionsChange(config);
|
||||
}
|
||||
|
||||
export function updateDatasourcePluginJsonDataOption(
|
||||
props: DataSourcePluginOptionsEditorProps,
|
||||
key: string,
|
||||
val: any,
|
||||
secure: boolean
|
||||
) {
|
||||
let config = props.options;
|
||||
|
||||
if (secure) {
|
||||
config = {
|
||||
...config,
|
||||
secureJsonData: {
|
||||
...config.secureJsonData,
|
||||
[key]: val,
|
||||
},
|
||||
};
|
||||
} else {
|
||||
config = {
|
||||
...config,
|
||||
jsonData: {
|
||||
...config.jsonData,
|
||||
[key]: val,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
props.onOptionsChange(config);
|
||||
}
|
||||
|
||||
export function updateDatasourcePluginResetKeyOption(props: DataSourcePluginOptionsEditorProps, key: string) {
|
||||
let config = props.options;
|
||||
|
||||
config = {
|
||||
...config,
|
||||
secureJsonData: {
|
||||
...config.secureJsonData,
|
||||
[key]: '',
|
||||
},
|
||||
secureJsonFields: {
|
||||
...config.secureJsonFields,
|
||||
[key]: false,
|
||||
},
|
||||
};
|
||||
|
||||
props.onOptionsChange(config);
|
||||
}
|
||||
|
||||
export interface QueryEditorProps<
|
||||
DSType extends DataSourceApi<TQuery, TOptions>,
|
||||
TQuery extends DataQuery = DataQuery,
|
||||
|
Reference in New Issue
Block a user