summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVitaliy Filippov <vitalif@yourcmc.ru>2015-09-29 13:58:21 +0300
committerVitaliy Filippov <vitalif@yourcmc.ru>2015-10-01 13:10:51 +0300
commitb4d9581961d219f6a8fbfd0e391b39d7e45e8e10 (patch)
tree0bca0c28ffc9c9931b77c1892c42fabdacb48605 /src
parent7be48d8d14c74dfb10ba3d71f12a78505daf29a6 (diff)
downloadgitblit-b4d9581961d219f6a8fbfd0e391b39d7e45e8e10.tar.gz
gitblit-b4d9581961d219f6a8fbfd0e391b39d7e45e8e10.zip
Add "all repositories" parameter
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/gitblit/wicket/GitBlitWebApp.properties1
-rw-r--r--src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.html1
-rw-r--r--src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java27
3 files changed, 20 insertions, 9 deletions
diff --git a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
index d0374200..0c6bb1e0 100644
--- a/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
+++ b/src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
@@ -48,6 +48,7 @@ gb.password = password
gb.tagger = tagger
gb.moreHistory = more history...
gb.difftocurrent = diff to current
+gb.allrepos = in all repositories
gb.search = search
gb.searchForAuthor = Search for commits authored by
gb.searchForCommitter = Search for commits committed by
diff --git a/src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.html b/src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.html
index 91a6ef43..c8865e85 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.allrepos"></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..ec822318 100644
--- a/src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java
@@ -24,6 +24,7 @@ import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.ListMultipleChoice;
import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
@@ -66,6 +67,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 +89,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 +110,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) {
@@ -124,6 +130,7 @@ public class LuceneSearchPage extends RootPage {
// 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 +142,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 +160,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