mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
DataSourceRef: Fix migration for panels inside collapsed rows (#41590)
This commit is contained in:
parent
69c5370e94
commit
175c39a976
@ -1801,6 +1801,16 @@ describe('DashboardModel', () => {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: 'row',
|
||||
id: 5,
|
||||
panels: [
|
||||
{
|
||||
id: 6,
|
||||
datasource: 'prom',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -1824,6 +1834,10 @@ describe('DashboardModel', () => {
|
||||
it('should update target datasource props to refs', () => {
|
||||
expect(model.panels[2].targets[0].datasource).toEqual({ type: 'prometheus', uid: 'mock-ds-2' });
|
||||
});
|
||||
|
||||
it('should update datasources in panels collapsed rows', () => {
|
||||
expect(model.panels[3].panels[0].datasource).toEqual({ type: 'prometheus', uid: 'mock-ds-2' });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -708,12 +708,11 @@ export class DashboardMigrator {
|
||||
variable.datasource = migrateDatasourceNameToRef(variable.datasource);
|
||||
}
|
||||
|
||||
// Mutate panel models
|
||||
for (const panel of this.dashboard.panels) {
|
||||
panelUpgrades.push((panel) => {
|
||||
panel.datasource = migrateDatasourceNameToRef(panel.datasource);
|
||||
|
||||
if (!panel.targets) {
|
||||
continue;
|
||||
return panel;
|
||||
}
|
||||
|
||||
for (const target of panel.targets) {
|
||||
@ -722,7 +721,9 @@ export class DashboardMigrator {
|
||||
target.datasource = targetRef;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return panel;
|
||||
});
|
||||
}
|
||||
|
||||
if (panelUpgrades.length === 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user