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:
Travis Patterson 2022-01-18 13:54:51 -07:00 committed by GitHub
parent b98a1d79cf
commit 959723050f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 1 deletions

View File

@ -99,4 +99,42 @@ describe('updateQueries', () => {
expect(updated[0].datasource).toEqual({ type: 'old-type', uid: 'old-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' });
});
});

View File

@ -21,7 +21,7 @@ export function updateQueries(
// Set data source on all queries except expression queries
return queries.map((query) => {
if (!isExpressionReference(query.datasource)) {
if (!isExpressionReference(query.datasource) && !newSettings.meta.mixed) {
query.datasource = datasource;
}
return query;