summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2011-12-28 16:20:39 -0500
committerJames Moger <james.moger@gitblit.com>2011-12-28 16:20:39 -0500
commitabeaaf77673e9e764fe68e398eeda1e3c3c22ea5 (patch)
tree0f19b665eafa7e6e5151098fd8eb3c4b749de31d
parent357109c5a5518db5925f49a6700a87e7ed30ca14 (diff)
downloadgitblit-abeaaf77673e9e764fe68e398eeda1e3c3c22ea5.tar.gz
gitblit-abeaaf77673e9e764fe68e398eeda1e3c3c22ea5.zip
Show additional columns in users and teams tables
-rw-r--r--src/com/gitblit/ConfigUserService.java29
-rw-r--r--src/com/gitblit/FileUserService.java32
-rw-r--r--src/com/gitblit/GitBlit.java24
-rw-r--r--src/com/gitblit/GitblitUserService.java10
-rw-r--r--src/com/gitblit/IUserService.java19
-rw-r--r--src/com/gitblit/wicket/GitBlitWebApp.properties2
-rw-r--r--src/com/gitblit/wicket/panels/TeamsPanel.html6
-rw-r--r--src/com/gitblit/wicket/panels/TeamsPanel.java35
-rw-r--r--src/com/gitblit/wicket/panels/UsersPanel.html10
-rw-r--r--src/com/gitblit/wicket/panels/UsersPanel.java35
10 files changed, 167 insertions, 35 deletions
diff --git a/src/com/gitblit/ConfigUserService.java b/src/com/gitblit/ConfigUserService.java
index 7e4600cf..c3d42df2 100644
--- a/src/com/gitblit/ConfigUserService.java
+++ b/src/com/gitblit/ConfigUserService.java
@@ -313,6 +313,21 @@ public class ConfigUserService implements IUserService {
}
/**
+ * Returns the list of all teams available to the login service.
+ *
+ * @return list of all teams
+ * @since 0.8.0
+ */
+ @Override
+ public List<TeamModel> getAllTeams() {
+ read();
+ List<TeamModel> list = new ArrayList<TeamModel>(teams.values());
+ list = DeepCopier.copy(list);
+ Collections.sort(list);
+ return list;
+ }
+
+ /**
* Returns the list of all users who are allowed to bypass the access
* restriction placed on the specified repository.
*
@@ -478,6 +493,20 @@ public class ConfigUserService implements IUserService {
Collections.sort(list);
return list;
}
+
+ /**
+ * Returns the list of all users available to the login service.
+ *
+ * @return list of all usernames
+ */
+ @Override
+ public List<UserModel> getAllUsers() {
+ read();
+ List<UserModel> list = new ArrayList<UserModel>(users.values());
+ list = DeepCopier.copy(list);
+ Collections.sort(list);
+ return list;
+ }
/**
* Returns the list of all users who are allowed to bypass the access
diff --git a/src/com/gitblit/FileUserService.java b/src/com/gitblit/FileUserService.java
index 88c7d790..9c4e507d 100644
--- a/src/com/gitblit/FileUserService.java
+++ b/src/com/gitblit/FileUserService.java
@@ -340,6 +340,22 @@ public class FileUserService extends FileSettings implements IUserService {
}
/**
+ * Returns the list of all users available to the login service.
+ *
+ * @return list of all usernames
+ */
+ @Override
+ public List<UserModel> getAllUsers() {
+ read();
+ List<UserModel> list = new ArrayList<UserModel>();
+ for (String username : getAllUsernames()) {
+ list.add(getUserModel(username));
+ }
+ Collections.sort(list);
+ return list;
+ }
+
+ /**
* Returns the list of all users who are allowed to bypass the access
* restriction placed on the specified repository.
*
@@ -670,6 +686,20 @@ public class FileUserService extends FileSettings implements IUserService {
}
/**
+ * Returns the list of all teams available to the login service.
+ *
+ * @return list of all teams
+ * @since 0.8.0
+ */
+ @Override
+ public List<TeamModel> getAllTeams() {
+ List<TeamModel> list = new ArrayList<TeamModel>(teams.values());
+ list = DeepCopier.copy(list);
+ Collections.sort(list);
+ return list;
+ }
+
+ /**
* Returns the list of all teams who are allowed to bypass the access
* restriction placed on the specified repository.
*
@@ -757,7 +787,7 @@ public class FileUserService extends FileSettings implements IUserService {
// remove role from team
for (String name : needsRemoveRole) {
String team = "@" + name;
- String[] values = allUsers.getProperty(team).split(",");
+ String[] values = allUsers.getProperty(team).split(",");
StringBuilder sb = new StringBuilder();
for (int i = 0; i < values.length; i++) {
String value = values[i];
diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java
index d82e3c2f..6271a0d6 100644
--- a/src/com/gitblit/GitBlit.java
+++ b/src/com/gitblit/GitBlit.java
@@ -449,9 +449,19 @@ public class GitBlit implements ServletContextListener {
*/
public List<String> getAllUsernames() {
List<String> names = new ArrayList<String>(userService.getAllUsernames());
- Collections.sort(names);
return names;
}
+
+ /**
+ * Returns the list of all users available to the login service.
+ *
+ * @see IUserService.getAllUsernames()
+ * @return list of all usernames
+ */
+ public List<UserModel> getAllUsers() {
+ List<UserModel> users = userService.getAllUsers();
+ return users;
+ }
/**
* Delete the user object with the specified username
@@ -533,7 +543,17 @@ public class GitBlit implements ServletContextListener {
*/
public List<String> getAllTeamnames() {
List<String> teams = new ArrayList<String>(userService.getAllTeamNames());
- Collections.sort(teams);
+ return teams;
+ }
+
+ /**
+ * Returns the list of available teams that a user or repository may be
+ * assigned to.
+ *
+ * @return the list of teams
+ */
+ public List<TeamModel> getAllTeams() {
+ List<TeamModel> teams = userService.getAllTeams();
return teams;
}
diff --git a/src/com/gitblit/GitblitUserService.java b/src/com/gitblit/GitblitUserService.java
index 122c21bb..eddc8a3d 100644
--- a/src/com/gitblit/GitblitUserService.java
+++ b/src/com/gitblit/GitblitUserService.java
@@ -162,11 +162,21 @@ public class GitblitUserService implements IUserService {
}
@Override
+ public List<UserModel> getAllUsers() {
+ return serviceImpl.getAllUsers();
+ }
+
+ @Override
public List<String> getAllTeamNames() {
return serviceImpl.getAllTeamNames();
}
@Override
+ public List<TeamModel> getAllTeams() {
+ return serviceImpl.getAllTeams();
+ }
+
+ @Override
public List<String> getTeamnamesForRepositoryRole(String role) {
return serviceImpl.getTeamnamesForRepositoryRole(role);
}
diff --git a/src/com/gitblit/IUserService.java b/src/com/gitblit/IUserService.java
index 98dbf0d6..a5e04e3e 100644
--- a/src/com/gitblit/IUserService.java
+++ b/src/com/gitblit/IUserService.java
@@ -121,6 +121,14 @@ public interface IUserService {
* @return list of all usernames
*/
List<String> getAllUsernames();
+
+ /**
+ * Returns the list of all users available to the login service.
+ *
+ * @return list of all users
+ * @since 0.8.0
+ */
+ List<UserModel> getAllUsers();
/**
* Returns the list of all teams available to the login service.
@@ -131,12 +139,21 @@ public interface IUserService {
List<String> getAllTeamNames();
/**
+ * Returns the list of all teams available to the login service.
+ *
+ * @return list of all teams
+ * @since 0.8.0
+ */
+ List<TeamModel> getAllTeams();
+
+ /**
* Returns the list of all users who are allowed to bypass the access
* restriction placed on the specified repository.
*
* @param role
* the repository name
* @return list of all usernames that can bypass the access restriction
+ * @since 0.8.0
*/
List<String> getTeamnamesForRepositoryRole(String role);
@@ -148,6 +165,7 @@ public interface IUserService {
* the repository name
* @param teamnames
* @return true if successful
+ * @since 0.8.0
*/
boolean setTeamnamesForRepositoryRole(String role, List<String> teamnames);
@@ -207,6 +225,7 @@ public interface IUserService {
* @param role
* the repository name
* @return list of all usernames that can bypass the access restriction
+ * @since 0.8.0
*/
List<String> getUsernamesForRepositoryRole(String role);
diff --git a/src/com/gitblit/wicket/GitBlitWebApp.properties b/src/com/gitblit/wicket/GitBlitWebApp.properties
index 6a5dd348..a2c81312 100644
--- a/src/com/gitblit/wicket/GitBlitWebApp.properties
+++ b/src/com/gitblit/wicket/GitBlitWebApp.properties
@@ -207,4 +207,4 @@ gb.accessPermissionsDescription = restrict access by users and teams
gb.accessPermissionsForUserDescription = set team memberships or grant access to specific restricted repositories
gb.accessPermissionsForTeamDescription = set team members and grant access to specific restricted repositories
gb.federationRepositoryDescription = share this repository with other Gitblit servers
-gb.hookScriptsDescription = run custom scripts on pushes to this Gitblit server \ No newline at end of file
+gb.hookScriptsDescription = run Groovy scripts on pushes to this Gitblit server \ No newline at end of file
diff --git a/src/com/gitblit/wicket/panels/TeamsPanel.html b/src/com/gitblit/wicket/panels/TeamsPanel.html
index af1d56de..e5382905 100644
--- a/src/com/gitblit/wicket/panels/TeamsPanel.html
+++ b/src/com/gitblit/wicket/panels/TeamsPanel.html
@@ -15,11 +15,15 @@
<img style="vertical-align: middle; border: 1px solid #888; background-color: white;" src="users_16x16.png"/>
<wicket:message key="gb.teams">[teams]</wicket:message>
</th>
- <th class="right"></th>
+ <th style="width:140px;"><wicket:message key="gb.teamMembers">[team members]</wicket:message></th>
+ <th style="width:100px;"><wicket:message key="gb.repositories">[repositories]</wicket:message></th>
+ <th style="width:80px;" class="right"></th>
</tr>
<tbody>
<tr wicket:id="teamRow">
<td class="left" ><div class="list" wicket:id="teamname">[teamname]</div></td>
+ <td class="left" ><div class="list" wicket:id="members">[members]</div></td>
+ <td class="left" ><div class="list" wicket:id="repositories">[repositories]</div></td>
<td class="rightAlign"><span wicket:id="teamLinks"></span></td>
</tr>
</tbody>
diff --git a/src/com/gitblit/wicket/panels/TeamsPanel.java b/src/com/gitblit/wicket/panels/TeamsPanel.java
index 33afb514..ae5a30a6 100644
--- a/src/com/gitblit/wicket/panels/TeamsPanel.java
+++ b/src/com/gitblit/wicket/panels/TeamsPanel.java
@@ -18,6 +18,7 @@ package com.gitblit.wicket.panels;
import java.text.MessageFormat;
import java.util.List;
+import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Fragment;
@@ -26,6 +27,7 @@ import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
import com.gitblit.GitBlit;
+import com.gitblit.models.TeamModel;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.pages.EditTeamPage;
@@ -40,9 +42,9 @@ public class TeamsPanel extends BasePanel {
adminLinks.add(new BookmarkablePageLink<Void>("newTeam", EditTeamPage.class));
add(adminLinks.setVisible(showAdmin));
- final List<String> teamnames = GitBlit.self().getAllTeamnames();
- DataView<String> teamsView = new DataView<String>("teamRow", new ListDataProvider<String>(
- teamnames)) {
+ final List<TeamModel> teams = GitBlit.self().getAllTeams();
+ DataView<TeamModel> teamsView = new DataView<TeamModel>("teamRow",
+ new ListDataProvider<TeamModel>(teams)) {
private static final long serialVersionUID = 1L;
private int counter;
@@ -52,31 +54,36 @@ public class TeamsPanel extends BasePanel {
counter = 0;
}
- public void populateItem(final Item<String> item) {
- final String entry = item.getModelObject();
- LinkPanel editLink = new LinkPanel("teamname", "list", entry, EditTeamPage.class,
- WicketUtils.newTeamnameParameter(entry));
- WicketUtils.setHtmlTooltip(editLink, getString("gb.edit") + " " + entry);
+ public void populateItem(final Item<TeamModel> item) {
+ final TeamModel entry = item.getModelObject();
+ LinkPanel editLink = new LinkPanel("teamname", "list", entry.name,
+ EditTeamPage.class, WicketUtils.newTeamnameParameter(entry.name));
+ WicketUtils.setHtmlTooltip(editLink, getString("gb.edit") + " " + entry.name);
item.add(editLink);
+ item.add(new Label("members", entry.users.size() > 0 ? ("" + entry.users.size())
+ : ""));
+ item.add(new Label("repositories",
+ entry.repositories.size() > 0 ? ("" + entry.repositories.size()) : ""));
Fragment teamLinks = new Fragment("teamLinks", "teamAdminLinks", this);
teamLinks.add(new BookmarkablePageLink<Void>("editTeam", EditTeamPage.class,
- WicketUtils.newTeamnameParameter(entry)));
+ WicketUtils.newTeamnameParameter(entry.name)));
Link<Void> deleteLink = new Link<Void>("deleteTeam") {
private static final long serialVersionUID = 1L;
@Override
public void onClick() {
- if (GitBlit.self().deleteTeam(entry)) {
- teamnames.remove(entry);
- info(MessageFormat.format("Team ''{0}'' deleted.", entry));
+ if (GitBlit.self().deleteTeam(entry.name)) {
+ teams.remove(entry);
+ info(MessageFormat.format("Team ''{0}'' deleted.", entry.name));
} else {
- error(MessageFormat.format("Failed to delete team ''{0}''!", entry));
+ error(MessageFormat
+ .format("Failed to delete team ''{0}''!", entry.name));
}
}
};
deleteLink.add(new JavascriptEventConfirmation("onclick", MessageFormat.format(
- "Delete team \"{0}\"?", entry)));
+ "Delete team \"{0}\"?", entry.name)));
teamLinks.add(deleteLink);
item.add(teamLinks);
diff --git a/src/com/gitblit/wicket/panels/UsersPanel.html b/src/com/gitblit/wicket/panels/UsersPanel.html
index 1cc19ee5..aa59a498 100644
--- a/src/com/gitblit/wicket/panels/UsersPanel.html
+++ b/src/com/gitblit/wicket/panels/UsersPanel.html
@@ -15,11 +15,17 @@
<img style="vertical-align: middle; border: 1px solid #888; background-color: white;" src="user_16x16.png"/>
<wicket:message key="gb.users">[users]</wicket:message>
</th>
- <th class="right"></th>
+ <th style="width:120px;"><wicket:message key="gb.accessLevel">[access level]</wicket:message></th>
+ <th style="width:140px;"><wicket:message key="gb.teamMemberships">[team memberships]</wicket:message></th>
+ <th style="width:100px;"><wicket:message key="gb.repositories">[repositories]</wicket:message></th>
+ <th style="width:80px;" class="right"></th>
</tr>
<tbody>
<tr wicket:id="userRow">
- <td class="left" ><div class="list" wicket:id="username">[username]</div></td>
+ <td class="left" ><span class="list" wicket:id="username">[username]</span></td>
+ <td class="left" ><span class="list" wicket:id="accesslevel">[access level]</span></td>
+ <td class="left" ><span class="list" wicket:id="teams">[team memberships]</span></td>
+ <td class="left" ><span class="list" wicket:id="repositories">[repositories]</span></td>
<td class="rightAlign"><span wicket:id="userLinks"></span></td>
</tr>
</tbody>
diff --git a/src/com/gitblit/wicket/panels/UsersPanel.java b/src/com/gitblit/wicket/panels/UsersPanel.java
index 4cf92a46..ad2ed922 100644
--- a/src/com/gitblit/wicket/panels/UsersPanel.java
+++ b/src/com/gitblit/wicket/panels/UsersPanel.java
@@ -18,6 +18,7 @@ package com.gitblit.wicket.panels;
import java.text.MessageFormat;
import java.util.List;
+import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Fragment;
@@ -26,6 +27,7 @@ import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
import com.gitblit.GitBlit;
+import com.gitblit.models.UserModel;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.pages.EditUserPage;
@@ -40,9 +42,9 @@ public class UsersPanel extends BasePanel {
adminLinks.add(new BookmarkablePageLink<Void>("newUser", EditUserPage.class));
add(adminLinks.setVisible(showAdmin));
- final List<String> usernames = GitBlit.self().getAllUsernames();
- DataView<String> usersView = new DataView<String>("userRow", new ListDataProvider<String>(
- usernames)) {
+ final List<UserModel> users = GitBlit.self().getAllUsers();
+ DataView<UserModel> usersView = new DataView<UserModel>("userRow",
+ new ListDataProvider<UserModel>(users)) {
private static final long serialVersionUID = 1L;
private int counter;
@@ -52,31 +54,36 @@ public class UsersPanel extends BasePanel {
counter = 0;
}
- public void populateItem(final Item<String> item) {
- final String entry = item.getModelObject();
- LinkPanel editLink = new LinkPanel("username", "list", entry, EditUserPage.class,
- WicketUtils.newUsernameParameter(entry));
- WicketUtils.setHtmlTooltip(editLink, getString("gb.edit") + " " + entry);
+ public void populateItem(final Item<UserModel> item) {
+ final UserModel entry = item.getModelObject();
+ LinkPanel editLink = new LinkPanel("username", "list", entry.username,
+ EditUserPage.class, WicketUtils.newUsernameParameter(entry.username));
+ WicketUtils.setHtmlTooltip(editLink, getString("gb.edit") + " " + entry.username);
item.add(editLink);
+ item.add(new Label("accesslevel", entry.canAdmin ? "administrator" : ""));
+ item.add(new Label("teams", entry.teams.size() > 0 ? ("" + entry.teams.size()) : ""));
+ item.add(new Label("repositories",
+ entry.repositories.size() > 0 ? ("" + entry.repositories.size()) : ""));
Fragment userLinks = new Fragment("userLinks", "userAdminLinks", this);
userLinks.add(new BookmarkablePageLink<Void>("editUser", EditUserPage.class,
- WicketUtils.newUsernameParameter(entry)));
+ WicketUtils.newUsernameParameter(entry.username)));
Link<Void> deleteLink = new Link<Void>("deleteUser") {
private static final long serialVersionUID = 1L;
@Override
public void onClick() {
- if (GitBlit.self().deleteUser(entry)) {
- usernames.remove(entry);
- info(MessageFormat.format("User ''{0}'' deleted.", entry));
+ if (GitBlit.self().deleteUser(entry.username)) {
+ users.remove(entry);
+ info(MessageFormat.format("User ''{0}'' deleted.", entry.username));
} else {
- error(MessageFormat.format("Failed to delete user ''{0}''!", entry));
+ error(MessageFormat.format("Failed to delete user ''{0}''!",
+ entry.username));
}
}
};
deleteLink.add(new JavascriptEventConfirmation("onclick", MessageFormat.format(
- "Delete user \"{0}\"?", entry)));
+ "Delete user \"{0}\"?", entry.username)));
userLinks.add(deleteLink);
item.add(userLinks);