]> source.dussan.org Git - gitblit.git/commitdiff
Add "all repositories" parameter 935/head
authorVitaliy Filippov <vitalif@yourcmc.ru>
Tue, 29 Sep 2015 10:58:21 +0000 (13:58 +0300)
committerVitaliy Filippov <vitalif@yourcmc.ru>
Thu, 1 Oct 2015 10:10:51 +0000 (13:10 +0300)
src/main/java/com/gitblit/wicket/GitBlitWebApp.properties
src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.html
src/main/java/com/gitblit/wicket/pages/LuceneSearchPage.java

index d037420061b683615981589ae89683128e528228..0c6bb1e0ae8543c67964e5873c3fb9dcefa9272e 100644 (file)
@@ -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
index 91a6ef43883869975c8a3bb7a67da2c22167f8c4..c8865e85f50df513d4149b67e67109b4ce5d5fa0 100644 (file)
@@ -24,6 +24,7 @@
                        <div class="span3">\r
                                <h3><wicket:message key="gb.repositories"></wicket:message></h3>\r
                                <select wicket:id="repositories" ></select>\r
+                               <label><input type="checkbox" wicket:id="allrepos" /> <span><wicket:message key="gb.allrepos"></wicket:message></span></label>
                        </div>\r
                        <div class="span9" style="margin-left:10px">\r
                                <div>\r
index 4d4545a5e6177672355ae5b255c276d081dc5985..ec8223183e5538bf24aac1c8bebe364c4b7e4a91 100644 (file)
@@ -24,6 +24,7 @@ import org.apache.wicket.PageParameters;
 import org.apache.wicket.markup.html.basic.Label;\r
 import org.apache.wicket.markup.html.form.ListMultipleChoice;\r
 import org.apache.wicket.markup.html.form.TextField;\r
+import org.apache.wicket.markup.html.form.CheckBox;\r
 import org.apache.wicket.markup.html.panel.Fragment;\r
 import org.apache.wicket.markup.repeater.Item;\r
 import org.apache.wicket.markup.repeater.data.DataView;\r
@@ -66,6 +67,15 @@ public class LuceneSearchPage extends RootPage {
                int page = 1;\r
                int pageSize = app().settings().getInteger(Keys.web.itemsPerPage, 50);\r
 \r
+               // display user-accessible selections\r
+               UserModel user = GitBlitWebSession.get().getUser();\r
+               List<String> availableRepositories = new ArrayList<String>();\r
+               for (RepositoryModel model : app().repositories().getRepositoryModels(user)) {\r
+                       if (model.hasCommits && !ArrayUtils.isEmpty(model.indexedBranches)) {\r
+                               availableRepositories.add(model.name);\r
+                       }\r
+               }\r
+\r
                if (params != null) {\r
                        String repository = WicketUtils.getRepositoryName(params);\r
                        if (!StringUtils.isEmpty(repository)) {\r
@@ -79,6 +89,10 @@ public class LuceneSearchPage extends RootPage {
                                List<String> list = StringUtils.getStringsFromValue(value);\r
                                repositories.addAll(list);\r
                        }\r
+
+                       if (params.containsKey("allrepos")) {\r
+                               repositories.addAll(availableRepositories);\r
+                       }\r
 \r
                        if (params.containsKey("query")) {\r
                                query = params.getString("query", "");\r
@@ -96,14 +110,6 @@ public class LuceneSearchPage extends RootPage {
                        }\r
                }\r
 \r
-               // display user-accessible selections\r
-               UserModel user = GitBlitWebSession.get().getUser();\r
-               List<String> availableRepositories = new ArrayList<String>();\r
-               for (RepositoryModel model : app().repositories().getRepositoryModels(user)) {\r
-                       if (model.hasCommits && !ArrayUtils.isEmpty(model.indexedBranches)) {\r
-                               availableRepositories.add(model.name);\r
-                       }\r
-               }\r
                boolean luceneEnabled = app().settings().getBoolean(Keys.web.allowLuceneIndexing, true);\r
                if (luceneEnabled) {\r
                        if (availableRepositories.size() == 0) {\r
@@ -124,6 +130,7 @@ public class LuceneSearchPage extends RootPage {
                // search form\r
                final Model<String> queryModel = new Model<String>(query);\r
                final Model<ArrayList<String>> repositoriesModel = new Model<ArrayList<String>>(searchRepositories);\r
+               final Model<Boolean> allreposModel = new Model<Boolean>(params != null && params.containsKey("allrepos"));\r
                SessionlessForm<Void> form = new SessionlessForm<Void>("searchForm", getClass()) {\r
 \r
                        private static final long serialVersionUID = 1L;\r
@@ -135,13 +142,14 @@ public class LuceneSearchPage extends RootPage {
                                        error(getString("gb.undefinedQueryWarning"));\r
                                        return;\r
                                }\r
-                               if (repositoriesModel.getObject().size() == 0) {\r
+                               if (repositoriesModel.getObject().size() == 0 && !allreposModel.getObject()) {\r
                                        error(getString("gb.noSelectedRepositoriesWarning"));\r
                                        return;\r
                                }\r
                                PageParameters params = new PageParameters();\r
                                params.put("repositories", StringUtils.flattenStrings(repositoriesModel.getObject()));\r
                                params.put("query", queryModel.getObject());\r
+                               params.put("allrepos", allreposModel.getObject());\r
                                LuceneSearchPage page = new LuceneSearchPage(params);\r
                                setResponsePage(page);\r
                        }\r
@@ -152,6 +160,7 @@ public class LuceneSearchPage extends RootPage {
                selections.setMaxRows(8);\r
                form.add(selections.setEnabled(luceneEnabled));\r
                form.add(new TextField<String>("query", queryModel).setEnabled(luceneEnabled));\r
+               form.add(new CheckBox("allrepos", allreposModel));\r
                add(form.setEnabled(luceneEnabled));\r
 \r
                // execute search\r