From b4d9581961d219f6a8fbfd0e391b39d7e45e8e10 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Tue, 29 Sep 2015 13:58:21 +0300 Subject: [PATCH] Add "all repositories" parameter --- .../gitblit/wicket/GitBlitWebApp.properties | 1 + .../wicket/pages/LuceneSearchPage.html | 1 + .../wicket/pages/LuceneSearchPage.java | 27 ++++++++++++------- 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 @@

+
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 availableRepositories = new ArrayList(); + 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 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 availableRepositories = new ArrayList(); - 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 queryModel = new Model(query); final Model> repositoriesModel = new Model>(searchRepositories); + final Model allreposModel = new Model(params != null && params.containsKey("allrepos")); SessionlessForm form = new SessionlessForm("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("query", queryModel).setEnabled(luceneEnabled)); + form.add(new CheckBox("allrepos", allreposModel)); add(form.setEnabled(luceneEnabled)); // execute search -- 2.39.5