summaryrefslogtreecommitdiffstats
path: root/src/com/gitblit/wicket/panels/UsersPanel.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/gitblit/wicket/panels/UsersPanel.java')
-rw-r--r--src/com/gitblit/wicket/panels/UsersPanel.java33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/com/gitblit/wicket/panels/UsersPanel.java b/src/com/gitblit/wicket/panels/UsersPanel.java
index 17212723..55671ec1 100644
--- a/src/com/gitblit/wicket/panels/UsersPanel.java
+++ b/src/com/gitblit/wicket/panels/UsersPanel.java
@@ -1,6 +1,10 @@
package com.gitblit.wicket.panels;
+import java.text.MessageFormat;
+import java.util.List;
+
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
@@ -10,7 +14,6 @@ import com.gitblit.GitBlit;
import com.gitblit.wicket.LinkPanel;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.pages.EditUserPage;
-import com.gitblit.wicket.pages.RepositoriesPage;
public class UsersPanel extends BasePanel {
@@ -22,10 +25,17 @@ public class UsersPanel extends BasePanel {
Fragment adminLinks = new Fragment("adminPanel", "adminLinks", this);
adminLinks.add(new BookmarkablePageLink<Void>("newUser", EditUserPage.class));
add(adminLinks.setVisible(showAdmin));
-
- DataView<String> usersView = new DataView<String>("userRow", new ListDataProvider<String>(GitBlit.self().getAllUsernames())) {
+
+ final List<String> usernames = GitBlit.self().getAllUsernames();
+ DataView<String> usersView = new DataView<String>("userRow", new ListDataProvider<String>(usernames)) {
private static final long serialVersionUID = 1L;
private int counter = 0;
+
+ @Override
+ protected void onBeforeRender() {
+ super.onBeforeRender();
+ counter = 0;
+ }
public void populateItem(final Item<String> item) {
final String entry = item.getModelObject();
@@ -34,7 +44,22 @@ public class UsersPanel extends BasePanel {
item.add(editLink);
Fragment userLinks = new Fragment("userLinks", "userAdminLinks", this);
userLinks.add(new BookmarkablePageLink<Void>("editUser", EditUserPage.class, WicketUtils.newUsernameParameter(entry)));
- userLinks.add(new BookmarkablePageLink<Void>("deleteUser", RepositoriesPage.class, WicketUtils.newUsernameParameter(entry)).setEnabled(false));
+ 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));
+ } else {
+ error(MessageFormat.format("Failed to delete user ''{0}''!", entry));
+ }
+ }
+ };
+ deleteLink.add(new JavascriptEventConfirmation("onclick", MessageFormat.format("Delete user \"{0}\"?", entry)));
+ userLinks.add(deleteLink);
item.add(userLinks);
WicketUtils.setAlternatingBackground(item, counter);