Merge "Add ability to hide quick approve button to GrChangeActionsInterface"

This commit is contained in:
viktard
2018-02-27 22:36:27 +00:00
committed by Gerrit Code Review
3 changed files with 35 additions and 0 deletions

View File

@@ -211,6 +211,10 @@
type: Boolean,
value: false,
},
_hideQuickApproveAction: {
type: Boolean,
value: false,
},
changeNum: String,
changeStatus: String,
commitNum: String,
@@ -653,7 +657,18 @@
return null;
},
hideQuickApproveAction() {
this._topLevelSecondaryActions =
this._topLevelSecondaryActions.filter(sa => {
return sa.key !== QUICK_APPROVE_ACTION.key;
});
this._hideQuickApproveAction = true;
},
_getQuickApproveAction() {
if (this._hideQuickApproveAction) {
return null;
}
const approval = this._getTopMissingApproval();
if (!approval) {
return null;

View File

@@ -1091,6 +1091,21 @@ limitations under the License.
assert.isNotNull(approveButton);
});
test('hide quick approve', () => {
const approveButton =
element.$$('gr-button[data-action-key=\'review\']');
assert.isNotNull(approveButton);
assert.isFalse(element._hideQuickApproveAction);
// Assert approve button gets removed from list of buttons.
element.hideQuickApproveAction();
flushAsynchronousOperations();
const approveButtonUpdated =
element.$$('gr-button[data-action-key=\'review\']');
assert.isNull(approveButtonUpdated);
assert.isTrue(element._hideQuickApproveAction);
});
test('is first in list of secondary actions', () => {
const approveButton = element.$.secondaryActions
.querySelector('gr-button');

View File

@@ -62,6 +62,11 @@
});
};
GrChangeActionsInterface.prototype.hideQuickApproveAction = function() {
ensureEl(this);
this._el.hideQuickApproveAction();
};
GrChangeActionsInterface.prototype.setActionOverflow = function(type, key,
overflow) {
ensureEl(this);