Export: Fix error being thrown when exporting dashboards using query variables that reference the default datasource (#44034)

* handle undefined datasources, add unit test

* slightly nicer
This commit is contained in:
Ashley Harrison
2022-01-17 10:21:13 +00:00
committed by GitHub
parent a65ce992c1
commit c618339482
2 changed files with 143 additions and 1 deletions

View File

@@ -116,7 +116,7 @@ export class DashboardExporter {
pluginName: ds.meta?.name,
};
if (obj.datasource === null || typeof obj.datasource === 'string') {
if (!obj.datasource || typeof obj.datasource === 'string') {
obj.datasource = '${' + refName + '}';
} else {
obj.datasource.uid = '${' + refName + '}';