summaryrefslogtreecommitdiffstats
path: root/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
diff options
context:
space:
mode:
Diffstat (limited to 'polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js')
-rw-r--r--polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js30
1 files changed, 23 insertions, 7 deletions
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
index 368b11b5a2..3e5c4f760c 100644
--- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
+++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions.js
@@ -991,6 +991,14 @@
},
_handleCherrypickConfirm() {
+ this._handleCherryPickRestApi(false);
+ },
+
+ _handleCherrypickConflictConfirm() {
+ this._handleCherryPickRestApi(true);
+ },
+
+ _handleCherryPickRestApi(conflicts) {
const el = this.$.confirmCherrypick;
if (!el.branch) {
// TODO(davido): Fix error handling
@@ -1011,6 +1019,7 @@
destination: el.branch,
base: el.baseCommit ? el.baseCommit : null,
message: el.message,
+ allow_conflicts: conflicts,
}
);
},
@@ -1113,8 +1122,9 @@
_fireAction(endpoint, action, revAction, opt_payload) {
const cleanupFn =
this._setLoadingOnButtonWithKey(action.__type, action.__key);
- this._send(action.method, opt_payload, endpoint, revAction, cleanupFn)
- .then(this._handleResponse.bind(this, action));
+
+ this._send(action.method, opt_payload, endpoint, revAction, cleanupFn,
+ action).then(this._handleResponse.bind(this, action));
},
_showActionDialog(dialog) {
@@ -1171,7 +1181,14 @@
});
},
- _handleResponseError(response) {
+ _handleResponseError(action, response, body) {
+ if (action && action.__key === RevisionActions.CHERRYPICK) {
+ if (response && response.status === 409 &&
+ body && !body.allow_conflicts) {
+ return this._showActionDialog(
+ this.$.confirmCherrypickConflict);
+ }
+ }
return response.text().then(errText => {
this.fire('show-error',
{message: `Could not perform action: ${errText}`});
@@ -1187,13 +1204,12 @@
* @param {string} actionEndpoint
* @param {boolean} revisionAction
* @param {?Function} cleanupFn
- * @param {?Function=} opt_errorFn
+ * @param {!Object|undefined} action
*/
- _send(method, payload, actionEndpoint, revisionAction, cleanupFn,
- opt_errorFn) {
+ _send(method, payload, actionEndpoint, revisionAction, cleanupFn, action) {
const handleError = response => {
cleanupFn.call(this);
- this._handleResponseError(response);
+ this._handleResponseError(action, response, payload);
};
return this.fetchChangeUpdates(this.change, this.$.restAPI)