{
+ const patchNum = '1';
+
+ const change1 = {
+ revisions: {
+ r1: {_number: 1, commit: {parents: []}},
+ },
+ };
+ assert.isTrue(element._computeHidePatchFile(change1, patchNum));
+
+ const change2 = {
+ revisions: {
+ r1: {_number: 1, commit: {parents: [
+ {commit: 'p1'},
+ ]}},
+ },
+ };
+ assert.isFalse(element._computeHidePatchFile(change2, patchNum));
+ });
});
diff --git a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.html b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.html
index 1a307f78e1..f7d90eb472 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.html
+++ b/polygerrit-ui/app/elements/change/gr-file-list-header/gr-file-list-header.html
@@ -28,7 +28,6 @@ limitations under the License.
-
-
+
+
diff --git a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js
index 8bab9d0a0e..460512aac4 100644
--- a/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js
+++ b/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.js
@@ -125,7 +125,6 @@
},
/** @type {?} */
_userPrefs: Object,
- _localPrefs: Object,
_showInlineDiffs: Boolean,
numFilesShown: {
type: Number,
@@ -269,7 +268,6 @@
});
}));
- this._localPrefs = this.$.storage.getPreferences();
promises.push(this._getDiffPreferences().then(prefs => {
this.diffPrefs = prefs;
}));
@@ -297,7 +295,7 @@
},
openDiffPrefs() {
- this.$.diffPreferences.open();
+ this.$.diffPreferencesDialog.open();
},
_calculatePatchChange(files) {
@@ -1255,5 +1253,11 @@
return 'Mark as reviewed (shortcut: r)';
},
+
+ _handleReloadingDiffPreference() {
+ this._getDiffPreferences().then(prefs => {
+ this.diffPrefs = prefs;
+ });
+ },
});
})();
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-preferences-dialog/gr-diff-preferences-dialog.html b/polygerrit-ui/app/elements/diff/gr-diff-preferences-dialog/gr-diff-preferences-dialog.html
new file mode 100644
index 0000000000..5cff316dda
--- /dev/null
+++ b/polygerrit-ui/app/elements/diff/gr-diff-preferences-dialog/gr-diff-preferences-dialog.html
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ Diff Preferences
+
+
+
+ Cancel
+
+
+ Save
+
+
+
+
+
+
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-preferences-dialog/gr-diff-preferences-dialog.js b/polygerrit-ui/app/elements/diff/gr-diff-preferences-dialog/gr-diff-preferences-dialog.js
new file mode 100644
index 0000000000..b50ef692ad
--- /dev/null
+++ b/polygerrit-ui/app/elements/diff/gr-diff-preferences-dialog/gr-diff-preferences-dialog.js
@@ -0,0 +1,66 @@
+/**
+ * @license
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+(function() {
+ 'use strict';
+
+ Polymer({
+ is: 'gr-diff-preferences-dialog',
+
+ properties: {
+ /** @type {?} */
+ diffPrefs: Object,
+
+ _diffPrefsChanged: Boolean,
+ },
+
+ getFocusStops() {
+ return {
+ start: this.$.contextSelect,
+ end: this.$.saveButton,
+ };
+ },
+
+ resetFocus() {
+ this.$.contextSelect.focus();
+ },
+
+ _computeHeaderClass(changed) {
+ return changed ? 'edited' : '';
+ },
+
+ _handleCancelDiff(e) {
+ e.stopPropagation();
+ this.$.diffPrefsOverlay.close();
+ },
+
+ open() {
+ this.$.diffPrefsOverlay.open().then(() => {
+ const focusStops = this.getFocusStops();
+ this.$.diffPrefsOverlay.setFocusStops(focusStops);
+ this.resetFocus();
+ });
+ },
+
+ _handleSaveDiffPreferences() {
+ this.$.diffPreferences.save().then(() => {
+ this.fire('reload-diff-preference', null, {bubbles: false});
+
+ this.$.diffPrefsOverlay.close();
+ });
+ },
+ });
+})();
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
deleted file mode 100644
index a22f689022..0000000000
--- a/polygerrit-ui/app/elements/diff/gr-diff-preferences/gr-diff-preferences.html
+++ /dev/null
@@ -1,173 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Cancel
-
- Save
-
-
-
-
-
-
-
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-preferences/gr-diff-preferences.js b/polygerrit-ui/app/elements/diff/gr-diff-preferences/gr-diff-preferences.js
deleted file mode 100644
index 8fc90b9815..0000000000
--- a/polygerrit-ui/app/elements/diff/gr-diff-preferences/gr-diff-preferences.js
+++ /dev/null
@@ -1,144 +0,0 @@
-/**
- * @license
- * Copyright (C) 2016 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-(function() {
- 'use strict';
-
- Polymer({
- is: 'gr-diff-preferences',
-
- properties: {
- prefs: {
- type: Object,
- notify: true,
- },
- localPrefs: {
- type: Object,
- notify: true,
- },
- disabled: {
- type: Boolean,
- value: false,
- reflectToAttribute: true,
- },
-
- /** @type {?} */
- _newPrefs: Object,
- _newLocalPrefs: Object,
- },
-
- observers: [
- '_prefsChanged(prefs.*)',
- '_localPrefsChanged(localPrefs.*)',
- ],
-
- getFocusStops() {
- return {
- start: this.$.contextSelect,
- end: this.$.saveButton,
- };
- },
-
- resetFocus() {
- this.$.contextSelect.focus();
- },
-
- _prefsChanged(changeRecord) {
- const prefs = changeRecord.base;
- // NOTE: Object.assign is NOT automatically a deep copy. If prefs adds
- // an object as a value, it must be marked enumerable.
- this._newPrefs = Object.assign({}, prefs);
- this.$.contextSelect.value = prefs.context;
- this.$.showTabsInput.checked = prefs.show_tabs;
- this.$.showTrailingWhitespaceInput.checked = prefs.show_whitespace_errors;
- this.$.lineWrappingInput.checked = prefs.line_wrapping;
- this.$.syntaxHighlightInput.checked = prefs.syntax_highlighting;
- this.$.automaticReviewInput.checked = !prefs.manual_review;
- this.$.ignoreWhitespace.value = prefs.ignore_whitespace;
- },
-
- _localPrefsChanged(changeRecord) {
- const localPrefs = changeRecord.base || {};
- this._newLocalPrefs = Object.assign({}, localPrefs);
- },
-
- _handleContextSelectChange(e) {
- const selectEl = Polymer.dom(e).rootTarget;
- this.set('_newPrefs.context', parseInt(selectEl.value, 10));
- },
-
- _handleIgnoreWhitespaceChange(e) {
- const selectEl = Polymer.dom(e).rootTarget;
- this.set('_newPrefs.ignore_whitespace', selectEl.value);
- },
-
- _handleShowTabsTap(e) {
- this.set('_newPrefs.show_tabs', Polymer.dom(e).rootTarget.checked);
- },
-
- _handleShowTrailingWhitespaceTap(e) {
- this.set('_newPrefs.show_whitespace_errors',
- Polymer.dom(e).rootTarget.checked);
- },
-
- _handleSyntaxHighlightTap(e) {
- this.set('_newPrefs.syntax_highlighting',
- Polymer.dom(e).rootTarget.checked);
- },
-
- _handlelineWrappingTap(e) {
- this.set('_newPrefs.line_wrapping', Polymer.dom(e).rootTarget.checked);
- },
-
- _handleAutomaticReviewTap(e) {
- this.set('_newPrefs.manual_review', !Polymer.dom(e).rootTarget.checked);
- },
-
- _handleSave(e) {
- e.stopPropagation();
- this.prefs = this._newPrefs;
- this.localPrefs = this._newLocalPrefs;
- const el = Polymer.dom(e).rootTarget;
- el.disabled = true;
- this.$.storage.savePreferences(this._localPrefs);
- this._saveDiffPreferences().then(response => {
- el.disabled = false;
- if (!response.ok) { return response; }
-
- this.$.prefsOverlay.close();
- }).catch(err => {
- el.disabled = false;
- });
- },
-
- _handleCancel(e) {
- e.stopPropagation();
- this.$.prefsOverlay.close();
- },
-
- open() {
- this.$.prefsOverlay.open().then(() => {
- const focusStops = this.getFocusStops();
- this.$.prefsOverlay.setFocusStops(focusStops);
- this.resetFocus();
- });
- },
-
- _saveDiffPreferences() {
- return this.$.restAPI.saveDiffPreferences(this.prefs);
- },
- });
-})();
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-preferences/gr-diff-preferences_test.html b/polygerrit-ui/app/elements/diff/gr-diff-preferences/gr-diff-preferences_test.html
deleted file mode 100644
index d9e14c0265..0000000000
--- a/polygerrit-ui/app/elements/diff/gr-diff-preferences/gr-diff-preferences_test.html
+++ /dev/null
@@ -1,110 +0,0 @@
-
-
-
-
-
gr-diff-preferences
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.html b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.html
index b3210cc7db..57525e19af 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view.html
@@ -34,9 +34,9 @@ limitations under the License.
-
-
+
+
@@ -338,10 +338,11 @@ limitations under the License.
on-comment-anchor-tap="_onLineSelected"
on-line-selected="_onLineSelected">
-
+
+
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 dadf8a7a97..c8b3c4bafd 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
@@ -266,7 +266,9 @@
},
_getDiffPreferences() {
- return this.$.restAPI.getDiffPreferences();
+ return this.$.restAPI.getDiffPreferences().then(prefs => {
+ this._prefs = prefs;
+ });
},
_getPreferences() {
@@ -466,7 +468,7 @@
if (this._diffPrefsDisabled) { return; }
e.preventDefault();
- this.$.diffPreferences.open();
+ this.$.diffPreferencesDialog.open();
},
_handleToggleDiffMode(e) {
@@ -617,10 +619,7 @@
const promises = [];
- this._localPrefs = this.$.storage.getPreferences();
- promises.push(this._getDiffPreferences().then(prefs => {
- this._prefs = prefs;
- }));
+ promises.push(this._getDiffPreferences());
promises.push(this._getPreferences().then(prefs => {
this._userPrefs = prefs;
@@ -846,22 +845,7 @@
_handlePrefsTap(e) {
e.preventDefault();
- this.$.diffPreferences.open();
- },
-
- _handlePrefsSave(e) {
- e.stopPropagation();
- const el = Polymer.dom(e).rootTarget;
- el.disabled = true;
- this.$.storage.savePreferences(this._localPrefs);
- this._saveDiffPreferences().then(response => {
- el.disabled = false;
- if (!response.ok) { return response; }
-
- this.$.prefsOverlay.close();
- }).catch(err => {
- el.disabled = false;
- });
+ this.$.diffPreferencesDialog.open();
},
/**
@@ -1049,5 +1033,9 @@
(file === this._path || !this._reviewedFiles.has(file)));
this._navToFile(this._path, unreviewedFiles, 1);
},
+
+ _handleReloadingDiffPreference() {
+ this._getDiffPreferences();
+ },
});
})();
diff --git a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.html b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.html
index 02743300e1..c4d6c95cc7 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.html
+++ b/polygerrit-ui/app/elements/diff/gr-diff-view/gr-diff-view_test.html
@@ -173,7 +173,7 @@ limitations under the License.
assert.isTrue(element._loading);
const showPrefsStub =
- sandbox.stub(element.$.diffPreferences.$.prefsOverlay, 'open',
+ sandbox.stub(element.$.diffPreferencesDialog, 'open',
() => Promise.resolve());
MockInteractions.pressAndReleaseKeyOn(element, 188, null, ',');
@@ -386,7 +386,7 @@ limitations under the License.
test('prefsButton opens gr-diff-preferences', () => {
const handlePrefsTapSpy = sandbox.spy(element, '_handlePrefsTap');
- const overlayOpenStub = sandbox.stub(element.$.diffPreferences,
+ const overlayOpenStub = sandbox.stub(element.$.diffPreferencesDialog,
'open');
const prefsButton =
Polymer.dom(element.root).querySelector('.prefsButton');
diff --git a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.html b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.html
index 799cf5943b..3c4270f7e1 100644
--- a/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.html
+++ b/polygerrit-ui/app/elements/settings/gr-settings-view/gr-settings-view.html
@@ -27,6 +27,7 @@ limitations under the License.
+
@@ -194,6 +195,18 @@ limitations under the License.
+
+ Default Base For Merges
+
+
+
+
+
+
Diff view
@@ -259,110 +272,9 @@ limitations under the License.
Diff Preferences
diff --git a/polygerrit-ui/app/elements/shared/gr-diff-preferences/gr-diff-preferences.js b/polygerrit-ui/app/elements/shared/gr-diff-preferences/gr-diff-preferences.js
new file mode 100644
index 0000000000..e2278c2680
--- /dev/null
+++ b/polygerrit-ui/app/elements/shared/gr-diff-preferences/gr-diff-preferences.js
@@ -0,0 +1,78 @@
+/**
+ * @license
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+(function() {
+ 'use strict';
+
+ Polymer({
+ is: 'gr-diff-preferences',
+
+ properties: {
+ hasUnsavedChanges: {
+ type: Boolean,
+ notify: true,
+ value: false,
+ },
+
+ /** @type {?} */
+ diffPrefs: Object,
+ },
+
+ loadData() {
+ return this.$.restAPI.getDiffPreferences().then(prefs => {
+ this.diffPrefs = prefs;
+ });
+ },
+
+ _handleDiffPrefsChanged() {
+ this.hasUnsavedChanges = true;
+ },
+
+ _handleLineWrappingTap() {
+ this.set('diffPrefs.line_wrapping', this.$.lineWrappingInput.checked);
+ this._handleDiffPrefsChanged();
+ },
+
+ _handleShowTabsTap() {
+ this.set('diffPrefs.show_tabs', this.$.showTabsInput.checked);
+ this._handleDiffPrefsChanged();
+ },
+
+ _handleShowTrailingWhitespaceTap() {
+ this.set('diffPrefs.show_whitespace_errors',
+ this.$.showTrailingWhitespaceInput.checked);
+ this._handleDiffPrefsChanged();
+ },
+
+ _handleSyntaxHighlightTap() {
+ this.set('diffPrefs.syntax_highlighting',
+ this.$.syntaxHighlightInput.checked);
+ this._handleDiffPrefsChanged();
+ },
+
+ _handleAutomaticReviewTap() {
+ this.set('diffPrefs.manual_review',
+ this.$.automaticReviewInput.checked);
+ this._handleDiffPrefsChanged();
+ },
+
+ save() {
+ return this.$.restAPI.saveDiffPreferences(this.diffPrefs).then(res => {
+ this.hasUnsavedChanges = false;
+ });
+ },
+ });
+})();
diff --git a/polygerrit-ui/app/elements/shared/gr-diff-preferences/gr-diff-preferences_test.html b/polygerrit-ui/app/elements/shared/gr-diff-preferences/gr-diff-preferences_test.html
new file mode 100644
index 0000000000..511737fcd8
--- /dev/null
+++ b/polygerrit-ui/app/elements/shared/gr-diff-preferences/gr-diff-preferences_test.html
@@ -0,0 +1,123 @@
+
+
+
+
+
gr-diff-preferences
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/polygerrit-ui/app/test/index.html b/polygerrit-ui/app/test/index.html
index 32bd39663e..d9e1238c37 100644
--- a/polygerrit-ui/app/test/index.html
+++ b/polygerrit-ui/app/test/index.html
@@ -108,7 +108,6 @@ limitations under the License.
'diff/gr-diff-highlight/gr-annotation_test.html',
'diff/gr-diff-highlight/gr-diff-highlight_test.html',
'diff/gr-diff-mode-selector/gr-diff-mode-selector_test.html',
- 'diff/gr-diff-preferences/gr-diff-preferences_test.html',
'diff/gr-diff-processor/gr-diff-processor_test.html',
'diff/gr-diff-selection/gr-diff-selection_test.html',
'diff/gr-diff-view/gr-diff-view_test.html',
@@ -162,6 +161,7 @@ limitations under the License.
'shared/gr-cursor-manager/gr-cursor-manager_test.html',
'shared/gr-date-formatter/gr-date-formatter_test.html',
'shared/gr-dialog/gr-dialog_test.html',
+ 'shared/gr-diff-preferences/gr-diff-preferences_test.html',
'shared/gr-download-commands/gr-download-commands_test.html',
'shared/gr-dropdown-list/gr-dropdown-list_test.html',
'shared/gr-editable-content/gr-editable-content_test.html',