Skip to content

The Unified and Autonomous Development Platform

Fix visiting empty repository throws exception

steve4755e60f71a7
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/ProjectCategoryPage.html b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/ProjectCategoryPage.html
index 8c4be224e9..bd7a780e20 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/ProjectCategoryPage.html
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/ProjectCategoryPage.html
@@ -2,7 +2,7 @@
<wicket:extend>
<div class="faux">
<div class="faux-row">
- <div class="faux-cell sidebar">
+ <div class="faux-cell sidebar" wicket:id="sidebar">
<div class="sidebar-inner repo-sidenav">
<wicket:container wicket:id="groups">
<h3 class="nav-head" wicket:id="name"></h3>
diff --git a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/ProjectCategoryPage.java b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/ProjectCategoryPage.java
index d0325695f6..16bf065dbb 100644
--- a/gitop.web/src/main/java/com/pmease/gitop/web/page/project/ProjectCategoryPage.java
+++ b/gitop.web/src/main/java/com/pmease/gitop/web/page/project/ProjectCategoryPage.java
@@ -7,6 +7,7 @@ import javax.persistence.EntityNotFoundException;
import org.apache.shiro.SecurityUtils;
import org.apache.wicket.Component;
import org.apache.wicket.behavior.AttributeAppender;
+import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.AbstractLink;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
@@ -67,6 +68,13 @@ public abstract class ProjectCategoryPage extends AbstractProjectPage {
@Override
protected void onPageInitialize() {
super.onPageInitialize();
+
+ add(createSidebar("sidebar"));
+ }
+
+ protected Component createSidebar(String id) {
+ WebMarkupContainer sidebar = new WebMarkupContainer(id);
+ sidebar.setVisibilityAllowed(getProject().code().hasCommits());
Loop groups = new Loop("groups", Category.values().length) {
@@ -78,7 +86,7 @@ public abstract class ProjectCategoryPage extends AbstractProjectPage {
}
};
- add(groups);
+ sidebar.add(groups);
AbstractLink adminLink = new BookmarkablePageLink<Void>("settinglink",
ProjectOptionsPage.class, PageSpec.forProject(getProject())) {
@@ -89,7 +97,8 @@ public abstract class ProjectCategoryPage extends AbstractProjectPage {
}
};
- add(adminLink);
+ sidebar.add(adminLink);
+ return sidebar;
}
protected String findRevision() {
@@ -147,21 +156,55 @@ public abstract class ProjectCategoryPage extends AbstractProjectPage {
// SOURCE TABS
//
- tabs.add(new ProjectPageTab(Model.of("Code"), Category.SOURCE, "icon-code", new Class[] { SourceTreePage.class, AbstractFilePage.class }));
- tabs.add(new ProjectPageTab(Model.of("Commits"), Category.SOURCE, "icon-commits", new Class[] { CommitsPage.class, SourceCommitPage.class }));
- tabs.add(new ProjectPageTab(Model.of("Branches"), Category.SOURCE, "icon-git-branch", BranchesPage.class));
- tabs.add(new ProjectPageTab(Model.of("Tags"), Category.SOURCE, "icon-tags", TagsPage.class));
- tabs.add(new ProjectPageTab(Model.of("Contributors"), Category.SOURCE, "icon-group-o", ContributorsPage.class));
+ tabs.add(new ProjectPageTab(Model.of("Code"),
+ Category.SOURCE,
+ "icon-code",
+ new Class[] { SourceTreePage.class,
+ AbstractFilePage.class }));
+
+ tabs.add(new ProjectPageTab(Model.of("Commits"),
+ Category.SOURCE,
+ "icon-commits",
+ new Class[] { CommitsPage.class,
+ SourceCommitPage.class }));
+
+ tabs.add(new ProjectPageTab(Model.of("Branches"),
+ Category.SOURCE,
+ "icon-git-branch",
+ BranchesPage.class));
+
+ tabs.add(new ProjectPageTab(Model.of("Tags"),
+ Category.SOURCE,
+ "icon-tags",
+ TagsPage.class));
+
+ tabs.add(new ProjectPageTab(Model.of("Contributors"),
+ Category.SOURCE,
+ "icon-group-o",
+ ContributorsPage.class));
// WIKI TABS
- tabs.add(new ProjectPageTab(Model.of("Wiki"), Category.WIKI, "icon-wiki", ProjectWikiPage.class));
+ tabs.add(new ProjectPageTab(Model.of("Wiki"),
+ Category.WIKI,
+ "icon-wiki",
+ ProjectWikiPage.class));
// ISSUES TABS
- tabs.add(new ProjectPageTab(Model.of("Pull Requests"), Category.ISSUES, "icon-pull-request", ProjectPullRequestsPage.class));
+ tabs.add(new ProjectPageTab(Model.of("Pull Requests"),
+ Category.ISSUES,
+ "icon-pull-request",
+ ProjectPullRequestsPage.class));
// STATISTICS TABS
- tabs.add(new ProjectPageTab(Model.of("Graphs"), Category.STATISTICS, "icon-chart-area", ProjectGraphsPage.class));
- tabs.add(new ProjectPageTab(Model.of("Forks"), Category.STATISTICS, "icon-network", ProjectForksPage.class));
+ tabs.add(new ProjectPageTab(Model.of("Graphs"),
+ Category.STATISTICS,
+ "icon-chart-area",
+ ProjectGraphsPage.class));
+
+ tabs.add(new ProjectPageTab(Model.of("Forks"),
+ Category.STATISTICS,
+ "icon-network",
+ ProjectForksPage.class));
return tabs;
}