From: James Moger Date: Tue, 2 Oct 2012 02:54:48 +0000 (-0400) Subject: Show display name for owner, when possible X-Git-Tag: v1.2.0~200 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fb6bf3a22e1bcaca11c1519328c73bf016b5cac0;p=gitblit.git Show display name for owner, when possible --- diff --git a/src/com/gitblit/wicket/pages/SummaryPage.java b/src/com/gitblit/wicket/pages/SummaryPage.java index 22b1c1ab..8df2cebc 100644 --- a/src/com/gitblit/wicket/pages/SummaryPage.java +++ b/src/com/gitblit/wicket/pages/SummaryPage.java @@ -45,12 +45,14 @@ import com.gitblit.Keys; import com.gitblit.models.Metric; import com.gitblit.models.PathModel; import com.gitblit.models.RepositoryModel; +import com.gitblit.models.UserModel; import com.gitblit.utils.ArrayUtils; import com.gitblit.utils.JGitUtils; import com.gitblit.utils.MarkdownUtils; import com.gitblit.utils.StringUtils; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.BranchesPanel; +import com.gitblit.wicket.panels.LinkPanel; import com.gitblit.wicket.panels.LogPanel; import com.gitblit.wicket.panels.RepositoryUrlPanel; import com.gitblit.wicket.panels.TagsPanel; @@ -80,7 +82,17 @@ public class SummaryPage extends RepositoryPage { // repository description add(new Label("repositoryDescription", getRepositoryModel().description)); - add(new Label("repositoryOwner", getRepositoryModel().owner)); + String owner = getRepositoryModel().owner; + if (StringUtils.isEmpty(owner)) { + add(new Label("repositoryOwner").setVisible(false)); + } else { + UserModel ownerModel = GitBlit.self().getUserModel(owner); + if (ownerModel != null) { + add(new LinkPanel("repositoryOwner", null, ownerModel.getDisplayName(), UserPage.class, WicketUtils.newUsernameParameter(owner))); + } else { + add(new Label("repositoryOwner", owner)); + } + } add(WicketUtils.createTimestampLabel("repositoryLastChange", JGitUtils.getLastChange(r), getTimeZone(), getTimeUtils())); diff --git a/src/com/gitblit/wicket/pages/UserPage.java b/src/com/gitblit/wicket/pages/UserPage.java index cabefb4e..e3661462 100644 --- a/src/com/gitblit/wicket/pages/UserPage.java +++ b/src/com/gitblit/wicket/pages/UserPage.java @@ -87,7 +87,7 @@ public class UserPage extends RootPage { ProjectModel project = GitBlit.self().getProjectModel(projectName); if (project == null) { - throw new RedirectException(GitBlitWebApp.get().getHomePage()); + project = new ProjectModel(projectName); } add(new Label("userDisplayName", user.getDisplayName())); diff --git a/src/com/gitblit/wicket/panels/ProjectRepositoryPanel.java b/src/com/gitblit/wicket/panels/ProjectRepositoryPanel.java index f7deaf13..c66fa60f 100644 --- a/src/com/gitblit/wicket/panels/ProjectRepositoryPanel.java +++ b/src/com/gitblit/wicket/panels/ProjectRepositoryPanel.java @@ -51,7 +51,7 @@ public class ProjectRepositoryPanel extends BasePanel { private static final long serialVersionUID = 1L; - public ProjectRepositoryPanel(String wicketId, Localizer localizer, Component owner, + public ProjectRepositoryPanel(String wicketId, Localizer localizer, Component parent, final boolean isAdmin, final RepositoryModel entry, final Map accessRestrictions) { super(wicketId); @@ -66,7 +66,7 @@ public class ProjectRepositoryPanel extends BasePanel { swatch = new Label("repositorySwatch", " ").setEscapeModelStrings(false); } else { swatch = new Label("repositorySwatch", "!"); - WicketUtils.setHtmlTooltip(swatch, localizer.getString("gb.workingCopyWarning", owner)); + WicketUtils.setHtmlTooltip(swatch, localizer.getString("gb.workingCopyWarning", parent)); } WicketUtils.setCssBackground(swatch, entry.toString()); add(swatch); @@ -91,13 +91,13 @@ public class ProjectRepositoryPanel extends BasePanel { add(new BookmarkablePageLink("docs", DocsPage.class, pp).setVisible(entry.useDocs)); if (entry.isFrozen) { - add(WicketUtils.newImage("frozenIcon", "cold_16x16.png", localizer.getString("gb.isFrozen", owner))); + add(WicketUtils.newImage("frozenIcon", "cold_16x16.png", localizer.getString("gb.isFrozen", parent))); } else { add(WicketUtils.newClearPixel("frozenIcon").setVisible(false)); } if (entry.isFederated) { - add(WicketUtils.newImage("federatedIcon", "federated_16x16.png", localizer.getString("gb.isFederated", owner))); + add(WicketUtils.newImage("federatedIcon", "federated_16x16.png", localizer.getString("gb.isFederated", parent))); } else { add(WicketUtils.newClearPixel("federatedIcon").setVisible(false)); } @@ -121,8 +121,17 @@ public class ProjectRepositoryPanel extends BasePanel { add(WicketUtils.newBlankImage("accessRestrictionIcon")); } - add(new Label("repositoryOwner", StringUtils.isEmpty(entry.owner) ? "" : (entry.owner + " (" - + localizer.getString("gb.owner", owner) + ")"))); + if (StringUtils.isEmpty(entry.owner)) { + add(new Label("repositoryOwner").setVisible(false)); + } else { + UserModel ownerModel = GitBlit.self().getUserModel(entry.owner); + String owner = entry.owner; + if (ownerModel != null) { + owner = ownerModel.getDisplayName(); + } + add(new Label("repositoryOwner", owner + " (" + + localizer.getString("gb.owner", parent) + ")")); + } UserModel user = GitBlitWebSession.get().getUser(); Fragment repositoryLinks; @@ -151,7 +160,7 @@ public class ProjectRepositoryPanel extends BasePanel { } }; deleteLink.add(new JavascriptEventConfirmation("onclick", MessageFormat.format( - localizer.getString("gb.deleteRepository", owner), entry))); + localizer.getString("gb.deleteRepository", parent), entry))); repositoryLinks.add(deleteLink); } } else { @@ -181,7 +190,7 @@ public class ProjectRepositoryPanel extends BasePanel { add(new Label("repositorySize", entry.size).setVisible(showSize)); } else { // New repository - add(new Label("repositorySize", localizer.getString("gb.empty", owner)).setEscapeModelStrings(false)); + add(new Label("repositorySize", localizer.getString("gb.empty", parent)).setEscapeModelStrings(false)); } add(new ExternalLink("syndication", SyndicationServlet.asLink("", entry.name, null, 0))); diff --git a/src/com/gitblit/wicket/panels/RepositoriesPanel.java b/src/com/gitblit/wicket/panels/RepositoriesPanel.java index 0855780b..4c9ed280 100644 --- a/src/com/gitblit/wicket/panels/RepositoriesPanel.java +++ b/src/com/gitblit/wicket/panels/RepositoriesPanel.java @@ -271,7 +271,14 @@ public class RepositoriesPanel extends BasePanel { row.add(WicketUtils.newBlankImage("accessRestrictionIcon")); } - row.add(new Label("repositoryOwner", entry.owner)); + String owner = entry.owner; + if (!StringUtils.isEmpty(owner)) { + UserModel ownerModel = GitBlit.self().getUserModel(owner); + if (ownerModel != null) { + owner = ownerModel.getDisplayName(); + } + } + row.add(new Label("repositoryOwner", owner)); String lastChange; if (entry.lastChange.getTime() == 0) {