summaryrefslogtreecommitdiffstats
path: root/src/com/gitblit/wicket/panels
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/gitblit/wicket/panels')
-rw-r--r--src/com/gitblit/wicket/panels/BranchesPanel.html20
-rw-r--r--src/com/gitblit/wicket/panels/BranchesPanel.java33
-rw-r--r--src/com/gitblit/wicket/panels/RefsPanel.java8
-rw-r--r--src/com/gitblit/wicket/panels/TagsPanel.java9
4 files changed, 57 insertions, 13 deletions
diff --git a/src/com/gitblit/wicket/panels/BranchesPanel.html b/src/com/gitblit/wicket/panels/BranchesPanel.html
index 497003a5..91c34d2d 100644
--- a/src/com/gitblit/wicket/panels/BranchesPanel.html
+++ b/src/com/gitblit/wicket/panels/BranchesPanel.html
@@ -17,16 +17,28 @@
<td><span wicket:id="branchName">[branch name]</span></td>
<td><span wicket:id="branchType">[branch type]</span></td>
<td class="rightAlign">
- <span class="link">
- <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a> | <a wicket:id="tree"><wicket:message key="gb.tree"></wicket:message></a>
- </span>
+ <span wicket:id="branchLinks"></span>
</td>
</tr>
</tbody>
</table>
<div wicket:id="allBranches">[all branches]</div>
-
+
+ <!-- branch page links -->
+ <wicket:fragment wicket:id="branchPageLinks">
+ <span class="link">
+ <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a> | <a wicket:id="tree"><wicket:message key="gb.tree"></wicket:message></a> | <a wicket:id="metrics"><wicket:message key="gb.metrics"></wicket:message></a>
+ </span>
+ </wicket:fragment>
+
+ <!-- branch panel links -->
+ <wicket:fragment wicket:id="branchPanelLinks">
+ <span class="link">
+ <a wicket:id="log"><wicket:message key="gb.log"></wicket:message></a> | <a wicket:id="tree"><wicket:message key="gb.tree"></wicket:message></a>
+ </span>
+ </wicket:fragment>
+
</wicket:panel>
</body>
</html> \ No newline at end of file
diff --git a/src/com/gitblit/wicket/panels/BranchesPanel.java b/src/com/gitblit/wicket/panels/BranchesPanel.java
index 82f8a045..b11c03ab 100644
--- a/src/com/gitblit/wicket/panels/BranchesPanel.java
+++ b/src/com/gitblit/wicket/panels/BranchesPanel.java
@@ -21,6 +21,7 @@ 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.panel.Fragment;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.markup.repeater.data.DataView;
import org.apache.wicket.markup.repeater.data.ListDataProvider;
@@ -35,6 +36,7 @@ import com.gitblit.utils.StringUtils;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.pages.BranchesPage;
import com.gitblit.wicket.pages.LogPage;
+import com.gitblit.wicket.pages.MetricsPage;
import com.gitblit.wicket.pages.SummaryPage;
import com.gitblit.wicket.pages.TreePage;
@@ -42,6 +44,8 @@ public class BranchesPanel extends BasePanel {
private static final long serialVersionUID = 1L;
+ private final boolean hasBranches;
+
public BranchesPanel(String wicketId, final RepositoryModel model, Repository r,
final int maxCount) {
super(wicketId);
@@ -89,11 +93,23 @@ public class BranchesPanel extends BasePanel {
item.add(new Label("branchType", remote ? getString("gb.remote")
: getString("gb.local")).setVisible(maxCount <= 0));
- item.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils
- .newObjectParameter(model.name, entry.getName())));
- item.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils
- .newObjectParameter(model.name, entry.getName())));
-
+ if (maxCount <= 0) {
+ Fragment fragment = new Fragment("branchLinks", "branchPageLinks", this);
+ fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils
+ .newObjectParameter(model.name, entry.getName())));
+ fragment.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils
+ .newObjectParameter(model.name, entry.getName())));
+ fragment.add(new BookmarkablePageLink<Void>("metrics", MetricsPage.class,
+ WicketUtils.newObjectParameter(model.name, entry.getName())));
+ item.add(fragment);
+ } else {
+ Fragment fragment = new Fragment("branchLinks", "branchPanelLinks", this);
+ fragment.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils
+ .newObjectParameter(model.name, entry.getName())));
+ fragment.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils
+ .newObjectParameter(model.name, entry.getName())));
+ item.add(fragment);
+ }
WicketUtils.setAlternatingBackground(item, counter);
counter++;
}
@@ -105,5 +121,12 @@ public class BranchesPanel extends BasePanel {
add(new LinkPanel("allBranches", "link", new StringResourceModel("gb.allBranches",
this, null), BranchesPage.class, WicketUtils.newRepositoryParameter(model.name)));
}
+ // We always have 1 branch
+ hasBranches = branches.size() > 1;
+ }
+
+ public BranchesPanel hideIfEmpty() {
+ setVisible(hasBranches);
+ return this;
}
}
diff --git a/src/com/gitblit/wicket/panels/RefsPanel.java b/src/com/gitblit/wicket/panels/RefsPanel.java
index 8cf137b1..f25b53b2 100644
--- a/src/com/gitblit/wicket/panels/RefsPanel.java
+++ b/src/com/gitblit/wicket/panels/RefsPanel.java
@@ -70,19 +70,19 @@ public class RefsPanel extends Panel {
Class<? extends RepositoryPage> linkClass = CommitPage.class;
String cssClass = "";
if (name.startsWith(Constants.R_HEADS)) {
- // local head
+ // local branch
linkClass = LogPage.class;
name = name.substring(Constants.R_HEADS.length());
- cssClass = "headRef";
+ cssClass = "localBranch";
} else if (name.equals(Constants.HEAD)) {
// local head
linkClass = LogPage.class;
cssClass = "headRef";
} else if (name.startsWith(Constants.R_REMOTES)) {
- // remote head
+ // remote branch
linkClass = LogPage.class;
name = name.substring(Constants.R_REMOTES.length());
- cssClass = "remoteRef";
+ cssClass = "remoteBranch";
} else if (name.startsWith(Constants.R_TAGS)) {
// tag
if (entry.isAnnotatedTag()) {
diff --git a/src/com/gitblit/wicket/panels/TagsPanel.java b/src/com/gitblit/wicket/panels/TagsPanel.java
index f6dd762b..4504c511 100644
--- a/src/com/gitblit/wicket/panels/TagsPanel.java
+++ b/src/com/gitblit/wicket/panels/TagsPanel.java
@@ -44,6 +44,8 @@ import com.gitblit.wicket.pages.TreePage;
public class TagsPanel extends BasePanel {
private static final long serialVersionUID = 1L;
+
+ private final boolean hasTags;
public TagsPanel(String wicketId, final String repositoryName, Repository r, final int maxCount) {
super(wicketId);
@@ -162,5 +164,12 @@ public class TagsPanel extends BasePanel {
add(new LinkPanel("allTags", "link", new StringResourceModel("gb.allTags", this, null),
TagsPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
}
+
+ hasTags = tags.size() > 0;
+ }
+
+ public TagsPanel hideIfEmpty() {
+ setVisible(hasTags);
+ return this;
}
}