diff options
-rw-r--r-- | polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js | 38 |
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 => { |