Change rebase action behavior
Previously, if the server did not return enabled=true for the rebase change action, the rebase button would be disabled on the UI. Really, what disabled indicated in this case was that the rebase could not be performed on the current branch, but could still perform a rebase on a different parent revision. This change updates revision actions in the change view always be enabled, and introduces a new parameter to indicate whether or not rebasing should be enabled on the current branch based on the initial status of the enabled flag. This change also disables the rebase button on the rebase dialog until an option is explicitly chosen. Previously, if an option was not chosen, if rebase was clicked, it would submit with a base branch of '', which is the same thing checking the box accomplishes. Now, either the box must be checked, or a base change must be entered, so it is more clear what happens with the rebase and in the new scenario when you cannot submit on the base branch, there won't be a possibility of a server error. Bug: Issue 5126 Change-Id: I47083ad328095aad4e04f2fc1586ad4d34412e4c
This commit is contained in:
@@ -267,6 +267,7 @@ limitations under the License.
|
||||
<gr-change-actions id="actions"
|
||||
change="[[_change]]"
|
||||
actions="[[_change.actions]]"
|
||||
rebase-on-current="[[_rebaseOnCurrent]]"
|
||||
revision-actions="[[_currentRevisionActions]]"
|
||||
change-num="[[_changeNum]]"
|
||||
change-status="[[_change.status]]"
|
||||
|
||||
@@ -96,6 +96,7 @@
|
||||
},
|
||||
_loading: Boolean,
|
||||
_projectConfig: Object,
|
||||
_rebaseOnCurrent: Boolean,
|
||||
_replyButtonLabel: {
|
||||
type: String,
|
||||
value: 'Reply',
|
||||
@@ -710,6 +711,14 @@
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
_updateRebaseAction: function(revisionActions) {
|
||||
if (revisionActions && revisionActions.rebase){
|
||||
this._rebaseOnCurrent = !!revisionActions.rebase.enabled;
|
||||
revisionActions.rebase.enabled = true;
|
||||
}
|
||||
return revisionActions;
|
||||
},
|
||||
|
||||
_getChangeDetail: function() {
|
||||
return this.$.restAPI.getChangeDetail(this._changeNum,
|
||||
this._handleGetChangeDetailError.bind(this)).then(
|
||||
@@ -735,7 +744,8 @@
|
||||
currentRevision.commit.commit = latestRevisionSha;
|
||||
}
|
||||
this._commitInfo = currentRevision.commit;
|
||||
this._currentRevisionActions = currentRevision.actions;
|
||||
this._currentRevisionActions =
|
||||
this._updateRebaseAction(currentRevision.actions);
|
||||
// TODO: Fetch and process files.
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
@@ -180,6 +180,41 @@ limitations under the License.
|
||||
assert.equal(putDescStub.args[0][2], 'test2');
|
||||
});
|
||||
|
||||
test('_updateRebaseAction', function(){
|
||||
var currentRevisionActions = {
|
||||
cherrypick: {
|
||||
enabled: true,
|
||||
label: 'Cherry Pick',
|
||||
method: 'POST',
|
||||
title: 'cherrypick'
|
||||
},
|
||||
rebase: {
|
||||
enabled: true,
|
||||
label: 'Rebase',
|
||||
method: 'POST',
|
||||
title: 'Rebase onto tip of branch or parent change'
|
||||
},
|
||||
};
|
||||
|
||||
// Rebase enabled should always end up true.
|
||||
// When rebase is enabled initially, rebaseOnCurrent should be set to
|
||||
// true.
|
||||
assert.equal(element._updateRebaseAction(currentRevisionActions),
|
||||
currentRevisionActions);
|
||||
|
||||
assert.isTrue(element._rebaseOnCurrent);
|
||||
|
||||
var newRevisionActions = currentRevisionActions
|
||||
delete newRevisionActions.rebase.enabled;
|
||||
|
||||
// When rebase is not enabled initially, rebaseOnCurrent should be set to
|
||||
// false.
|
||||
assert.equal(element._updateRebaseAction(newRevisionActions),
|
||||
currentRevisionActions);
|
||||
|
||||
assert.isFalse(element._rebaseOnCurrent);
|
||||
});
|
||||
|
||||
test('_reload is called when an approved label is removed', function() {
|
||||
var vote = {_account_id: 1, name: 'bojack', value: 1};
|
||||
element._changeNum = '42';
|
||||
|
||||
Reference in New Issue
Block a user