diff options
author | Milutin Kristofic <milutin@google.com> | 2024-04-09 09:30:12 +0200 |
---|---|---|
committer | Paladox none <thomasmulhall410@yahoo.com> | 2024-04-16 14:26:22 +0000 |
commit | 2a8af9ef9676adc19cd957062110a73f6e4ad773 (patch) | |
tree | f5055cbdab1b07df631b1c6c9bb2399b3f05974c | |
parent | 605f985e3dcdb332408ccb41a5dd850b6208f734 (diff) |
Do not disable apply fix when on Edit patchset
Apply Fix Dialog was calculating latest patch num from change revision
without ignoring EDIT patch num. Therefore you couldn't apply fixes
when in EDIT mode even though they can be applied. We now get
latestPatchNum from change model that calculate it correctly.
Google-Bug-Id: b/306779262
Release-Notes: skip
Change-Id: Ia37dc7312e1d7ebfc9cf6b9ed36ef255a5c48ece
(cherry picked from commit 0a99c4178177eb163f10af7d6e46e9f6a131f194)
-rw-r--r-- | polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.ts | 16 | ||||
-rw-r--r-- | polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog_test.ts | 7 |
2 files changed, 16 insertions, 7 deletions
diff --git a/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.ts b/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.ts index 0a31677db8..7d62735061 100644 --- a/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.ts +++ b/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.ts @@ -15,6 +15,7 @@ import { PatchSetNum, BasePatchSetNum, FilePathToDiffInfoMap, + PatchSetNumber, } from '../../../types/common'; import {DiffInfo, DiffPreferencesInfo} from '../../../types/diff'; import {PROVIDED_FIX_ID} from '../../../utils/comment-util'; @@ -72,6 +73,8 @@ export class GrApplyFixDialog extends LitElement { @state() patchNum?: PatchSetNum; + @state() latestPatchNum?: PatchSetNumber; + @state() currentFix?: FixSuggestionInfo; @@ -146,6 +149,11 @@ export class GrApplyFixDialog extends LitElement { () => this.getChangeModel().changeNum$, changeNum => (this.changeNum = changeNum) ); + subscribe( + this, + () => this.getChangeModel().latestPatchNum$, + x => (this.latestPatchNum = x) + ); } static override get styles() { @@ -383,18 +391,14 @@ export class GrApplyFixDialog extends LitElement { private computeTooltip() { if (!this.change || !this.patchNum) return ''; - const latestPatchNum = - this.change.revisions[this.change.current_revision]._number; - return latestPatchNum !== this.patchNum + return this.latestPatchNum !== this.patchNum ? 'You cannot apply this fix because it is from a previous patchset' : ''; } private computeDisableApplyFixButton() { if (!this.change || !this.patchNum) return true; - const latestPatchNum = - this.change.revisions[this.change.current_revision]._number; - return this.patchNum !== latestPatchNum || this.isApplyFixLoading; + return this.patchNum !== this.latestPatchNum || this.isApplyFixLoading; } // visible for testing diff --git a/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog_test.ts b/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog_test.ts index 267c5699c3..dc7ab98ac3 100644 --- a/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog_test.ts +++ b/polygerrit-ui/app/elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog_test.ts @@ -11,7 +11,7 @@ import { } from '../../core/gr-navigation/gr-navigation'; import {queryAndAssert, stubRestApi} from '../../../test/test-utils'; import {GrApplyFixDialog} from './gr-apply-fix-dialog'; -import {PatchSetNum} from '../../../types/common'; +import {PatchSetNum, PatchSetNumber} from '../../../types/common'; import { createFixSuggestionInfo, createParsedChange, @@ -73,6 +73,8 @@ suite('gr-apply-fix-dialog tests', () => { }; element.changeNum = change._number; element.patchNum = change.revisions[change.current_revision]._number; + element.latestPatchNum = change.revisions[change.current_revision] + ._number as PatchSetNumber; element.change = change; element.diffPrefs = { ...createDefaultDiffPrefs(), @@ -169,6 +171,9 @@ suite('gr-apply-fix-dialog tests', () => { revisions: createRevisions(2), current_revision: getCurrentRevision(0), }; + element.latestPatchNum = element.change.revisions[ + element.change.current_revision + ]._number as PatchSetNumber; await open(TWO_FIXES); const button = getConfirmButton(); assert.isTrue(button.hasAttribute('disabled')); |