Allow UiCommands to appear in more than one place
Some commands might want to list themselves in multiple contexts. Support this by asking them to return a set describing where they can be positioned. Change-Id: I401e032f3a574f6c485abb1c1dd5bfa7d792f2ab
This commit is contained in:
parent
cfbd2e9982
commit
2bcfc66424
@ -17,12 +17,14 @@ package com.google.gerrit.extensions.webui;
|
||||
import com.google.gerrit.extensions.restapi.RestResource;
|
||||
import com.google.gerrit.extensions.restapi.RestView;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface UiCommand<R extends RestResource> extends RestView<R> {
|
||||
public static enum Place {
|
||||
PATCHSET_ACTION_PANEL;
|
||||
};
|
||||
|
||||
Place getPlace();
|
||||
Set<Place> getPlaces();
|
||||
String getLabel(R resource);
|
||||
String getTitle(R resource);
|
||||
boolean isVisible(R resource);
|
||||
|
@ -19,6 +19,7 @@ import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gerrit.common.data.UiCommandDetail;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.extensions.restapi.ChildCollection;
|
||||
@ -99,7 +100,8 @@ public class UiCommands {
|
||||
}
|
||||
|
||||
UiCommand<R> cmd = (UiCommand<R>) view;
|
||||
if (!places.contains(cmd.getPlace()) || !cmd.isVisible(resource)) {
|
||||
if (Sets.intersection(cmd.getPlaces(), places).isEmpty()
|
||||
|| !cmd.isVisible(resource)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user