Modifying the dashboard grid to not unnecessarily set appStatus.dirty (#9307)

This commit is contained in:
Brandon Kobel 2016-12-02 12:01:59 -05:00 committed by Court Ewing
parent f432698c27
commit 083d564a7c

View file

@ -36,20 +36,6 @@ app.directive('dashboardGrid', function ($compile, Notifier) {
function init() {
$el.addClass('gridster');
// See issue https://github.com/elastic/kibana/issues/2138 and the
// subsequent fix for why we need to sort here. Short story is that
// gridster can fail to render widgets in the correct order, depending
// on the specific order of the panels.
// See https://github.com/ducksboard/gridster.js/issues/147
// for some additional back story.
$state.panels.sort((a, b) => {
if (a.row === b.row) {
return a.col - b.col;
} else {
return a.row - b.row;
}
});
gridster = $el.gridster({
max_cols: COLS,
min_cols: COLS,
@ -85,7 +71,23 @@ app.directive('dashboardGrid', function ($compile, Notifier) {
const added = _.difference(panels, currentPanels);
if (removed.length) removed.forEach(removePanel);
if (added.length) added.forEach(addPanel);
if (added.length) {
// See issue https://github.com/elastic/kibana/issues/2138 and the
// subsequent fix for why we need to sort here. Short story is that
// gridster can fail to render widgets in the correct order, depending
// on the specific order of the panels.
// See https://github.com/ducksboard/gridster.js/issues/147
// for some additional back story.
added.sort((a, b) => {
if (a.row === b.row) {
return a.col - b.col;
} else {
return a.row - b.row;
}
});
added.forEach(addPanel);
};
// ensure that every panel can be serialized now that we are done
$state.panels.forEach(makePanelSerializeable);