Merge "Add min-height to account list in reply dialog"
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.js b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.js
index 2ccb327..fab728d 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.js
+++ b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog.js
@@ -69,6 +69,10 @@
this.fire('cancel', null, {bubbles: false});
},
+ resetFocus() {
+ this.$.branchInput.focus();
+ },
+
_getProjectBranchesSuggestions(input) {
if (input.startsWith('refs/heads/')) {
input = input.substring('refs/heads/'.length);
diff --git a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog_test.html b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog_test.html
index 577a66f..0956f84 100644
--- a/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog_test.html
+++ b/polygerrit-ui/app/elements/change/gr-confirm-cherrypick-dialog/gr-confirm-cherrypick-dialog_test.html
@@ -34,8 +34,10 @@
<script>
suite('gr-confirm-cherrypick-dialog tests', () => {
let element;
+ let sandbox;
setup(() => {
+ sandbox = sinon.sandbox.create();
stub('gr-rest-api-interface', {
getProjectBranches(input) {
if (input.startsWith('test')) {
@@ -55,6 +57,8 @@
element.project = 'test-project';
});
+ teardown(() => { sandbox.restore(); });
+
test('with merged change', () => {
element.changeStatus = 'MERGED';
element.commitMessage = 'message\n';
@@ -93,6 +97,12 @@
});
});
+ test('resetFocus', () => {
+ const focusStub = sandbox.stub(element.$.branchInput, 'focus');
+ element.resetFocus();
+ assert.isTrue(focusStub.called);
+ });
+
test('_getProjectBranchesSuggestions non-empty', done => {
element._getProjectBranchesSuggestions('test-branch').then(branches => {
assert.equal(branches.length, 1);
diff --git a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.js b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.js
index 86594d3..5652793 100644
--- a/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.js
+++ b/polygerrit-ui/app/elements/edit/gr-editor-view/gr-editor-view.js
@@ -106,17 +106,7 @@
},
_getFileContent(changeNum, path) {
- return this.$.restAPI.getFileInChangeEdit(changeNum, path).then(res => {
- if (!res.ok) {
- if (res.status === 404) {
- // No edits have been made yet.
- return this.$.restAPI.getFileInChangeEdit(changeNum, path, true)
- .then(res => res.text);
- }
- return '';
- }
- return res.text;
- });
+ return this.$.restAPI.getFileInChangeEdit(changeNum, path);
},
_saveEdit() {
diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js
index 033d01b..837552e 100644
--- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js
+++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js
@@ -1269,20 +1269,14 @@
* Gets a file in a change edit.
* @param {number|string} changeNum
* @param {string} path
- * @param {boolean=} opt_base If specified, file contents come from change
- * edit's base patchset.
*/
- getFileInChangeEdit(changeNum, path, opt_base) {
+ getFileInChangeEdit(changeNum, path) {
const e = '/edit/' + encodeURIComponent(path);
- let payload = null;
- if (opt_base) { payload = {base: true}; }
- return this.getChangeURLAndSend(changeNum, 'GET', null, e, payload)
- .then(res => {
+ const headers = {Accept: 'application/json'};
+ return this.getChangeURLAndSend(changeNum, 'GET', null, e, null, null,
+ null, null, headers).then(res => {
if (!res.ok) { return res; }
- return res.text().then(text => {
- res.text = atob(text);
- return res;
- });
+ return this.getResponseObject(res);
});
},
@@ -1348,8 +1342,10 @@
* passed as null sometimes.
* @param {?=} opt_ctx
* @param {?string=} opt_contentType
+ * @param {Object=} opt_headers
*/
- send(method, url, opt_body, opt_errFn, opt_ctx, opt_contentType) {
+ send(method, url, opt_body, opt_errFn, opt_ctx, opt_contentType,
+ opt_headers) {
const options = {method};
if (opt_body) {
options.headers = new Headers();
@@ -1360,6 +1356,13 @@
}
options.body = opt_body;
}
+ if (opt_headers) {
+ if (!options.headers) { options.headers = new Headers(); }
+ for (const header in opt_headers) {
+ if (!opt_headers.hasOwnProperty(header)) { continue; }
+ options.headers.set(header, opt_headers[header]);
+ }
+ }
return this._auth.fetch(this.getBaseUrl() + url, options)
.then(response => {
if (!response.ok) {
@@ -1368,7 +1371,6 @@
}
this.fire('server-error', {response});
}
-
return response;
}).catch(err => {
this.fire('network-error', {error: err});
@@ -1881,13 +1883,14 @@
* @param {?function(?Response, string=)=} opt_errFn
* @param {?=} opt_ctx
* @param {?=} opt_contentType
+ * @param {Object=} opt_headers
* @return {!Promise<!Object>}
*/
getChangeURLAndSend(changeNum, method, patchNum, endpoint, opt_payload,
- opt_errFn, opt_ctx, opt_contentType) {
+ opt_errFn, opt_ctx, opt_contentType, opt_headers) {
return this._changeBaseURL(changeNum, patchNum).then(url => {
return this.send(method, url + endpoint, opt_payload, opt_errFn,
- opt_ctx, opt_contentType);
+ opt_ctx, opt_contentType, opt_headers);
});
},