| | |
| | | // grab primary url from the top of the list
|
| | | primaryUrl = repositoryUrls.size() == 0 ? null : repositoryUrls.get(0);
|
| | |
|
| | | boolean canClone = ((primaryUrl.permission == null) || primaryUrl.permission.atLeast(AccessPermission.CLONE));
|
| | | boolean canClone = primaryUrl != null && ((primaryUrl.permission == null) || primaryUrl.permission.atLeast(AccessPermission.CLONE));
|
| | |
|
| | | if (repositoryUrls.size() == 0 || !canClone) {
|
| | | // no urls, nothing to show.
|
| | | add(new Label("repositoryUrlPanel").setVisible(false));
|
| | | add(new Label("applicationMenusPanel").setVisible(false));
|
| | | add(new Label("repositoryIndicators").setVisible(false));
|
| | | return;
|
| | | }
|
| | |
|
| | | // display primary url
|
| | | add(createPrimaryUrlPanel("repositoryUrlPanel", repository, repositoryUrls));
|
| | |
|
| | | if (onlyUrls) {
|
| | | add(new Label("repositoryIndicators").setVisible(false));
|
| | | } else {
|
| | | add(createRepositoryIndicators(repository));
|
| | | }
|
| | |
|
| | | boolean allowAppLinks = GitBlit.getBoolean(Keys.web.allowAppCloneLinks, true);
|
| | | if (onlyUrls || !canClone || !allowAppLinks) {
|
| | |
| | | }
|
| | |
|
| | | // access restriction icon and tooltip
|
| | | if (isGitblitServingRepositories()) {
|
| | | if (GitBlit.isServingRepositories()) {
|
| | | switch (repository.accessRestriction) {
|
| | | case NONE:
|
| | | urlPanel.add(WicketUtils.newClearPixel("accessRestrictionIcon").setVisible(false));
|
| | |
| | | final GitClientApplication clientApp = item.getModelObject();
|
| | |
|
| | | // filter the urls for the client app
|
| | | List<RepositoryUrl> urls;
|
| | | if (clientApp.minimumPermission == null) {
|
| | | // client app does not specify minimum access permission
|
| | | urls = repositoryUrls;
|
| | | } else {
|
| | | urls = new ArrayList<RepositoryUrl>();
|
| | | for (RepositoryUrl repoUrl : repositoryUrls) {
|
| | | if (repoUrl.permission == null) {
|
| | | // external permissions, assume it is satisfactory
|
| | | List<RepositoryUrl> urls = new ArrayList<RepositoryUrl>();
|
| | | for (RepositoryUrl repoUrl : repositoryUrls) {
|
| | | if (clientApp.minimumPermission == null || repoUrl.permission == null) {
|
| | | // no minimum permission or external permissions, assume it is satisfactory
|
| | | if (clientApp.supportsTransport(repoUrl.url)) {
|
| | | urls.add(repoUrl);
|
| | | } else if (repoUrl.permission.atLeast(clientApp.minimumPermission)) {
|
| | | // repo url meets minimum permission requirement
|
| | | }
|
| | | } else if (repoUrl.permission.atLeast(clientApp.minimumPermission)) {
|
| | | // repo url meets minimum permission requirement
|
| | | if (clientApp.supportsTransport(repoUrl.url)) {
|
| | | urls.add(repoUrl);
|
| | | }
|
| | | }
|
| | |
| | | return pattern.replace("${repoUrl}", repoUrl).replace("${baseUrl}", baseUrl);
|
| | | }
|
| | |
|
| | | protected boolean isGitblitServingRepositories() {
|
| | | return GitBlit.getBoolean(Keys.git.enableGitServlet, true) || (GitBlit.getInteger(Keys.git.daemonPort, 0) > 0);
|
| | | }
|
| | | |
| | | protected Label createPermissionBadge(String wicketId, RepositoryUrl repoUrl) {
|
| | | Label permissionLabel = new Label(wicketId, repoUrl.isExternal() ? externalPermission : repoUrl.permission.toString());
|
| | | WicketUtils.setPermissionClass(permissionLabel, repoUrl.permission);
|
| | |
| | | }
|
| | | return accessRestrictionsMap;
|
| | | }
|
| | | |
| | | protected Component createRepositoryIndicators(RepositoryModel repository) {
|
| | | Fragment fragment = new Fragment("repositoryIndicators", "indicatorsFragment", this);
|
| | | if (repository.isBare) {
|
| | | fragment.add(new Label("workingCopyIndicator").setVisible(false));
|
| | | } else {
|
| | | Fragment wc = new Fragment("workingCopyIndicator", "workingCopyFragment", this);
|
| | | Label lbl = new Label("workingCopy", getString("gb.workingCopy"));
|
| | | WicketUtils.setHtmlTooltip(lbl, getString("gb.workingCopyWarning"));
|
| | | wc.add(lbl);
|
| | | fragment.add(wc);
|
| | | }
|
| | | |
| | | boolean allowForking = GitBlit.getBoolean(Keys.web.allowForking, true);
|
| | | if (!allowForking || user == null || !user.isAuthenticated) {
|
| | | // must be logged-in to fork, hide all fork controls
|
| | | fragment.add(new Label("forksProhibitedIndicator").setVisible(false));
|
| | | } else {
|
| | | String fork = GitBlit.self().getFork(user.username, repository.name);
|
| | | boolean hasFork = fork != null;
|
| | | boolean canFork = user.canFork(repository);
|
| | |
|
| | | if (hasFork || !canFork) {
|
| | | if (user.canFork() && !repository.allowForks) {
|
| | | // show forks prohibited indicator
|
| | | Fragment wc = new Fragment("forksProhibitedIndicator", "forksProhibitedFragment", this);
|
| | | Label lbl = new Label("forksProhibited", getString("gb.forksProhibited"));
|
| | | WicketUtils.setHtmlTooltip(lbl, getString("gb.forksProhibitedWarning"));
|
| | | wc.add(lbl);
|
| | | fragment.add(wc);
|
| | | } else {
|
| | | // can not fork, no need for forks prohibited indicator
|
| | | fragment.add(new Label("forksProhibitedIndicator").setVisible(false));
|
| | | }
|
| | | } else if (canFork) {
|
| | | // can fork and we do not have one
|
| | | fragment.add(new Label("forksProhibitedIndicator").setVisible(false));
|
| | | }
|
| | | }
|
| | | return fragment;
|
| | | }
|
| | | }
|