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

Backports PR #9307

**Commit 1:**
Modifying the dashboard grid to not unnecessarily set appStatus.dirty

* Original sha: 2431ec0c5d
* Authored by kobelb <brandon.kobel@elastic.co> on 2016-12-01T16:23:19Z
This commit is contained in:
jasper 2016-12-02 12:02:51 -05:00 committed by Court Ewing
parent 84a4a0df57
commit 64799faf67

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);