Filter revert submission button from change actions Revert button allows user to choose between revert submission, changes. No need to display the revert submission button now. Change-Id: Ib339c1ef27bf51c1aa152dd54f34752065a2edc1
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 299c12a..deaa094 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
@@ -197,6 +197,12 @@ REVERT_SUBMISSION: 2, }; + /* Revert submission is skipped as the normal revert dialog will now show + the user a choice between reverting single change or an entire submission. + Hence, a second button is not needed. + */ + const SKIP_ACTION_KEYS = [ChangeActions.REVERT_SUBMISSION]; + /** * @appliesMixin Gerrit.FireMixin * @appliesMixin Gerrit.PatchSetMixin @@ -1470,7 +1476,8 @@ action.icon = action.__key; } return action; - }); + }) + .filter(action => !this._shouldSkipAction(action)); } _getActionPriority(action) { @@ -1508,6 +1515,10 @@ } } + _shouldSkipAction(action) { + return SKIP_ACTION_KEYS.includes(action.__key); + } + _computeTopLevelActions(actionRecord, hiddenActionsRecord) { const hiddenActions = hiddenActionsRecord.base || []; return actionRecord.base.filter(a => {
diff --git a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html index de6817d..a6e491e 100644 --- a/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html +++ b/polygerrit-ui/app/elements/change/gr-change-actions/gr-change-actions_test.html
@@ -67,6 +67,12 @@ title: 'Submit patch set 2 into master', enabled: true, }, + revert_submission: { + method: 'POST', + label: 'Revert submission', + title: 'Revert this submission', + enabled: true, + }, }); }, send(method, url, payload) { @@ -126,6 +132,11 @@ element._topLevelActions.length - 1); }); + test('revert submission action is skipped', () => { + assert.isFalse(element._allActionValues.includes(action => + action.key === 'revert_submission')); + }); + test('_shouldHideActions', () => { assert.isTrue(element._shouldHideActions(undefined, true)); assert.isTrue(element._shouldHideActions({base: {}}, false));