ChangeScreen2: Display 'No Related Changes' if there are none

Instead of returning ourselves as the only result from /related
return an empty list. This is more clear to the caller that there
are no related changes for the searched for change.

In the web UI display a message making it clear there are no
related changes.

Change-Id: Icccd2fbb9d6b21965e699060228a108a83b22838
This commit is contained in:
Shawn Pearce
2013-07-22 15:47:45 -07:00
parent d5c8a351eb
commit d4610d8536
3 changed files with 26 additions and 7 deletions

View File

@@ -97,6 +97,7 @@ class RelatedChanges extends Composite {
@UiField Style style;
@UiField Element header;
@UiField Element none;
@UiField ScrollPanel scroll;
@UiField ProgressBar progress;
@UiField Element error;
@@ -144,11 +145,17 @@ class RelatedChanges extends Composite {
}
}
private void render(String revision, JsArray<ChangeAndCommit> graph) {
DisplayCommand cmd = new DisplayCommand(revision, graph);
private void render(String revision, JsArray<ChangeAndCommit> list) {
if (0 < list.length()) {
DisplayCommand cmd = new DisplayCommand(revision, list);
if (cmd.execute()) {
Scheduler.get().scheduleIncremental(cmd);
}
} else {
progress.setVisible(false);
UIObject.setVisible(header, false);
UIObject.setVisible(none, true);
}
}
private void setTable(MyTable t) {

View File

@@ -37,5 +37,8 @@ limitations under the License.
<g:ScrollPanel ui:field='scroll' visible='false'/>
<x:ProgressBar ui:field='progress'/>
<div ui:field='error' aria-hidden='true' style='display: NONE'/>
<div ui:field='none' aria-hidden='true' style='display: NONE'>
<ui:msg>No Related Changes</ui:msg>
</div>
</g:HTMLPanel>
</ui:UiBinder>

View File

@@ -93,7 +93,7 @@ public class GetRelated implements RestReadView<RevisionResource> {
throws OrmException, IOException {
Map<Change.Id, Change> changes = allOpenChanges(rsrc);
Map<PatchSet.Id, PatchSet> patchSets = allPatchSets(changes.keySet());
List<ChangeAndCommit> graph = children(rsrc, rw, changes, patchSets);
List<ChangeAndCommit> list = children(rsrc, rw, changes, patchSets);
Map<String, PatchSet> commits = Maps.newHashMap();
for (PatchSet p : patchSets.values()) {
@@ -116,9 +116,18 @@ public class GetRelated implements RestReadView<RevisionResource> {
for (RevCommit c; (c = rw.next()) != null;) {
PatchSet p = commits.get(c.name());
Change g = p != null ? changes.get(p.getId().getParentKey()) : null;
graph.add(new ChangeAndCommit(g, p, c));
list.add(new ChangeAndCommit(g, p, c));
}
return graph;
if (list.size() == 1) {
ChangeAndCommit r = list.get(0);
if (r._changeNumber != null && r._revisionNumber != null
&& r._changeNumber == rsrc.getChange().getChangeId()
&& r._revisionNumber == rsrc.getPatchSet().getPatchSetId()) {
return Collections.emptyList();
}
}
return list;
}
private Map<Change.Id, Change> allOpenChanges(RevisionResource rsrc)