mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Variables: Fixes problem with data source variable when default ds is selected (#32384)
This commit is contained in:
parent
eebcc55faa
commit
f37c8c10c5
@ -69,6 +69,9 @@ export class DatasourceSrv implements DataSourceService {
|
||||
// The return name or uid needs preservet string containing the variable
|
||||
const clone = cloneDeep(dsSettings);
|
||||
clone.name = nameOrUid;
|
||||
// A data source being looked up using a variable should not be considered default
|
||||
clone.isDefault = false;
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
@ -77,6 +77,7 @@ describe('datasource_srv', () => {
|
||||
name: 'BBB',
|
||||
uid: 'uid-code-BBB',
|
||||
meta: { metrics: true },
|
||||
isDefault: true,
|
||||
},
|
||||
Jaeger: {
|
||||
type: 'jaeger-db',
|
||||
@ -127,6 +128,11 @@ describe('datasource_srv', () => {
|
||||
expect(ds?.uid).toBe('uid-code-BBB');
|
||||
});
|
||||
|
||||
it('should not set isDefault when being fetched via variable', () => {
|
||||
const ds = dataSourceSrv.getInstanceSettings('${datasource}');
|
||||
expect(ds?.isDefault).toBe(false);
|
||||
});
|
||||
|
||||
it('should work with variable', () => {
|
||||
const ds = dataSourceSrv.getInstanceSettings('${datasourceDefault}');
|
||||
expect(ds?.name).toBe('${datasourceDefault}');
|
||||
@ -182,6 +188,7 @@ describe('datasource_srv', () => {
|
||||
"uid": "uid-code-aaa",
|
||||
},
|
||||
Object {
|
||||
"isDefault": true,
|
||||
"meta": Object {
|
||||
"metrics": true,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user