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:
Maxime Guerreiro
2018-04-03 14:47:01 +00:00
parent 78982fd60c
commit ba1d50563d
3 changed files with 13 additions and 14 deletions

View File

@@ -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.

View File

@@ -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']);
}); });

View File

@@ -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,
}; };