mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix change to mixed bahavior (#44179)
- If the datasource is already set to mixed, don't change any queries in the editor
This commit is contained in:
@@ -99,4 +99,42 @@ describe('updateQueries', () => {
|
|||||||
expect(updated[0].datasource).toEqual({ type: 'old-type', uid: 'old-uid' });
|
expect(updated[0].datasource).toEqual({ type: 'old-type', uid: 'old-uid' });
|
||||||
expect(updated[1].datasource).toEqual({ type: 'other-type', uid: 'other-uid' });
|
expect(updated[1].datasource).toEqual({ type: 'other-type', uid: 'other-uid' });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should change nothing mixed updated to mixed', () => {
|
||||||
|
const updated = updateQueries(
|
||||||
|
{
|
||||||
|
uid: 'mixed',
|
||||||
|
type: 'mixed',
|
||||||
|
meta: {
|
||||||
|
mixed: true,
|
||||||
|
},
|
||||||
|
} as any,
|
||||||
|
[
|
||||||
|
{
|
||||||
|
refId: 'A',
|
||||||
|
datasource: {
|
||||||
|
uid: 'old-uid',
|
||||||
|
type: 'old-type',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
refId: 'B',
|
||||||
|
datasource: {
|
||||||
|
uid: 'other-uid',
|
||||||
|
type: 'other-type',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
{
|
||||||
|
uid: 'mixed',
|
||||||
|
type: 'mixed',
|
||||||
|
meta: {
|
||||||
|
mixed: true,
|
||||||
|
},
|
||||||
|
} as any
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(updated[0].datasource).toEqual({ type: 'old-type', uid: 'old-uid' });
|
||||||
|
expect(updated[1].datasource).toEqual({ type: 'other-type', uid: 'other-uid' });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export function updateQueries(
|
|||||||
|
|
||||||
// Set data source on all queries except expression queries
|
// Set data source on all queries except expression queries
|
||||||
return queries.map((query) => {
|
return queries.map((query) => {
|
||||||
if (!isExpressionReference(query.datasource)) {
|
if (!isExpressionReference(query.datasource) && !newSettings.meta.mixed) {
|
||||||
query.datasource = datasource;
|
query.datasource = datasource;
|
||||||
}
|
}
|
||||||
return query;
|
return query;
|
||||||
|
|||||||
Reference in New Issue
Block a user