@@ -16,6 +16,7 @@ If you are updating from an earlier release AND you have indexed branches with t | |||
#### additions | |||
- delete branch feature (issue 121, Github/ajermakovics) | |||
- added line links to blob view at the expense of zebra striping (issue 130) | |||
- added RedmineUserService (github/mallowlabs) | |||
@@ -61,6 +61,9 @@ public class RefModel implements Serializable, Comparable<RefModel> { | |||
} | |||
public String getName() { | |||
if (reference == null) { | |||
return displayName; | |||
} | |||
return reference.getName(); | |||
} | |||
@@ -24,7 +24,7 @@ public class BranchesPage extends RepositoryPage { | |||
public BranchesPage(PageParameters params) { | |||
super(params); | |||
add(new BranchesPanel("branchesPanel", getRepositoryModel(), getRepository(), -1, isShowAdmin())); | |||
add(new BranchesPanel("branchesPanel", getRepositoryModel(), getRepository(), -1, isShowAdmin() || isOwner())); | |||
} | |||
@Override |
@@ -76,7 +76,8 @@ public abstract class RepositoryPage extends BasePage { | |||
private final Map<String, PageRegistration> registeredPages; | |||
private boolean showAdmin; | |||
private boolean isOwner; | |||
public RepositoryPage(PageParameters params) { | |||
super(params); | |||
repositoryName = WicketUtils.getRepositoryName(params); | |||
@@ -149,17 +150,17 @@ public abstract class RepositoryPage extends BasePage { | |||
} | |||
// Conditionally add edit link | |||
this.showAdmin = false; | |||
showAdmin = false; | |||
if (GitBlit.getBoolean(Keys.web.authenticateAdminPages, true)) { | |||
boolean allowAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, false); | |||
showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin(); | |||
} else { | |||
showAdmin = GitBlit.getBoolean(Keys.web.allowAdministration, false); | |||
} | |||
if (showAdmin | |||
|| GitBlitWebSession.get().isLoggedIn() | |||
isOwner = GitBlitWebSession.get().isLoggedIn() | |||
&& (model.owner != null && model.owner.equalsIgnoreCase(GitBlitWebSession.get() | |||
.getUsername()))) { | |||
.getUsername())); | |||
if (showAdmin || isOwner) { | |||
pages.put("edit", new PageRegistration("gb.edit", EditRepositoryPage.class, params)); | |||
} | |||
return pages; | |||
@@ -413,9 +414,12 @@ public abstract class RepositoryPage extends BasePage { | |||
return WicketUtils.newObjectParameter(repositoryName, commitId); | |||
} | |||
public boolean isShowAdmin() | |||
{ | |||
return this.showAdmin; | |||
public boolean isShowAdmin() { | |||
return showAdmin; | |||
} | |||
public boolean isOwner() { | |||
return isOwner; | |||
} | |||
private class SearchForm extends SessionlessForm<Void> implements Serializable { |
@@ -132,7 +132,7 @@ public class SummaryPage extends RepositoryPage { | |||
add(new LogPanel("commitsPanel", repositoryName, getRepositoryModel().HEAD, r, numberCommits, 0)); | |||
add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs).hideIfEmpty()); | |||
add(new BranchesPanel("branchesPanel", getRepositoryModel(), r, numberRefs, isShowAdmin()).hideIfEmpty()); | |||
add(new BranchesPanel("branchesPanel", getRepositoryModel(), r, numberRefs, false).hideIfEmpty()); | |||
if (getRepositoryModel().showReadme) { | |||
String htmlText = null; |
@@ -28,6 +28,13 @@ | |||
<!-- 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> | <a wicket:id="syndication"><wicket:message key="gb.feed"></wicket:message></a> | |||
</span> | |||
</wicket:fragment> | |||
<!-- branch page admin links --> | |||
<wicket:fragment wicket:id="branchPageAdminLinks"> | |||
<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> | <a wicket:id="syndication"><wicket:message key="gb.feed"></wicket:message></a> | <a wicket:id="deleteBranch"><wicket:message key="gb.delete"></wicket:message></a> | |||
</span> |
@@ -32,6 +32,7 @@ import org.apache.wicket.model.StringResourceModel; | |||
import org.eclipse.jgit.lib.Repository; | |||
import com.gitblit.Constants; | |||
import com.gitblit.GitBlit; | |||
import com.gitblit.SyndicationServlet; | |||
import com.gitblit.models.RefModel; | |||
import com.gitblit.models.RepositoryModel; | |||
@@ -51,7 +52,7 @@ public class BranchesPanel extends BasePanel { | |||
private final boolean hasBranches; | |||
public BranchesPanel(String wicketId, final RepositoryModel model, final Repository r, | |||
public BranchesPanel(String wicketId, final RepositoryModel model, Repository r, | |||
final int maxCount, final boolean showAdmin) { | |||
super(wicketId); | |||
@@ -76,7 +77,10 @@ public class BranchesPanel extends BasePanel { | |||
// branches page | |||
add(new Label("branches", new StringResourceModel("gb.branches", this, null))); | |||
} | |||
// only allow delete if we have multiple branches | |||
final boolean showDelete = showAdmin && branches.size() > 1; | |||
ListDataProvider<RefModel> branchesDp = new ListDataProvider<RefModel>(branches); | |||
DataView<RefModel> branchesView = new DataView<RefModel>("branch", branchesDp) { | |||
private static final long serialVersionUID = 1L; | |||
@@ -110,7 +114,7 @@ public class BranchesPanel extends BasePanel { | |||
item.add(shortlog); | |||
if (maxCount <= 0) { | |||
Fragment fragment = new Fragment("branchLinks", "branchPageLinks", this); | |||
Fragment fragment = new Fragment("branchLinks", showDelete? "branchPageAdminLinks" : "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 | |||
@@ -120,9 +124,9 @@ public class BranchesPanel extends BasePanel { | |||
fragment.add(new ExternalLink("syndication", SyndicationServlet.asLink( | |||
getRequest().getRelativePathPrefixToContextRoot(), model.name, | |||
entry.getName(), 0))); | |||
fragment.add(createDeleteBranchLink(r, entry, showAdmin)); | |||
if (showDelete) { | |||
fragment.add(createDeleteBranchLink(model, entry)); | |||
} | |||
item.add(fragment); | |||
} else { | |||
Fragment fragment = new Fragment("branchLinks", "branchPanelLinks", this); | |||
@@ -154,15 +158,20 @@ public class BranchesPanel extends BasePanel { | |||
return this; | |||
} | |||
private Link<Void> createDeleteBranchLink(final Repository r, final RefModel entry, final boolean showAdmin) | |||
private Link<Void> createDeleteBranchLink(final RepositoryModel repositoryModel, final RefModel entry) | |||
{ | |||
Link<Void> deleteLink = new Link<Void>("deleteBranch") { | |||
private static final long serialVersionUID = 1L; | |||
@Override | |||
public void onClick() { | |||
if( showAdmin && JGitUtils.deleteBranchRef(r, entry.getName()) ) { | |||
Repository r = GitBlit.self().getRepository(repositoryModel.name); | |||
boolean success = JGitUtils.deleteBranchRef(r, entry.getName()); | |||
r.close(); | |||
if (success) { | |||
info(MessageFormat.format("Branch \"{0}\" deleted", entry.displayName)); | |||
// redirect to the owning page | |||
setResponsePage(getPage().getClass(), WicketUtils.newRepositoryParameter(repositoryModel.name)); | |||
} | |||
else { | |||
error(MessageFormat.format("Failed to delete branch \"{0}\"", entry.displayName)); | |||
@@ -172,9 +181,6 @@ public class BranchesPanel extends BasePanel { | |||
deleteLink.add(new JavascriptEventConfirmation("onclick", MessageFormat.format( | |||
"Delete branch \"{0}\"?", entry.displayName ))); | |||
deleteLink.setVisible(showAdmin); | |||
return deleteLink; | |||
} | |||
} |