Skip to content

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

Merged
epixa merged 1 commit intoelastic:masterfrom
kobelb:dashboard-grid-dirty
Dec 2, 2016
Merged

Modifying the dashboard grid to not unnecessarily set appStatus.dirty#9307
epixa merged 1 commit intoelastic:masterfrom
kobelb:dashboard-grid-dirty

Conversation

@kobelb
Copy link
Copy Markdown
Contributor

@kobelb kobelb commented Dec 1, 2016

Previously, we were sorting the $scope.panels so that Gridster would display them in the proper order. This has the side-effect of setting the appStatus.dirty to true whenever this happened as described in #9305

Moving the sorting to occur when the panels are about to be added to Gridster resolves this issue because it's no longer modifying $scope.panels.

Closes: #9305

Copy link
Copy Markdown

@stacey-gammon stacey-gammon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for fixing this!

@spalger spalger self-assigned this Dec 2, 2016
Copy link
Copy Markdown
Contributor

@spalger spalger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but I do have a suggestion for readability

// 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) => {
Copy link
Copy Markdown
Contributor

@spalger spalger Dec 2, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was confused about why this worked at first, but then I realized it is sorting a copy of state.panels rather than modifying it. I think future readers would benefit from that fact being a bit more obvious somehow.

Maybe changing added.forEach(addPanel); to addPanels(added) and making addPanels() do something like:

function addPanels(panels) {
  // copy and sort the panels by row before applying them so
  // that gridster lays them out correctly
  const sortedPanels = panels.slice().sort(...);
  sortedPanels.forEach(appPanel);
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it! I'll make those changes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this change works as-is, let's get it in and then make tweaks in a follow up

@epixa epixa merged commit 083d564 into elastic:master Dec 2, 2016
elastic-jasper added a commit that referenced this pull request Dec 2, 2016
Backports PR #9307

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

* Original sha: 2431ec0
* Authored by kobelb <brandon.kobel@elastic.co> on 2016-12-01T16:23:19Z
elastic-jasper added a commit that referenced this pull request Dec 2, 2016
Backports PR #9307

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

* Original sha: 2431ec0
* Authored by kobelb <brandon.kobel@elastic.co> on 2016-12-01T16:23:19Z
epixa pushed a commit that referenced this pull request Dec 2, 2016
…#9342)

Backports PR #9307

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

* Original sha: 2431ec0
* Authored by kobelb <brandon.kobel@elastic.co> on 2016-12-01T16:23:19Z
epixa pushed a commit that referenced this pull request Dec 2, 2016
…#9341)

Backports PR #9307

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

* Original sha: 2431ec0
* Authored by kobelb <brandon.kobel@elastic.co> on 2016-12-01T16:23:19Z
airow pushed a commit to airow/kibana that referenced this pull request Feb 16, 2017
…elastic#9342)

Backports PR elastic#9307

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

* Original sha: 2431ec0
* Authored by kobelb <brandon.kobel@elastic.co> on 2016-12-01T16:23:19Z

Former-commit-id: d85c254
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dashboard grid unnecessarily setting $appStatus.dirty

5 participants