mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix(): fix for cleaning up repeat panel scope for orphaned panels or duplicated panels
This commit is contained in:
parent
0586dbaf8b
commit
775a805959
@ -174,6 +174,11 @@ function (angular, $, kbn, _, moment) {
|
||||
var newPanel = angular.copy(panel);
|
||||
newPanel.id = this.getNextPanelId();
|
||||
|
||||
delete newPanel.repeat;
|
||||
delete newPanel.repeatIteration;
|
||||
delete newPanel.repeatPanelId;
|
||||
delete newPanel.scopedVars;
|
||||
|
||||
var currentRow = this.rows[rowIndex];
|
||||
currentRow.panels.push(newPanel);
|
||||
return newPanel;
|
||||
|
@ -53,6 +53,10 @@ function (angular, _) {
|
||||
row.panels = _.without(row.panels, panel);
|
||||
j = j - 1;
|
||||
}
|
||||
// clean up left over scoped vars
|
||||
else if (panel.scopedVars && panel.repeatIteration !== this.iteration) {
|
||||
delete panel.scopedVars;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -116,6 +120,7 @@ function (angular, _) {
|
||||
panel = copy.panels[i];
|
||||
panel.scopedVars = {};
|
||||
panel.scopedVars[variable.name] = option;
|
||||
panel.repeatIteration = self.iteration;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -136,7 +136,7 @@ function (angular, _, InfluxQueryBuilder) {
|
||||
|
||||
$scope.addTemplateVariableSegments = function(segments) {
|
||||
_.each(templateSrv.variables, function(variable) {
|
||||
segments.unshift(new MetricSegment({ type: 'template', value: '$' + variable.name, expandable: true }));
|
||||
segments.unshift(new MetricSegment({ type: 'template', value: '/$' + variable.name + '/', expandable: true }));
|
||||
});
|
||||
return segments;
|
||||
};
|
||||
|
@ -81,6 +81,15 @@ define([
|
||||
expect(dashboard.rows[0].panels[1].id).to.be(11);
|
||||
});
|
||||
|
||||
it('duplicate panel should remove repeat data', function() {
|
||||
var panel = { span: 4, attr: '123', id: 10, repeat: 'asd', scopedVars: { test: 'asd' }};
|
||||
dashboard.rows = [{ panels: [panel] }];
|
||||
dashboard.duplicatePanel(panel, dashboard.rows[0]);
|
||||
|
||||
expect(dashboard.rows[0].panels[1].repeat).to.be(null);
|
||||
expect(dashboard.rows[0].panels[1].scopedVars.test).to.be(undefined);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('when creating dashboard with editable false', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user