summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaladox none <thomasmulhall410@yahoo.com>2021-07-12 13:10:09 +0000
committerPaladox none <thomasmulhall410@yahoo.com>2021-07-17 16:13:42 +0000
commite2c69b31613dabdd1bcfa047d414c98c88bd623a (patch)
tree3d5798239edfe6b4ac48ac0f52a0bcde92545467
parent0fa4d3555a2eaeaa93b5c7bc6b0eb3d36d6ea161 (diff)
Fix deleting edits when change is merged
This fixes supporting deleting a change edit after change is merged or abandoned. This also improves the user interaction so a dialog is not shown because a change edit didn't exist on /commit?links. Rather we now write to the console log. This also has the benefit of making the redirect of /edit -> ,edit seamless because no more dialog showing and having to press close which could cause some confusion with the user. Since we're redirecting /edit -> ,edit anyways we don't need the dialog. Change-Id: I2e478d203ae7eb95acf92b518b73c9ad6b73c77d
-rw-r--r--polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
index b8b674b978..7ce6990ca2 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
@@ -1564,6 +1564,26 @@ class GrChangeView extends mixinBehaviors( [
*/
_processEdit(change, edit) {
if (
+ !edit &&
+ this._patchRange &&
+ this._patchRange.patchNum === this.EDIT_NAME &&
+ change.status === this.ChangeStatus.NEW
+ ) {
+ /* eslint-disable max-len */
+ const message = 'Change edit not found. Please create a change edit.';
+ this.dispatchEvent(
+ new CustomEvent('show-alert', {
+ detail: {message},
+ bubbles: true,
+ composed: true,
+ })
+ );
+ GerritNav.navigateToChange(change);
+ return;
+ }
+
+ if (
+ !edit &&
(change.status === this.ChangeStatus.MERGED ||
change.status === this.ChangeStatus.ABANDONED) &&
this._editMode
@@ -1711,6 +1731,24 @@ class GrChangeView extends mixinBehaviors( [
}
_getCommitInfo() {
+ // We only call _getEdit if the patchset number is an edit.
+ // We have to do this to ensure we can tell if an edit
+ // exists or not.
+ // This safely works even if a edit does not exist.
+ if (this._patchRange.patchNum === this.EDIT_NAME) {
+ return this._getEdit().then(edit => {
+ if (!edit) {
+ return Promise.resolve();
+ }
+
+ return this._getChangeCommitInfo();
+ });
+ }
+
+ return this._getChangeCommitInfo();
+ }
+
+ _getChangeCommitInfo() {
return this.$.restAPI.getChangeCommitInfo(
this._changeNum, this._patchRange.patchNum).then(
commitInfo => {