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 no missing requirements, either active or ready to submit.
if (opt_options.readyToSubmit) {
if (change.submittable) {
states.push('Ready to submit');
} else {
// Otherwise it is active.

View File

@@ -93,28 +93,33 @@ limitations under the License.
assert.deepEqual(statuses, []);
assert.equal(statusString, '');
change.submittable = false;
statuses = element.changeStatuses(change,
{readyToSubmit: false, includeDerived: true});
{includeDerived: true});
assert.deepEqual(statuses, ['Active']);
// With no missing labels
change.submittable = true;
statuses = element.changeStatuses(change,
{readyToSubmit: true, includeDerived: true});
{includeDerived: true});
statusString = element.changeStatusString(change);
assert.deepEqual(statuses, ['Ready to submit']);
change.mergeable = false;
change.submittable = true;
statuses = element.changeStatuses(change,
{readyToSubmit: true, includeDerived: true});
{includeDerived: true});
assert.deepEqual(statuses, ['Merge Conflict']);
delete change.mergeable;
change.submittable = true;
statuses = element.changeStatuses(change,
{readyToSubmit: true, includeDerived: true, mergeable: true});
{includeDerived: true, mergeable: true});
assert.deepEqual(statuses, ['Ready to submit']);
change.submittable = true;
statuses = element.changeStatuses(change,
{readyToSubmit: true, includeDerived: true, mergeable: false});
{includeDerived: true, mergeable: false});
assert.deepEqual(statuses, ['Merge Conflict']);
});

View File

@@ -203,8 +203,7 @@
},
_changeStatuses: {
type: String,
computed: '_computeChangeStatusChips(_change, _missingLabels, ' +
'_mergeable)',
computed: '_computeChangeStatusChips(_change, _mergeable)',
},
_commitCollapsed: {
type: Boolean,
@@ -396,16 +395,11 @@
return missingLabels;
},
_readyToSubmit(missingLabels) {
return missingLabels.length === 0;
},
_computeChangeStatusChips(change, missingLabels, mergeable) {
_computeChangeStatusChips(change, mergeable) {
// Show no chips until mergeability is loaded.
if (mergeable === null || mergeable === undefined) { return []; }
const options = {
readyToSubmit: this._readyToSubmit(missingLabels),
includeDerived: true,
mergeable: !!mergeable,
};