Make revision contribute to change status computation
Current code erroneously ignores revision status for change status computation and renders NEW (no status) for draft revision. Fix it and render "(Draft)" for draft revisions. Test Plan: 1. Upload a change, note that first patch set is not a draft 2. Upload a draft patch set 3. Open the change in PolyGerrit 4. Confirm that the "(Draft)" suffix appears in the change header 5. Switch to previous patch set (normal patch set) 6. Confirm that there is no "(Draft)" suffix for this patch set Change-Id: If2b5cb1555ed018eba026c6d689a2b3aca498130
This commit is contained in:
@@ -235,7 +235,7 @@ limitations under the License.
|
||||
<gr-change-star change="{{_change}}" hidden$="[[!_loggedIn]]"></gr-change-star>
|
||||
<a href$="[[_computeChangePermalink(_change._number)]]">[[_change._number]]</a><span>:</span>
|
||||
<span>[[_change.subject]]</span>
|
||||
<span class="changeStatus">[[_computeChangeStatus(_change.status)]]</span>
|
||||
<span class="changeStatus">[[_computeChangeStatus(_change, _patchNum)]]</span>
|
||||
</span>
|
||||
<span class="header-actions">
|
||||
<gr-reply-dropdown id="replyDropdown"
|
||||
@@ -548,9 +548,13 @@ limitations under the License.
|
||||
return '/' + changeNum;
|
||||
},
|
||||
|
||||
_computeChangeStatus: function(status) {
|
||||
_computeChangeStatus: function(change, patchNum) {
|
||||
var status = change.status;
|
||||
if (status == this.ChangeStatus.NEW) {
|
||||
return '';
|
||||
var rev = this._getRevisionNumber(change, patchNum);
|
||||
// TODO(davido): Figure out, why sometimes revision is not there
|
||||
if (rev == undefined || !rev.draft) { return ''; }
|
||||
status = this.ChangeStatus.DRAFT;
|
||||
}
|
||||
return '(' + status.toLowerCase() + ')';
|
||||
},
|
||||
@@ -594,6 +598,14 @@ limitations under the License.
|
||||
});
|
||||
},
|
||||
|
||||
_getRevisionNumber: function(change, patchNum) {
|
||||
for (var rev in change.revisions) {
|
||||
if (change.revisions[rev]._number == patchNum) {
|
||||
return change.revisions[rev];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_computePatchIndexIsSelected: function(index, patchNum) {
|
||||
return this._allPatchSets[index] == patchNum;
|
||||
},
|
||||
|
||||
@@ -123,5 +123,57 @@ limitations under the License.
|
||||
selectEl.value = '1';
|
||||
element.fire('change', {}, {node: selectEl});
|
||||
});
|
||||
|
||||
test('change status new', function() {
|
||||
element._changeNum = '1';
|
||||
element._patchNum = 1;
|
||||
element._change = {
|
||||
change_id: 'Iad9dc96274af6946f3632be53b106ef80f7ba6ca',
|
||||
revisions: {
|
||||
rev1: {_number: 1},
|
||||
},
|
||||
current_revision: 'rev1',
|
||||
status: 'NEW',
|
||||
labels: {},
|
||||
};
|
||||
var status = element._computeChangeStatus(element._change, '1');
|
||||
assert.equal(status, '');
|
||||
});
|
||||
|
||||
test('change status draft', function() {
|
||||
element._changeNum = '1';
|
||||
element._patchNum = 1;
|
||||
element._change = {
|
||||
change_id: 'Iad9dc96274af6946f3632be53b106ef80f7ba6ca',
|
||||
revisions: {
|
||||
rev1: {_number: 1},
|
||||
},
|
||||
current_revision: 'rev1',
|
||||
status: 'DRAFT',
|
||||
labels: {},
|
||||
};
|
||||
var status = element._computeChangeStatus(element._change, '1');
|
||||
assert.equal(status, '(draft)');
|
||||
});
|
||||
|
||||
test('revision status draft', function() {
|
||||
element._changeNum = '1';
|
||||
element._patchNum = 2;
|
||||
element._change = {
|
||||
change_id: 'Iad9dc96274af6946f3632be53b106ef80f7ba6ca',
|
||||
revisions: {
|
||||
rev1: {_number: 1},
|
||||
rev2: {
|
||||
_number: 2,
|
||||
draft: true,
|
||||
},
|
||||
},
|
||||
current_revision: 'rev1',
|
||||
status: 'NEW',
|
||||
labels: {},
|
||||
};
|
||||
var status = element._computeChangeStatus(element._change, '2');
|
||||
assert.equal(status, '(draft)');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user