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
This commit is contained in:
Dhruv Srivastava
2020-02-13 19:15:20 +01:00
parent ca113273ff
commit 535e85d883
2 changed files with 23 additions and 1 deletions

View File

@@ -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 => {

View File

@@ -67,6 +67,12 @@ limitations under the License.
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 @@ limitations under the License.
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));