mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
dashboard: Close/hide 'Add Panel' before saving a dashboard (#10482)
Fixes #10472
This commit is contained in:
committed by
Torkel Ödegaard
parent
9606a34e0a
commit
2843961677
@@ -145,7 +145,10 @@ export class DashboardModel {
|
||||
};
|
||||
|
||||
// get panel save models
|
||||
copy.panels = _.map(this.panels, panel => panel.getSaveModel());
|
||||
copy.panels = _.chain(this.panels)
|
||||
.filter(panel => panel.type !== 'add-panel')
|
||||
.map(panel => panel.getSaveModel())
|
||||
.value();
|
||||
|
||||
// sort by keys
|
||||
copy = sortByKeys(copy);
|
||||
|
||||
@@ -49,6 +49,23 @@ describe('DashboardModel', function() {
|
||||
expect(keys[0]).toBe('annotations');
|
||||
expect(keys[1]).toBe('autoUpdate');
|
||||
});
|
||||
|
||||
it('should remove add panel panels', () => {
|
||||
var model = new DashboardModel({});
|
||||
model.addPanel({
|
||||
type: 'add-panel',
|
||||
});
|
||||
model.addPanel({
|
||||
type: 'graph',
|
||||
});
|
||||
model.addPanel({
|
||||
type: 'add-panel',
|
||||
});
|
||||
var saveModel = model.getSaveModelClone();
|
||||
var panels = saveModel.panels;
|
||||
|
||||
expect(panels.length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('row and panel manipulation', function() {
|
||||
|
||||
Reference in New Issue
Block a user