Merge "Merge doc and change searches."
This commit is contained in:
@@ -118,6 +118,7 @@ public class Gerrit implements EntryPoint {
|
||||
private static AccountPreferencesInfo myPrefs;
|
||||
private static UrlAliasMatcher urlAliasMatcher;
|
||||
private static boolean hasDocumentation;
|
||||
private static boolean docSearch;
|
||||
private static String docUrl;
|
||||
private static HostPageData.Theme myTheme;
|
||||
private static String defaultScreenToken;
|
||||
@@ -487,6 +488,7 @@ public class Gerrit implements EntryPoint {
|
||||
hasDocumentation = true;
|
||||
docUrl = du;
|
||||
}
|
||||
docSearch = info.gerrit().docSearch();
|
||||
}
|
||||
}));
|
||||
HostPageDataService hpd = GWT.create(HostPageDataService.class);
|
||||
@@ -918,6 +920,10 @@ public class Gerrit implements EntryPoint {
|
||||
urlAliasMatcher.updateUserAliases(myPrefs.urlAliases());
|
||||
}
|
||||
|
||||
public static boolean hasDocSearch() {
|
||||
return docSearch;
|
||||
}
|
||||
|
||||
private static void getDocIndex(final AsyncCallback<DocInfo> cb) {
|
||||
RequestBuilder req =
|
||||
new RequestBuilder(RequestBuilder.HEAD, GWT.getHostPageBaseURL()
|
||||
|
||||
@@ -126,4 +126,7 @@ public interface GerritConstants extends Constants {
|
||||
String stringListPanelDelete();
|
||||
String stringListPanelUp();
|
||||
String stringListPanelDown();
|
||||
|
||||
String searchDropdownChanges();
|
||||
String searchDropdownDoc();
|
||||
}
|
||||
|
||||
@@ -109,3 +109,6 @@ stringListPanelAdd = Add
|
||||
stringListPanelDelete = Delete
|
||||
stringListPanelUp = Up
|
||||
stringListPanelDown = Down
|
||||
|
||||
searchDropdownChanges = Changes
|
||||
searchDropdownDoc = Documentation
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.google.gwt.event.shared.HandlerRegistration;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.ListBox;
|
||||
import com.google.gwt.user.client.ui.SuggestBox;
|
||||
import com.google.gwt.user.client.ui.SuggestOracle.Suggestion;
|
||||
import com.google.gwtexpui.globalkey.client.GlobalKey;
|
||||
@@ -34,6 +35,7 @@ import com.google.gwtexpui.globalkey.client.KeyCommand;
|
||||
|
||||
class SearchPanel extends Composite {
|
||||
private final HintTextBox searchBox;
|
||||
private final ListBox dropdown;
|
||||
private HandlerRegistration regFocus;
|
||||
|
||||
SearchPanel() {
|
||||
@@ -54,6 +56,18 @@ class SearchPanel extends Composite {
|
||||
}
|
||||
});
|
||||
|
||||
if (Gerrit.hasDocSearch()) {
|
||||
dropdown = new ListBox();
|
||||
dropdown.setStyleName("searchDropdown");
|
||||
dropdown.addItem(Gerrit.C.searchDropdownChanges());
|
||||
dropdown.addItem(Gerrit.C.searchDropdownDoc());
|
||||
dropdown.setVisibleItemCount(1);
|
||||
dropdown.setSelectedIndex(0);
|
||||
} else {
|
||||
// Doc search is NOT available.
|
||||
dropdown = null;
|
||||
}
|
||||
|
||||
final SuggestBox suggestBox =
|
||||
new SuggestBox(new SearchSuggestOracle(), searchBox, suggestionDisplay);
|
||||
searchBox.setStyleName("searchTextBox");
|
||||
@@ -70,6 +84,9 @@ class SearchPanel extends Composite {
|
||||
});
|
||||
|
||||
body.add(suggestBox);
|
||||
if (dropdown != null) {
|
||||
body.add(dropdown);
|
||||
}
|
||||
body.add(searchButton);
|
||||
}
|
||||
|
||||
@@ -110,14 +127,23 @@ class SearchPanel extends Composite {
|
||||
|
||||
searchBox.setFocus(false);
|
||||
|
||||
if (query.matches("^[1-9][0-9]*$")) {
|
||||
Gerrit.display(PageLinks.toChange(Change.Id.parse(query)));
|
||||
if (dropdown != null
|
||||
&& dropdown.getSelectedValue().equals(Gerrit.C.searchDropdownDoc())) {
|
||||
// doc
|
||||
Gerrit.display(PageLinks.toDocumentationQuery(query));
|
||||
} else {
|
||||
Gerrit.display(PageLinks.toChangeQuery(query), QueryScreen.forQuery(query));
|
||||
// changes
|
||||
if (query.matches("^[1-9][0-9]*$")) {
|
||||
Gerrit.display(PageLinks.toChange(Change.Id.parse(query)));
|
||||
} else {
|
||||
Gerrit.display(
|
||||
PageLinks.toChangeQuery(query), QueryScreen.forQuery(query));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class MySuggestionDisplay extends SuggestBox.DefaultSuggestionDisplay {
|
||||
private static class MySuggestionDisplay
|
||||
extends SuggestBox.DefaultSuggestionDisplay {
|
||||
private boolean isSuggestionSelected;
|
||||
|
||||
private MySuggestionDisplay() {
|
||||
|
||||
@@ -307,7 +307,15 @@ a:hover {
|
||||
}
|
||||
.searchPanel .searchTextBox {
|
||||
font-size: 9pt;
|
||||
margin: 5.286px 3px 0 0;
|
||||
margin: 8.286px 3px 0 0;
|
||||
}
|
||||
.searchPanel .searchDropdown {
|
||||
font-size: 8pt;
|
||||
border: 2px solid;
|
||||
border-color: rgba(0, 0, 0, 0.15);
|
||||
height: 16px;
|
||||
border-radius: 2px;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
.searchPanel .searchButton {
|
||||
text-align: center;
|
||||
|
||||
Reference in New Issue
Block a user