From 9e7b14b651cf3812718d33665529de919c05795d Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Thu, 15 May 2014 08:10:20 -0400 Subject: [PATCH] Redesign the EmptyRepositoryPage --- src/main/java/com/gitblit/wicket/pages/RepositoryPage.java | 33 +++++++++++++++++++-------------- 1 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java index a0c9ce0..fcf659a 100644 --- a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java @@ -108,7 +108,7 @@ error(MessageFormat.format(getString("gb.repositoryNotSpecifiedFor"), getPageName()), true); } - if (!getRepositoryModel().hasCommits) { + if (!getRepositoryModel().hasCommits && getClass() != EmptyRepositoryPage.class) { throw new RestartResponseException(EmptyRepositoryPage.class, params); } @@ -147,6 +147,16 @@ } } } + + showAdmin = false; + if (app().settings().getBoolean(Keys.web.authenticateAdminPages, true)) { + boolean allowAdmin = app().settings().getBoolean(Keys.web.allowAdministration, false); + showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin(); + } else { + showAdmin = app().settings().getBoolean(Keys.web.allowAdministration, false); + } + isOwner = GitBlitWebSession.get().isLoggedIn() + && (getRepositoryModel().isOwner(GitBlitWebSession.get().getUsername())); // register the available navigation links for this page and user List<NavLink> navLinks = registerNavLinks(); @@ -195,9 +205,14 @@ navLinks.add(new PageNavLink("gb.summary", SummaryPage.class, params)); } else { navLinks.add(new PageNavLink("gb.summary", SummaryPage.class, params)); -// pages.put("overview", new PageRegistration("gb.overview", OverviewPage.class, params)); + // pages.put("overview", new PageRegistration("gb.overview", OverviewPage.class, params)); navLinks.add(new PageNavLink("gb.reflog", ReflogPage.class, params)); } + + if (!model.hasCommits) { + return navLinks; + } + navLinks.add(new PageNavLink("gb.commits", LogPage.class, params)); navLinks.add(new PageNavLink("gb.tree", TreePage.class, params)); if (app().tickets().isReady() && (app().tickets().isAcceptingNewTickets(model) || app().tickets().hasTickets(model))) { @@ -229,16 +244,6 @@ navLinks.addAll(ext.getNavLinks(user, model)); } - // Conditionally add edit link - showAdmin = false; - if (app().settings().getBoolean(Keys.web.authenticateAdminPages, true)) { - boolean allowAdmin = app().settings().getBoolean(Keys.web.allowAdministration, false); - showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin(); - } else { - showAdmin = app().settings().getBoolean(Keys.web.allowAdministration, false); - } - isOwner = GitBlitWebSession.get().isLoggedIn() - && (model.isOwner(GitBlitWebSession.get().getUsername())); return navLinks; } @@ -311,7 +316,7 @@ } // (un)star link allows a user to star a repository - if (user.isAuthenticated) { + if (user.isAuthenticated && model.hasCommits) { PageParameters starParams = DeepCopier.copy(getPageParameters()); starParams.put(PARAM_STAR, !user.getPreferences().isStarredRepository(model.name)); String toggleStarUrl = getRequestCycle().urlFor(getClass(), starParams).toString(); @@ -338,7 +343,7 @@ } else { String fork = app().repositories().getFork(user.username, model.name); boolean hasFork = fork != null; - boolean canFork = user.canFork(model); + boolean canFork = user.canFork(model) && model.hasCommits; if (hasFork || !canFork) { // user not allowed to fork or fork already exists or repo forbids forking -- Gitblit v1.9.1