name = name.substring(projectName.length() + 1);
}
add(new LinkPanel("repositoryName", null, name, SummaryPage.class,
WicketUtils.newRepositoryParameter(repositoryName)));
UserModel user = GitBlitWebSession.get().getUser();
if (user == null) {
user = UserModel.ANONYMOUS;
}
// indicate origin repository
RepositoryModel model = getRepositoryModel();
if (StringUtils.isEmpty(model.originRepository)) {
if (model.isMirror) {
Fragment mirrorFrag = new Fragment("originRepository", "mirrorFragment", this);
Label lbl = new Label("originRepository", MessageFormat.format(getString("gb.mirrorOf"), "<b>" + model.origin + "</b>"));
mirrorFrag.add(lbl.setEscapeModelStrings(false));
add(mirrorFrag);
} else {
add(new Label("originRepository").setVisible(false));
}
} else {
RepositoryModel origin = app().repositories().getRepositoryModel(model.originRepository);
if (origin == null) {
// no origin repository
add(new Label("originRepository").setVisible(false));
} else if (!user.canView(origin)) {
// show origin repository without link
Fragment forkFrag = new Fragment("originRepository", "originFragment", this);
forkFrag.add(new Label("originRepository", StringUtils.stripDotGit(model.originRepository)));
add(forkFrag);
} else {
// link to origin repository
Fragment forkFrag = new Fragment("originRepository", "originFragment", this);
forkFrag.add(new LinkPanel("originRepository", null, StringUtils.stripDotGit(model.originRepository),
SummaryPage.class, WicketUtils.newRepositoryParameter(model.originRepository)));
add(forkFrag);
}
}
// new ticket button
if (user.isAuthenticated && app().tickets().isAcceptingNewTickets(getRepositoryModel())) {
String newTicketUrl = getRequestCycle().urlFor(NewTicketPage.class, WicketUtils.newRepositoryParameter(repositoryName)).toString();
addToolbarButton("newTicketLink", "fa fa-ticket", getString("gb.new"), newTicketUrl);
} else {
add(new Label("newTicketLink").setVisible(false));
}
// (un)star link allows a user to star a repository
if (user.isAuthenticated) {
PageParameters starParams = DeepCopier.copy(getPageParameters());
starParams.put(PARAM_STAR, !user.getPreferences().isStarredRepository(model.name));
String toggleStarUrl = getRequestCycle().urlFor(getClass(), starParams).toString();
if (user.getPreferences().isStarredRepository(model.name)) {
// show unstar button
add(new Label("starLink").setVisible(false));
addToolbarButton("unstarLink", "icon-star-empty", getString("gb.unstar"), toggleStarUrl);
} else {
// show star button
addToolbarButton("starLink", "icon-star", getString("gb.star"), toggleStarUrl);
add(new Label("unstarLink").setVisible(false));
}
} else {
// anonymous user
add(new Label("starLink").setVisible(false));
add(new Label("unstarLink").setVisible(false));
}
// fork controls
if (!allowForkControls() || !user.isAuthenticated) {
// must be logged-in to fork, hide all fork controls
add(new ExternalLink("forkLink", "").setVisible(false));
add(new ExternalLink("myForkLink", "").setVisible(false));
} else {
String fork = app().repositories().getFork(user.username, model.name);
boolean hasFork = fork != null;
boolean canFork = user.canFork(model);
if (hasFork || !canFork) {
// user not allowed to fork or fork already exists or repo forbids forking
add(new ExternalLink("forkLink", "").setVisible(false));