Make PolyGerrit use Change's submittable field
Use the server provided value to determine if a change can be submitted. This way, PolyGerrit does not rely on Labels, and respects the decision taken by the server (which might be influenced by plugins). Change-Id: Ic43cf3504d93aaebd689d64e7c97989d15221d73
This commit is contained in:
@@ -151,7 +151,7 @@ limitations under the License.
|
|||||||
if (states.length || !opt_options) { return states; }
|
if (states.length || !opt_options) { return states; }
|
||||||
|
|
||||||
// If no missing requirements, either active or ready to submit.
|
// If no missing requirements, either active or ready to submit.
|
||||||
if (opt_options.readyToSubmit) {
|
if (change.submittable) {
|
||||||
states.push('Ready to submit');
|
states.push('Ready to submit');
|
||||||
} else {
|
} else {
|
||||||
// Otherwise it is active.
|
// Otherwise it is active.
|
||||||
|
@@ -93,28 +93,33 @@ limitations under the License.
|
|||||||
assert.deepEqual(statuses, []);
|
assert.deepEqual(statuses, []);
|
||||||
assert.equal(statusString, '');
|
assert.equal(statusString, '');
|
||||||
|
|
||||||
|
change.submittable = false;
|
||||||
statuses = element.changeStatuses(change,
|
statuses = element.changeStatuses(change,
|
||||||
{readyToSubmit: false, includeDerived: true});
|
{includeDerived: true});
|
||||||
assert.deepEqual(statuses, ['Active']);
|
assert.deepEqual(statuses, ['Active']);
|
||||||
|
|
||||||
// With no missing labels
|
// With no missing labels
|
||||||
|
change.submittable = true;
|
||||||
statuses = element.changeStatuses(change,
|
statuses = element.changeStatuses(change,
|
||||||
{readyToSubmit: true, includeDerived: true});
|
{includeDerived: true});
|
||||||
statusString = element.changeStatusString(change);
|
statusString = element.changeStatusString(change);
|
||||||
assert.deepEqual(statuses, ['Ready to submit']);
|
assert.deepEqual(statuses, ['Ready to submit']);
|
||||||
|
|
||||||
change.mergeable = false;
|
change.mergeable = false;
|
||||||
|
change.submittable = true;
|
||||||
statuses = element.changeStatuses(change,
|
statuses = element.changeStatuses(change,
|
||||||
{readyToSubmit: true, includeDerived: true});
|
{includeDerived: true});
|
||||||
assert.deepEqual(statuses, ['Merge Conflict']);
|
assert.deepEqual(statuses, ['Merge Conflict']);
|
||||||
|
|
||||||
delete change.mergeable;
|
delete change.mergeable;
|
||||||
|
change.submittable = true;
|
||||||
statuses = element.changeStatuses(change,
|
statuses = element.changeStatuses(change,
|
||||||
{readyToSubmit: true, includeDerived: true, mergeable: true});
|
{includeDerived: true, mergeable: true});
|
||||||
assert.deepEqual(statuses, ['Ready to submit']);
|
assert.deepEqual(statuses, ['Ready to submit']);
|
||||||
|
|
||||||
|
change.submittable = true;
|
||||||
statuses = element.changeStatuses(change,
|
statuses = element.changeStatuses(change,
|
||||||
{readyToSubmit: true, includeDerived: true, mergeable: false});
|
{includeDerived: true, mergeable: false});
|
||||||
assert.deepEqual(statuses, ['Merge Conflict']);
|
assert.deepEqual(statuses, ['Merge Conflict']);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -203,8 +203,7 @@
|
|||||||
},
|
},
|
||||||
_changeStatuses: {
|
_changeStatuses: {
|
||||||
type: String,
|
type: String,
|
||||||
computed: '_computeChangeStatusChips(_change, _missingLabels, ' +
|
computed: '_computeChangeStatusChips(_change, _mergeable)',
|
||||||
'_mergeable)',
|
|
||||||
},
|
},
|
||||||
_commitCollapsed: {
|
_commitCollapsed: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -396,16 +395,11 @@
|
|||||||
return missingLabels;
|
return missingLabels;
|
||||||
},
|
},
|
||||||
|
|
||||||
_readyToSubmit(missingLabels) {
|
_computeChangeStatusChips(change, mergeable) {
|
||||||
return missingLabels.length === 0;
|
|
||||||
},
|
|
||||||
|
|
||||||
_computeChangeStatusChips(change, missingLabels, mergeable) {
|
|
||||||
// Show no chips until mergeability is loaded.
|
// Show no chips until mergeability is loaded.
|
||||||
if (mergeable === null || mergeable === undefined) { return []; }
|
if (mergeable === null || mergeable === undefined) { return []; }
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
readyToSubmit: this._readyToSubmit(missingLabels),
|
|
||||||
includeDerived: true,
|
includeDerived: true,
|
||||||
mergeable: !!mergeable,
|
mergeable: !!mergeable,
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user