SubmittedTogether: Only show tab if there is more than one change

If the tab contains only the current change, the tab feels pointless
and a waste of screen estate. In that case we don't want to display the
tab. To do so we choose to modify the REST API for the /submitted_together
call, because this keeps the client side code from growing exceptions
around the REST API calls.

Change-Id: If1943f93f5f5f9bc2dd1e2135e7ab4406e91262e
This commit is contained in:
Stefan Beller
2015-07-20 14:10:41 -07:00
committed by Shawn Pearce
parent 0cc78d1134
commit 460f354392
3 changed files with 59 additions and 13 deletions

View File

@@ -32,6 +32,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
@@ -60,12 +61,16 @@ public class SubmittedTogether implements RestReadView<ChangeResource> {
try {
ChangeSet cs = mergeSuperSet.completeChangeSet(dbProvider.get(),
ChangeSet.create(resource.getChange()));
return json.create(EnumSet.of(
ListChangesOption.CURRENT_REVISION,
ListChangesOption.CURRENT_COMMIT,
ListChangesOption.DETAILED_LABELS,
ListChangesOption.LABELS))
.format(cs.ids());
if (cs.ids().size() > 1) {
return json.create(EnumSet.of(
ListChangesOption.CURRENT_REVISION,
ListChangesOption.CURRENT_COMMIT,
ListChangesOption.DETAILED_LABELS,
ListChangesOption.LABELS))
.format(cs.ids());
} else {
return Collections.emptyList();
}
} catch (OrmException | IOException e) {
log.error("Error on getting a ChangeSet", e);
throw e;