mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
DatasourceSrv: Fix instance retrieval when datasource variable value set to "default" (#31347)
* Failing tests * Fixed
This commit is contained in:
@@ -54,7 +54,15 @@ export class DatasourceSrv implements DataSourceService {
|
||||
// For this we just pick the current or first data source in the variable
|
||||
if (nameOrUid[0] === '$') {
|
||||
const interpolatedName = this.templateSrv.replace(nameOrUid, {}, variableInterpolation);
|
||||
const dsSettings = this.settingsMapByUid[interpolatedName] ?? this.settingsMapByName[interpolatedName];
|
||||
|
||||
let dsSettings;
|
||||
|
||||
if (interpolatedName === 'default') {
|
||||
dsSettings = this.settingsMapByName[this.defaultName];
|
||||
} else {
|
||||
dsSettings = this.settingsMapByUid[interpolatedName] ?? this.settingsMapByName[interpolatedName];
|
||||
}
|
||||
|
||||
if (!dsSettings) {
|
||||
return undefined;
|
||||
}
|
||||
|
Reference in New Issue
Block a user