Search in sources :

Example 1 with ExternalNavLink

use of com.gitblit.models.NavLink.ExternalNavLink in project gitblit by gitblit.

the class RepositoryPage method registerNavLinks.

private List<NavLink> registerNavLinks() {
    Repository r = getRepository();
    RepositoryModel model = getRepositoryModel();
    PageParameters params = null;
    PageParameters objectParams = null;
    if (!StringUtils.isEmpty(repositoryName)) {
        params = WicketUtils.newRepositoryParameter(getRepositoryName());
        objectParams = params;
        // preserve the objectid iff the objectid directly (or indirectly) refers to a ref
        if (isCommitPage() && !StringUtils.isEmpty(objectId)) {
            RevCommit commit = JGitUtils.getCommit(r, objectId);
            if (commit != null) {
                String bestId = getBestCommitId(commit);
                if (!commit.getName().equals(bestId)) {
                    objectParams = WicketUtils.newObjectParameter(getRepositoryName(), bestId);
                }
            }
        }
    }
    List<NavLink> navLinks = new ArrayList<NavLink>();
    // standard links
    if (RefLogUtils.getRefLogBranch(r) == null) {
        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));
        navLinks.add(new PageNavLink("gb.reflog", ReflogPage.class, params));
    }
    if (!model.hasCommits) {
        return navLinks;
    }
    navLinks.add(new PageNavLink("gb.commits", LogPage.class, objectParams));
    navLinks.add(new PageNavLink("gb.tree", TreePage.class, objectParams));
    if (app().tickets().isReady() && (app().tickets().isAcceptingNewTickets(model) || app().tickets().hasTickets(model))) {
        PageParameters tParams = WicketUtils.newOpenTicketsParameter(getRepositoryName());
        navLinks.add(new PageNavLink("gb.tickets", TicketsPage.class, tParams));
    }
    navLinks.add(new PageNavLink("gb.docs", DocsPage.class, objectParams, true));
    if (app().settings().getBoolean(Keys.web.allowForking, true)) {
        navLinks.add(new PageNavLink("gb.forks", ForksPage.class, params, true));
    }
    navLinks.add(new PageNavLink("gb.compare", ComparePage.class, params, true));
    // per-repository extra navlinks
    if (JGitUtils.getPagesBranch(r) != null) {
        ExternalNavLink pagesLink = new ExternalNavLink("gb.pages", PagesServlet.asLink(getRequest().getRelativePathPrefixToContextRoot(), getRepositoryName(), null), true);
        navLinks.add(pagesLink);
    }
    UserModel user = UserModel.ANONYMOUS;
    if (GitBlitWebSession.get().isLoggedIn()) {
        user = GitBlitWebSession.get().getUser();
    }
    // add repository nav link extensions
    List<RepositoryNavLinkExtension> extensions = app().plugins().getExtensions(RepositoryNavLinkExtension.class);
    for (RepositoryNavLinkExtension ext : extensions) {
        navLinks.addAll(ext.getNavLinks(user, model));
    }
    return navLinks;
}
Also used : ExternalNavLink(com.gitblit.models.NavLink.ExternalNavLink) ArrayList(java.util.ArrayList) RepositoryModel(com.gitblit.models.RepositoryModel) PageParameters(org.apache.wicket.PageParameters) UserModel(com.gitblit.models.UserModel) Repository(org.eclipse.jgit.lib.Repository) ExternalNavLink(com.gitblit.models.NavLink.ExternalNavLink) PageNavLink(com.gitblit.models.NavLink.PageNavLink) NavLink(com.gitblit.models.NavLink) PageNavLink(com.gitblit.models.NavLink.PageNavLink) RepositoryNavLinkExtension(com.gitblit.extensions.RepositoryNavLinkExtension) RevCommit(org.eclipse.jgit.revwalk.RevCommit)

Aggregations

RepositoryNavLinkExtension (com.gitblit.extensions.RepositoryNavLinkExtension)1 NavLink (com.gitblit.models.NavLink)1 ExternalNavLink (com.gitblit.models.NavLink.ExternalNavLink)1 PageNavLink (com.gitblit.models.NavLink.PageNavLink)1 RepositoryModel (com.gitblit.models.RepositoryModel)1 UserModel (com.gitblit.models.UserModel)1 ArrayList (java.util.ArrayList)1 PageParameters (org.apache.wicket.PageParameters)1 Repository (org.eclipse.jgit.lib.Repository)1 RevCommit (org.eclipse.jgit.revwalk.RevCommit)1