Related Changes: Add status of each related change to REST API

Since some recent refactoring the output for the related changes is
slightly broken. The black dot next to a change entry in the related tab
doesn't show up any more.

The occurrence of the black dot is calculated on the client side using
the existance of the change and revision id number. This is fragile,
so we want to have a more robust way of determining the if to show the
black dot. This change includes the state of each related change in the
REST API, such that in a later commit we can use the state instead of
indirect fragile measures for displaying the state of each related change.

As the json object sent over the wire will be parsed as a ChangeInfo
object, we need to name the status "status" and not "_status" or otherwise
different.

Change-Id: I5e593d0c563ddce914c036eaed6c6466b2805012
This commit is contained in:
Stefan Beller 2015-06-17 09:46:36 -07:00
parent cc26ed70c4
commit 3e8bd6e30d
3 changed files with 9 additions and 1 deletions

View File

@ -2219,6 +2219,7 @@ describing the related changes.
"_change_number": 58478, "_change_number": 58478,
"_revision_number": 2, "_revision_number": 2,
"_current_revision_number": 2 "_current_revision_number": 2
"status": "NEW"
}, },
{ {
"change_id": "I5e4fc08ce34d33c090c9e0bf320de1b17309f774", "change_id": "I5e4fc08ce34d33c090c9e0bf320de1b17309f774",
@ -2240,6 +2241,7 @@ describing the related changes.
"_change_number": 58081, "_change_number": 58081,
"_revision_number": 10, "_revision_number": 10,
"_current_revision_number": 10 "_current_revision_number": 10
"status": "NEW"
} }
] ]
} }
@ -4065,6 +4067,8 @@ link:#commit-info[CommitInfo] entity.
|`_change_number` |optional|The change number. |`_change_number` |optional|The change number.
|`_revision_number` |optional|The revision number. |`_revision_number` |optional|The revision number.
|`_current_revision_number`|optional|The current revision number. |`_current_revision_number`|optional|The current revision number.
|`status` |optional|The status of the change. The status of
the change is one of (`NEW`, `SUBMITTED`, `MERGED`, `ABANDONED`, `DRAFT`).
|=========================== |===========================
[[related-changes-info]] [[related-changes-info]]

View File

@ -252,7 +252,7 @@ public class GetRelatedIT extends AbstractDaemonTest {
indexer.index(changeDataFactory.create(db, psId1_1.getParentKey())); indexer.index(changeDataFactory.create(db, psId1_1.getParentKey()));
if (!cfg.getBoolean("change", null, "getRelatedByAncestors", false)) { if (!cfg.getBoolean("change", null, "getRelatedByAncestors", false)) {
// PS1,1 has no groups, so disappeared from related chanegs. // PS1,1 has no groups, so disappeared from related changes.
assertRelated(psId2_1); assertRelated(psId2_1);
} }
@ -306,6 +306,7 @@ public class GetRelatedIT extends AbstractDaemonTest {
result.commit.commit = commitId.name(); result.commit.commit = commitId.name();
result._revisionNumber = revisionNum; result._revisionNumber = revisionNum;
result._currentRevisionNumber = currentRevisionNum; result._currentRevisionNumber = currentRevisionNum;
result.status = "NEW";
return result; return result;
} }

View File

@ -191,6 +191,7 @@ public class GetRelated implements RestReadView<RevisionResource> {
public Integer _changeNumber; public Integer _changeNumber;
public Integer _revisionNumber; public Integer _revisionNumber;
public Integer _currentRevisionNumber; public Integer _currentRevisionNumber;
public String status;
public ChangeAndCommit() { public ChangeAndCommit() {
} }
@ -202,6 +203,7 @@ public class GetRelated implements RestReadView<RevisionResource> {
_revisionNumber = ps != null ? ps.getPatchSetId() : null; _revisionNumber = ps != null ? ps.getPatchSetId() : null;
PatchSet.Id curr = change.currentPatchSetId(); PatchSet.Id curr = change.currentPatchSetId();
_currentRevisionNumber = curr != null ? curr.get() : null; _currentRevisionNumber = curr != null ? curr.get() : null;
status = change.getStatus().asChangeStatus().toString();
} }
commit = new CommitInfo(); commit = new CommitInfo();
@ -224,6 +226,7 @@ public class GetRelated implements RestReadView<RevisionResource> {
.add("_changeNumber", _changeNumber) .add("_changeNumber", _changeNumber)
.add("_revisionNumber", _revisionNumber) .add("_revisionNumber", _revisionNumber)
.add("_currentRevisionNumber", _currentRevisionNumber) .add("_currentRevisionNumber", _currentRevisionNumber)
.add("status", status)
.toString(); .toString();
} }