Show Merge Conflict status in change view
Bug: Issue 4057 Change-Id: Ic5abbae2b4f261dc4e182e892a74aff288ba3ce4
This commit is contained in:
parent
f51492b337
commit
7bb03b8644
@ -30,10 +30,10 @@ limitations under the License.
|
|||||||
},
|
},
|
||||||
|
|
||||||
ChangeStatus: {
|
ChangeStatus: {
|
||||||
NEW: 'NEW',
|
|
||||||
MERGED: 'MERGED',
|
|
||||||
ABANDONED: 'ABANDONED',
|
ABANDONED: 'ABANDONED',
|
||||||
DRAFT: 'DRAFT',
|
DRAFT: 'DRAFT',
|
||||||
|
MERGED: 'MERGED',
|
||||||
|
NEW: 'NEW',
|
||||||
},
|
},
|
||||||
|
|
||||||
// Must be kept in sync with the ListChangesOption enum and protobuf.
|
// Must be kept in sync with the ListChangesOption enum and protobuf.
|
||||||
@ -108,6 +108,23 @@ limitations under the License.
|
|||||||
return status === this.ChangeStatus.NEW ||
|
return status === this.ChangeStatus.NEW ||
|
||||||
status === this.ChangeStatus.DRAFT;
|
status === this.ChangeStatus.DRAFT;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
changeStatusString: function(change) {
|
||||||
|
// "Closed" states should take precedence over "open" ones.
|
||||||
|
if (change.status === this.ChangeStatus.MERGED) {
|
||||||
|
return 'Merged';
|
||||||
|
}
|
||||||
|
if (change.status === this.ChangeStatus.ABANDONED) {
|
||||||
|
return 'Abandoned';
|
||||||
|
}
|
||||||
|
if (change.mergeable === false) {
|
||||||
|
return 'Merge Conflict';
|
||||||
|
}
|
||||||
|
if (change.status === this.ChangeStatus.DRAFT) {
|
||||||
|
return 'Draft';
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
window.Gerrit = window.Gerrit || {};
|
window.Gerrit = window.Gerrit || {};
|
||||||
|
@ -75,7 +75,7 @@ limitations under the License.
|
|||||||
[[change._number]]
|
[[change._number]]
|
||||||
</a>
|
</a>
|
||||||
<a class="cell subject" href$="[[changeURL]]">[[change.subject]]</a>
|
<a class="cell subject" href$="[[changeURL]]">[[change.subject]]</a>
|
||||||
<span class="cell status">[[_computeChangeStatusString(change)]]</span>
|
<span class="cell status">[[changeStatusString(change)]]</span>
|
||||||
<span class="cell owner">
|
<span class="cell owner">
|
||||||
<gr-account-link account="[[change.owner]]"></gr-account-link>
|
<gr-account-link account="[[change.owner]]"></gr-account-link>
|
||||||
</span>
|
</span>
|
||||||
|
@ -51,25 +51,6 @@
|
|||||||
return '/c/' + changeNum + '/';
|
return '/c/' + changeNum + '/';
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeChangeStatusString: function(change) {
|
|
||||||
// "Closed" states should take precedence over "open" ones.
|
|
||||||
if (change.status == this.ChangeStatus.MERGED) {
|
|
||||||
return 'Merged';
|
|
||||||
}
|
|
||||||
if (change.status == this.ChangeStatus.ABANDONED) {
|
|
||||||
return 'Abandoned';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (change.mergeable != null && change.mergeable == false) {
|
|
||||||
return 'Merge Conflict';
|
|
||||||
}
|
|
||||||
if (change.status == this.ChangeStatus.DRAFT) {
|
|
||||||
return 'Draft';
|
|
||||||
}
|
|
||||||
|
|
||||||
return '';
|
|
||||||
},
|
|
||||||
|
|
||||||
_computeLabelTitle: function(change, labelName) {
|
_computeLabelTitle: function(change, labelName) {
|
||||||
var label = change.labels[labelName];
|
var label = change.labels[labelName];
|
||||||
if (!label) { return 'Label not applicable'; }
|
if (!label) { return 'Label not applicable'; }
|
||||||
|
@ -38,18 +38,21 @@ limitations under the License.
|
|||||||
element = fixture('basic');
|
element = fixture('basic');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('computed fields', function() {
|
test('change status', function() {
|
||||||
assert.equal(element._computeChangeStatusString({mergeable: true}), '');
|
var getStatusForChange = function(change) {
|
||||||
assert.equal(element._computeChangeStatusString({mergeable: false}),
|
element.change = change;
|
||||||
'Merge Conflict');
|
return element.$$('.cell.status').textContent;
|
||||||
assert.equal(element._computeChangeStatusString({status: 'NEW'}), '');
|
};
|
||||||
assert.equal(element._computeChangeStatusString({status: 'MERGED'}),
|
|
||||||
'Merged');
|
|
||||||
assert.equal(element._computeChangeStatusString({status: 'ABANDONED'}),
|
|
||||||
'Abandoned');
|
|
||||||
assert.equal(element._computeChangeStatusString({status: 'DRAFT'}),
|
|
||||||
'Draft');
|
|
||||||
|
|
||||||
|
assert.equal(getStatusForChange({mergeable: true}), '');
|
||||||
|
assert.equal(getStatusForChange({mergeable: false}), 'Merge Conflict');
|
||||||
|
assert.equal(getStatusForChange({status: 'NEW'}), '');
|
||||||
|
assert.equal(getStatusForChange({status: 'MERGED'}), 'Merged');
|
||||||
|
assert.equal(getStatusForChange({status: 'ABANDONED'}), 'Abandoned');
|
||||||
|
assert.equal(getStatusForChange({status: 'DRAFT'}), 'Draft');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('computed fields', function() {
|
||||||
assert.equal(element._computeLabelClass({labels: {}}),
|
assert.equal(element._computeLabelClass({labels: {}}),
|
||||||
'cell label u-gray-background');
|
'cell label u-gray-background');
|
||||||
assert.equal(element._computeLabelClass(
|
assert.equal(element._computeLabelClass(
|
||||||
|
@ -405,15 +405,17 @@
|
|||||||
return '/' + changeNum;
|
return '/' + changeNum;
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeChangeStatus: function(change, patchNum) {
|
_computeChangeStatus: function(change, patchNum) {
|
||||||
var status = change.status;
|
var statusString;
|
||||||
if (status == this.ChangeStatus.NEW) {
|
if (change.status === this.ChangeStatus.NEW) {
|
||||||
var rev = this._getRevisionNumber(change, patchNum);
|
var rev = this._getRevisionNumber(change, patchNum);
|
||||||
// TODO(davido): Figure out, why sometimes revision is not there
|
if (rev && rev.draft === true) {
|
||||||
if (rev == undefined || !rev.draft) { return ''; }
|
statusString = 'Draft';
|
||||||
status = this.ChangeStatus.DRAFT;
|
}
|
||||||
|
} else {
|
||||||
|
statusString = this.changeStatusString(change);
|
||||||
}
|
}
|
||||||
return '(' + status.toLowerCase() + ')';
|
return statusString ? '(' + statusString + ')' : '';
|
||||||
},
|
},
|
||||||
|
|
||||||
_computeLatestPatchNum: function(allPatchSets) {
|
_computeLatestPatchNum: function(allPatchSets) {
|
||||||
|
@ -257,7 +257,7 @@ limitations under the License.
|
|||||||
labels: {},
|
labels: {},
|
||||||
};
|
};
|
||||||
var status = element._computeChangeStatus(element._change, '1');
|
var status = element._computeChangeStatus(element._change, '1');
|
||||||
assert.equal(status, '(draft)');
|
assert.equal(status, '(Draft)');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('revision status draft', function() {
|
test('revision status draft', function() {
|
||||||
@ -280,7 +280,7 @@ limitations under the License.
|
|||||||
labels: {},
|
labels: {},
|
||||||
};
|
};
|
||||||
var status = element._computeChangeStatus(element._change, '2');
|
var status = element._computeChangeStatus(element._change, '2');
|
||||||
assert.equal(status, '(draft)');
|
assert.equal(status, '(Draft)');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('show commit message edit button', function() {
|
test('show commit message edit button', function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user