summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2015-10-05 08:04:34 -0400
committerJames Moger <james.moger@gitblit.com>2015-10-05 08:04:34 -0400
commit1c261bd5fbe8f4750f17678f85f98cf101439b71 (patch)
treeadbe29cd5d87f7824b8bfc10a604ce200dbe99fd
parent92ae83de6b4f5401a1007bbb26e2f01168e9d6cb (diff)
parent548b29e87dedac76bad2011cda4e39a9f3d72a21 (diff)
downloadgitblit-1c261bd5fbe8f4750f17678f85f98cf101439b71.tar.gz
gitblit-1c261bd5fbe8f4750f17678f85f98cf101439b71.zip
Merge branch 'topic/pr-935' into develop
-rw-r--r--src/main/java/com/gitblit/wicket/GitBlitWebApp.properties3
-rw-r--r--src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.html1
-rw-r--r--src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java34
3 files changed, 26 insertions, 12 deletions
diff --git a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
index d0374200..d8027548 100644
--- a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
+++ b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
@@ -763,4 +763,5 @@ gb.imgdiffSubtract = Subtract (black = identical)
gb.deleteRepositoryHeader = Delete Repository
gb.deleteRepositoryDescription = Deleted repositories will be unrecoverable.
gb.show_whitespace = show whitespace
-gb.ignore_whitespace = ignore whitespace \ No newline at end of file
+gb.ignore_whitespace = ignore whitespace
+gb.allRepositories = All Repositories \ No newline at end of file
diff --git a/src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.html b/src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.html
index 91a6ef43..d62b7b22 100644
--- a/src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.html
+++ b/src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.html
@@ -24,6 +24,7 @@
<div class="span3">
<h3><wicket:message key="gb.repositories"></wicket:message></h3>
<select wicket:id="repositories" ></select>
+ <label><input type="checkbox" wicket:id="allrepos" /> <span><wicket:message key="gb.allRepositories"></wicket:message></span></label>
</div>
<div class="span9" style="margin-left:10px">
<div>
diff --git a/src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java b/src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java
index 4d4545a5..b2fd9037 100644
--- a/src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java
@@ -17,11 +17,14 @@ package com.gitblit.wicket.pages;
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Set;
import org.apache.wicket.Component;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.markup.html.form.ListMultipleChoice;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.Fragment;
@@ -66,6 +69,15 @@ public class LuceneSearchPage extends RootPage {
int page = 1;
int pageSize = app().settings().getInteger(Keys.web.itemsPerPage, 50);
+ // display user-accessible selections
+ UserModel user = GitBlitWebSession.get().getUser();
+ List<String> availableRepositories = new ArrayList<String>();
+ for (RepositoryModel model : app().repositories().getRepositoryModels(user)) {
+ if (model.hasCommits && !ArrayUtils.isEmpty(model.indexedBranches)) {
+ availableRepositories.add(model.name);
+ }
+ }
+
if (params != null) {
String repository = WicketUtils.getRepositoryName(params);
if (!StringUtils.isEmpty(repository)) {
@@ -79,6 +91,10 @@ public class LuceneSearchPage extends RootPage {
List<String> list = StringUtils.getStringsFromValue(value);
repositories.addAll(list);
}
+
+ if (params.containsKey("allrepos")) {
+ repositories.addAll(availableRepositories);
+ }
if (params.containsKey("query")) {
query = params.getString("query", "");
@@ -96,14 +112,6 @@ public class LuceneSearchPage extends RootPage {
}
}
- // display user-accessible selections
- UserModel user = GitBlitWebSession.get().getUser();
- List<String> availableRepositories = new ArrayList<String>();
- for (RepositoryModel model : app().repositories().getRepositoryModels(user)) {
- if (model.hasCommits && !ArrayUtils.isEmpty(model.indexedBranches)) {
- availableRepositories.add(model.name);
- }
- }
boolean luceneEnabled = app().settings().getBoolean(Keys.web.allowLuceneIndexing, true);
if (luceneEnabled) {
if (availableRepositories.size() == 0) {
@@ -114,16 +122,18 @@ public class LuceneSearchPage extends RootPage {
}
// enforce user-accessible repository selections
- ArrayList<String> searchRepositories = new ArrayList<String>();
+ Set<String> uniqueRepositories = new LinkedHashSet<String>();
for (String selectedRepository : repositories) {
if (availableRepositories.contains(selectedRepository)) {
- searchRepositories.add(selectedRepository);
+ uniqueRepositories.add(selectedRepository);
}
}
+ ArrayList<String> searchRepositories = new ArrayList<String>(uniqueRepositories);
// search form
final Model<String> queryModel = new Model<String>(query);
final Model<ArrayList<String>> repositoriesModel = new Model<ArrayList<String>>(searchRepositories);
+ final Model<Boolean> allreposModel = new Model<Boolean>(params != null && params.containsKey("allrepos"));
SessionlessForm<Void> form = new SessionlessForm<Void>("searchForm", getClass()) {
private static final long serialVersionUID = 1L;
@@ -135,13 +145,14 @@ public class LuceneSearchPage extends RootPage {
error(getString("gb.undefinedQueryWarning"));
return;
}
- if (repositoriesModel.getObject().size() == 0) {
+ if (repositoriesModel.getObject().size() == 0 && !allreposModel.getObject()) {
error(getString("gb.noSelectedRepositoriesWarning"));
return;
}
PageParameters params = new PageParameters();
params.put("repositories", StringUtils.flattenStrings(repositoriesModel.getObject()));
params.put("query", queryModel.getObject());
+ params.put("allrepos", allreposModel.getObject());
LuceneSearchPage page = new LuceneSearchPage(params);
setResponsePage(page);
}
@@ -152,6 +163,7 @@ public class LuceneSearchPage extends RootPage {
selections.setMaxRows(8);
form.add(selections.setEnabled(luceneEnabled));
form.add(new TextField<String>("query", queryModel).setEnabled(luceneEnabled));
+ form.add(new CheckBox("allrepos", allreposModel));
add(form.setEnabled(luceneEnabled));
// execute search