From 5008b4491f817e5f865a590f53a092870630ef4c Mon Sep 17 00:00:00 2001 From: Viktar Donich Date: Wed, 8 Jun 2016 12:37:31 -0700 Subject: [PATCH] Add a checkbox to hide ranged comments behind Also adds concept of locally stored preferences. Change-Id: Ib074a682228d5360a932af696e18967e8e3473be --- .../gr-diff-preferences.html | 11 +++++++++++ .../gr-diff-preferences.js | 19 +++++++++++++++++++ .../gr-diff-preferences_test.html | 17 +++++++++++++++++ .../diff/gr-diff-view/gr-diff-view.html | 3 +++ .../diff/gr-diff-view/gr-diff-view.js | 3 +++ .../app/elements/diff/gr-diff/gr-diff.js | 1 + .../elements/shared/gr-storage/gr-storage.js | 8 ++++++++ 7 files changed, 62 insertions(+) diff --git a/polygerrit-ui/app/elements/diff/gr-diff-preferences/gr-diff-preferences.html b/polygerrit-ui/app/elements/diff/gr-diff-preferences/gr-diff-preferences.html index addb026137..ff48213688 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff-preferences/gr-diff-preferences.html +++ b/polygerrit-ui/app/elements/diff/gr-diff-preferences/gr-diff-preferences.html @@ -17,6 +17,7 @@ limitations under the License. + diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js index 8144385e15..6eefe077ac 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js +++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.js @@ -69,6 +69,7 @@ value: true, }, _prefs: Object, + _localPrefs: Object, _projectConfig: Object, _userPrefs: Object, _diffMode: { @@ -136,6 +137,7 @@ }, _getDiffPreferences: function() { + this._localPrefs = this.$.storage.getPreferences(); return this.$.restAPI.getDiffPreferences(); }, @@ -407,6 +409,7 @@ e.stopPropagation(); var el = Polymer.dom(e).rootTarget; el.disabled = true; + this.$.storage.savePreferences(this._localPrefs); this._saveDiffPreferences().then(function(response) { el.disabled = false; if (!response.ok) { return response; } diff --git a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.js b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.js index ea64581a7d..f89d1e8cbe 100644 --- a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.js +++ b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.js @@ -43,6 +43,7 @@ computed: '_computeIsImageDiff(_diff)', notify: true, }, + hasRangedComments: Boolean, _loggedIn: { type: Boolean, diff --git a/polygerrit-ui/app/elements/shared/gr-storage/gr-storage.js b/polygerrit-ui/app/elements/shared/gr-storage/gr-storage.js index ef3a6c0485..55664ebc74 100644 --- a/polygerrit-ui/app/elements/shared/gr-storage/gr-storage.js +++ b/polygerrit-ui/app/elements/shared/gr-storage/gr-storage.js @@ -48,6 +48,14 @@ this._storage.removeItem(key); }, + getPreferences: function() { + return this._getObject('localPrefs'); + }, + + savePreferences: function(localPrefs) { + this._setObject('localPrefs', localPrefs || null); + }, + _getDraftKey: function(location) { return ['draft', location.changeNum, location.patchNum, location.path, location.line].join(':');