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:
@@ -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) {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user