DatasourceSrv: Fix instance retrieval when datasource variable value set to "default" (#31347)

* Failing tests

* Fixed
This commit is contained in:
Dominik Prokop
2021-02-19 12:31:28 +01:00
committed by GitHub
parent ce63df425d
commit 0d6e5298b7
2 changed files with 27 additions and 3 deletions

View File

@@ -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;
}