mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboard: Fix library panels in collapsed rows not getting updated (#66643)
This commit is contained in:
parent
3ab1706145
commit
f478504bc9
@ -195,6 +195,27 @@ describe('PanelModel', () => {
|
||||
expect(saveModel.events).toBe(undefined);
|
||||
});
|
||||
|
||||
it('getSaveModel should clean libraryPanels from a collapsed row', () => {
|
||||
const newmodelJson = {
|
||||
type: 'row',
|
||||
panels: [
|
||||
{
|
||||
...modelJson,
|
||||
libraryPanel: {
|
||||
uid: 'BVIBScisnl',
|
||||
model: modelJson,
|
||||
name: 'Library panel title',
|
||||
},
|
||||
},
|
||||
modelJson,
|
||||
],
|
||||
};
|
||||
const newmodel = new PanelModel(newmodelJson);
|
||||
const saveModel = newmodel.getSaveModel();
|
||||
expect(saveModel.panels[0].tagrets).toBe(undefined);
|
||||
expect(saveModel.panels[1].targets).toBeTruthy();
|
||||
});
|
||||
|
||||
describe('variables interpolation', () => {
|
||||
beforeEach(() => {
|
||||
model.scopedVars = {
|
||||
|
@ -310,6 +310,26 @@ export class PanelModel implements DataConfigSource, IPanelModel {
|
||||
model[property] = cloneDeep(this[property]);
|
||||
}
|
||||
|
||||
// clean libraryPanel from collapsed rows
|
||||
if (this.type === 'row' && this.panels && this.panels.length > 0) {
|
||||
model.panels = this.panels.map((panel) => {
|
||||
if (panel.libraryPanel) {
|
||||
const { id, title, libraryPanel, gridPos } = panel;
|
||||
return {
|
||||
id,
|
||||
title,
|
||||
gridPos,
|
||||
libraryPanel: {
|
||||
uid: libraryPanel.uid,
|
||||
name: libraryPanel.name,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return panel;
|
||||
});
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user