PolyGerrit: Add rebase change edit to actions
Bug: Issue 4437 Bug: Issue 7213 Change-Id: I33b10c58db1f69acda1cfe107cc014c446568703
This commit is contained in:
@@ -203,6 +203,13 @@ limitations under the License.
|
||||
return allPatchSets[allPatchSets.length - 1].num;
|
||||
},
|
||||
|
||||
/** @return {Boolean} */
|
||||
hasEditBasedOnCurrentPatchSet(allPatchSets) {
|
||||
if (!allPatchSets || !allPatchSets.length) { return false; }
|
||||
return allPatchSets[allPatchSets.length - 1].num ===
|
||||
Gerrit.PatchSetBehavior.EDIT_NAME;
|
||||
},
|
||||
|
||||
/**
|
||||
* Check whether there is no newer patch than the latest patch that was
|
||||
* available when this change was loaded.
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
PRIVATE: 'private',
|
||||
PRIVATE_DELETE: 'private.delete',
|
||||
PUBLISH_EDIT: 'publishEdit',
|
||||
REBASE_EDIT: 'rebaseEdit',
|
||||
RESTORE: 'restore',
|
||||
REVERT: 'revert',
|
||||
UNIGNORE: 'unignore',
|
||||
@@ -120,6 +121,16 @@
|
||||
__type: 'revision',
|
||||
};
|
||||
|
||||
const REBASE_EDIT = {
|
||||
enabled: true,
|
||||
label: 'Rebase Edit',
|
||||
title: 'Rebase change edit',
|
||||
__key: 'rebaseEdit',
|
||||
__primary: false,
|
||||
__type: 'change',
|
||||
method: 'POST',
|
||||
};
|
||||
|
||||
const PUBLISH_EDIT = {
|
||||
enabled: true,
|
||||
label: 'Publish Edit',
|
||||
@@ -302,6 +313,10 @@
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
editBasedOnCurrentPatchSet: {
|
||||
type: Boolean,
|
||||
value: true,
|
||||
},
|
||||
},
|
||||
|
||||
ActionType,
|
||||
@@ -315,7 +330,7 @@
|
||||
|
||||
observers: [
|
||||
'_actionsChanged(actions.*, revisionActions.*, _additionalActions.*, ' +
|
||||
'editLoaded, change)',
|
||||
'editLoaded, editBasedOnCurrentPatchSet, change)',
|
||||
],
|
||||
|
||||
listeners: {
|
||||
@@ -449,7 +464,8 @@
|
||||
},
|
||||
|
||||
_actionsChanged(actionsChangeRecord, revisionActionsChangeRecord,
|
||||
additionalActionsChangeRecord, editLoaded, change) {
|
||||
additionalActionsChangeRecord, editLoaded, editBasedOnCurrentPatchSet,
|
||||
change) {
|
||||
const additionalActions = (additionalActionsChangeRecord &&
|
||||
additionalActionsChangeRecord.base) || [];
|
||||
this.hidden = this._keyCount(actionsChangeRecord) === 0 &&
|
||||
@@ -468,8 +484,22 @@
|
||||
if (Object.keys(changeActions).length !== 0) {
|
||||
if (editLoaded) {
|
||||
if (this.changeIsOpen(change.status)) {
|
||||
if (!changeActions.publishEdit) {
|
||||
this.set('actions.publishEdit', PUBLISH_EDIT);
|
||||
if (editBasedOnCurrentPatchSet) {
|
||||
if (!changeActions.publishEdit) {
|
||||
this.set('actions.publishEdit', PUBLISH_EDIT);
|
||||
}
|
||||
if (changeActions.rebaseEdit) {
|
||||
delete this.actions.rebaseEdit;
|
||||
this.notifyPath('actions.rebaseEdit');
|
||||
}
|
||||
} else {
|
||||
if (!changeActions.rebasEdit) {
|
||||
this.set('actions.rebaseEdit', REBASE_EDIT);
|
||||
}
|
||||
if (changeActions.publishEdit) {
|
||||
delete this.actions.publishEdit;
|
||||
this.notifyPath('actions.publishEdit');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!changeActions.deleteEdit) {
|
||||
@@ -480,6 +510,10 @@
|
||||
delete this.actions.publishEdit;
|
||||
this.notifyPath('actions.publishEdit');
|
||||
}
|
||||
if (changeActions.rebaseEdit) {
|
||||
delete this.actions.rebaseEdit;
|
||||
this.notifyPath('actions.rebaseEdit');
|
||||
}
|
||||
if (changeActions.deleteEdit) {
|
||||
delete this.actions.deleteEdit;
|
||||
this.notifyPath('actions.deleteEdit');
|
||||
@@ -700,6 +734,9 @@
|
||||
case ChangeActions.PUBLISH_EDIT:
|
||||
this._handlePublishEditTap();
|
||||
break;
|
||||
case ChangeActions.REBASE_EDIT:
|
||||
this._handleRebaseEditTap();
|
||||
break;
|
||||
default:
|
||||
this._fireAction(this._prependSlash(key), this.actions[key], false);
|
||||
}
|
||||
@@ -926,6 +963,7 @@
|
||||
case ChangeActions.WIP:
|
||||
case ChangeActions.DELETE_EDIT:
|
||||
case ChangeActions.PUBLISH_EDIT:
|
||||
case ChangeActions.REBASE_EDIT:
|
||||
page.show(this.changePath(this.changeNum));
|
||||
break;
|
||||
default:
|
||||
@@ -1025,6 +1063,10 @@
|
||||
this._fireAction('/edit:publish', this.actions.publishEdit, false);
|
||||
},
|
||||
|
||||
_handleRebaseEditTap() {
|
||||
this._fireAction('/edit:rebase', this.actions.rebaseEdit, false);
|
||||
},
|
||||
|
||||
_handleHideBackgroundContent() {
|
||||
this.$.mainContent.classList.add('overlayOpen');
|
||||
},
|
||||
|
||||
@@ -380,6 +380,15 @@ limitations under the License.
|
||||
__type: 'change',
|
||||
method: 'POST',
|
||||
};
|
||||
const rebaseEditAction = {
|
||||
enabled: true,
|
||||
label: 'Rebase Edit',
|
||||
title: 'Rebase change edit',
|
||||
__key: 'rebaseEdit',
|
||||
__primary: false,
|
||||
__type: 'change',
|
||||
method: 'POST',
|
||||
};
|
||||
|
||||
setup(() => {
|
||||
fireActionStub = sandbox.stub(element, '_fireAction');
|
||||
@@ -403,10 +412,14 @@ limitations under the License.
|
||||
fireActionStub.calledWith('/edit', deleteEditAction, false));
|
||||
});
|
||||
|
||||
test('show publish edit', () => {
|
||||
test('show publish edit but rebaseEdit is hidden', () => {
|
||||
element.change = {
|
||||
status: 'NEW',
|
||||
};
|
||||
const rebaseEditButton =
|
||||
element.$$('gr-button[data-action-key="rebaseEdit"]');
|
||||
assert.isNotOk(rebaseEditButton);
|
||||
|
||||
const publishEditButton =
|
||||
element.$$('gr-button[data-action-key="publishEdit"]');
|
||||
assert.ok(publishEditButton);
|
||||
@@ -418,7 +431,28 @@ limitations under the License.
|
||||
fireActionStub.calledWith('/edit:publish', publishEditAction, false));
|
||||
});
|
||||
|
||||
test('hide publishEdit if change is not open', () => {
|
||||
test('show rebase edit but publishEdit is hidden', () => {
|
||||
element.change = {
|
||||
status: 'NEW',
|
||||
};
|
||||
element.editBasedOnCurrentPatchSet = false;
|
||||
|
||||
const publishEditButton =
|
||||
element.$$('gr-button[data-action-key="publishEdit"]');
|
||||
assert.isNotOk(publishEditButton);
|
||||
|
||||
const rebaseEditButton =
|
||||
element.$$('gr-button[data-action-key="rebaseEdit"]');
|
||||
assert.ok(rebaseEditButton);
|
||||
MockInteractions.tap(rebaseEditButton);
|
||||
element._handleRebaseEditTap();
|
||||
flushAsynchronousOperations();
|
||||
|
||||
assert.isTrue(
|
||||
fireActionStub.calledWith('/edit:rebase', rebaseEditAction, false));
|
||||
});
|
||||
|
||||
test('hide publishEdit and rebaseEdit if change is not open', () => {
|
||||
element.change = {
|
||||
status: 'MERGED',
|
||||
};
|
||||
@@ -428,6 +462,10 @@ limitations under the License.
|
||||
element.$$('gr-button[data-action-key="publishEdit"]');
|
||||
assert.isNotOk(publishEditButton);
|
||||
|
||||
const rebaseEditButton =
|
||||
element.$$('gr-button[data-action-key="rebaseEdit"]');
|
||||
assert.isNotOk(rebaseEditButton);
|
||||
|
||||
const deleteEditButton =
|
||||
element.$$('gr-button[data-action-key="deleteEdit"]');
|
||||
assert.ok(deleteEditButton);
|
||||
|
||||
@@ -352,6 +352,7 @@ limitations under the License.
|
||||
patch-num="[[computeLatestPatchNum(_allPatchSets)]]"
|
||||
commit-message="[[_latestCommitMessage]]"
|
||||
edit-loaded="[[_editLoaded]]"
|
||||
edit-based-on-current-patch-set="[[hasEditBasedOnCurrentPatchSet(_allPatchSets)]]"
|
||||
on-reload-change="_handleReloadChange"
|
||||
on-download-tap="_handleOpenDownloadDialog"></gr-change-actions>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user