\r
import java.text.MessageFormat;\r
import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.HashMap;\r
import java.util.LinkedHashSet;\r
import java.util.List;\r
+import java.util.Map;\r
import java.util.Set;\r
+import java.util.concurrent.atomic.AtomicInteger;\r
import java.util.regex.Pattern;\r
\r
import org.apache.wicket.PageParameters;\r
boolean authenticateView = GitBlit.getBoolean(Keys.web.authenticateViewPages, false);\r
boolean authenticateAdmin = GitBlit.getBoolean(Keys.web.authenticateAdminPages, true);\r
boolean allowAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, true);\r
- \r
- if (authenticateAdmin) { \r
+\r
+ if (authenticateAdmin) {\r
showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin();\r
// authentication requires state and session\r
setStatelessHint(false);\r
WicketUtils.setInputPlaceholder(pwField, getString("gb.password"));\r
loginForm.add(pwField);\r
add(loginForm);\r
- \r
+\r
if (authenticateView || authenticateAdmin) {\r
loginForm.setVisible(!GitBlitWebSession.get().isLoggedIn());\r
} else {\r
protected List<DropDownMenuItem> getFilterMenuItems() {\r
final UserModel user = GitBlitWebSession.get().getUser();\r
Set<DropDownMenuItem> filters = new LinkedHashSet<DropDownMenuItem>();\r
+ List<RepositoryModel> repositories = GitBlit.self().getRepositoryModels(user);\r
\r
// accessible repositories by federation set\r
- for (RepositoryModel repository : GitBlit.self().getRepositoryModels(user)) {\r
+ Map<String, AtomicInteger> setMap = new HashMap<String, AtomicInteger>();\r
+ for (RepositoryModel repository : repositories) {\r
for (String set : repository.federationSets) {\r
- filters.add(new DropDownMenuItem(set, "set", set));\r
+ String key = set.toLowerCase();\r
+ if (setMap.containsKey(key)) {\r
+ setMap.get(key).incrementAndGet();\r
+ } else {\r
+ setMap.put(key, new AtomicInteger(1));\r
+ }\r
}\r
}\r
- if (filters.size() > 0) {\r
+ if (setMap.size() > 0) {\r
+ List<String> sets = new ArrayList<String>(setMap.keySet());\r
+ Collections.sort(sets);\r
+ for (String set : sets) {\r
+ filters.add(new DropDownMenuItem(MessageFormat.format("{0} ({1})", set,\r
+ setMap.get(set).get()), "set", set));\r
+ }\r
// divider\r
filters.add(new DropDownMenuItem());\r
}\r
\r
// user's team memberships\r
if (user != null && user.teams.size() > 0) {\r
- for (TeamModel team : user.teams) {\r
- filters.add(new DropDownMenuItem(team.name, "team", team.name));\r
+ List<TeamModel> teams = new ArrayList<TeamModel>(user.teams);\r
+ Collections.sort(teams);\r
+ for (TeamModel team : teams) {\r
+ filters.add(new DropDownMenuItem(MessageFormat.format("{0} ({1})", team.name,\r
+ team.repositories.size()), "team", team.name));\r
}\r
// divider\r
filters.add(new DropDownMenuItem());\r
\r
if (filters.size() > 0) {\r
// add All Repositories\r
- filters.add(new DropDownMenuItem("All Repositories", null, null));\r
+ filters.add(new DropDownMenuItem(MessageFormat.format("All Repositories ({0})",\r
+ repositories.size()), null, null));\r
}\r
\r
return new ArrayList<DropDownMenuItem>(filters);\r