Skip to content

The Unified and Autonomous Development Platform

Make various file actions visible instead of hiding under a dropdown menu

robin shine2866fcb8385d
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/CodeCommentToggled.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentToggled.java
similarity index 80%
rename from gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/CodeCommentToggled.java
rename to gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentToggled.java
index aa5c7d4251..c20c6baa4b 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/CodeCommentToggled.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/comment/CodeCommentToggled.java
@@ -1,4 +1,4 @@
-package com.pmease.gitplex.web.component.diff.revision;
+package com.pmease.gitplex.web.component.comment;
import org.apache.wicket.ajax.AjaxRequestTarget;
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewContext.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewContext.java
index 5537f6b521..2d01d9936b 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewContext.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewContext.java
@@ -10,8 +10,6 @@ import org.eclipse.jgit.revwalk.RevCommit;
import com.pmease.commons.git.BlobIdent;
import com.pmease.commons.lang.extractors.TokenPosition;
-import com.pmease.commons.wicket.component.menu.MenuItem;
-import com.pmease.commons.wicket.component.menu.MenuLink;
import com.pmease.gitplex.core.entity.CodeComment;
import com.pmease.gitplex.core.entity.Depot;
import com.pmease.gitplex.core.entity.PullRequest;
@@ -40,6 +38,8 @@ public interface BlobViewContext extends Serializable {
boolean isOnBranch();
+ boolean isOnCommentBranch();
+
void onSelect(AjaxRequestTarget target, BlobIdent blobIdent, @Nullable TokenPosition tokenPos);
void onSearchComplete(AjaxRequestTarget target, List<QueryHit> hits);
@@ -62,6 +62,4 @@ public interface BlobViewContext extends Serializable {
RevCommit getCommit();
- List<MenuItem> getMenuItems(MenuLink menuLink);
-
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewPanel.html
index 4fd137ef2e..be021d425f 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewPanel.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewPanel.html
@@ -1,6 +1,20 @@
<wicket:panel>
<div class="blob-view autofit">
- <div class="content">
+ <div class="head clearfix">
+ <div class="pull-left formats">
+ </div>
+ <div class="pull-right actions">
+ <div class="btn-group">
+ <a wicket:id="raw" class="btn btn-default btn-xs"><i class="fa fa-file-o"></i> Raw</a>
+ <wicket:container wicket:id="additionalActions"></wicket:container>
+ </div>
+ <div wicket:id="changeActions" class="btn-group">
+ <a wicket:id="edit" class="btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
+ <a wicket:id="delete" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</a>
+ </div>
+ </div>
+ </div>
+ <div class="body scrollable">
<wicket:child></wicket:child>
</div>
</div>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewPanel.java
index 2b49590513..3ade1c564c 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/BlobViewPanel.java
@@ -1,17 +1,38 @@
package com.pmease.gitplex.web.component.depotfile.blobview;
-import java.util.ArrayList;
-import java.util.List;
+import javax.annotation.Nullable;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
+import org.apache.wicket.ajax.markup.html.AjaxLink;
+import org.apache.wicket.behavior.AttributeAppender;
+import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;
+import org.apache.wicket.event.IEvent;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+import org.apache.wicket.markup.html.link.Link;
+import org.apache.wicket.markup.html.link.ResourceLink;
import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.request.cycle.RequestCycle;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
import com.google.common.base.Preconditions;
import com.pmease.commons.git.BlobIdent;
-import com.pmease.commons.wicket.component.menu.MenuItem;
-import com.pmease.commons.wicket.component.menu.MenuLink;
+import com.pmease.commons.git.GitUtils;
+import com.pmease.commons.wicket.ajaxlistener.ConfirmLeaveListener;
+import com.pmease.commons.wicket.component.PreventDefaultAjaxLink;
+import com.pmease.commons.wicket.component.ViewStateAwareAjaxLink;
+import com.pmease.gitplex.core.entity.CodeComment;
+import com.pmease.gitplex.core.entity.PullRequest;
+import com.pmease.gitplex.core.security.SecurityUtils;
+import com.pmease.gitplex.web.component.comment.CodeCommentToggled;
+import com.pmease.gitplex.web.component.depotfile.blobview.BlobViewContext.Mode;
+import com.pmease.gitplex.web.page.depot.file.DepotFilePage;
+import com.pmease.gitplex.web.resource.BlobResource;
+import com.pmease.gitplex.web.resource.BlobResourceReference;
@SuppressWarnings("serial")
public abstract class BlobViewPanel extends Panel {
@@ -28,17 +49,116 @@ public abstract class BlobViewPanel extends Panel {
this.context = context;
}
+ @Override
+ public void onEvent(IEvent<?> event) {
+ super.onEvent(event);
+
+ if (event.getPayload() instanceof CodeCommentToggled) {
+ CodeCommentToggled codeCommentToggled = (CodeCommentToggled) event.getPayload();
+ newChangeActions(codeCommentToggled.getPartialPageRequestHandler());
+ }
+ }
+
+ protected WebMarkupContainer newAdditionalActions(String id) {
+ return new WebMarkupContainer(id);
+ }
+
+ private void newChangeActions(@Nullable IPartialPageRequestHandler target) {
+ WebMarkupContainer changeActions = new WebMarkupContainer("changeActions");
+ CodeComment comment = context.getOpenComment();
+ changeActions.setVisible(SecurityUtils.canModify(context.getDepot(), context.getBlobIdent().revision, context.getBlobIdent().path)
+ && (context.isOnBranch() || context.isOnCommentBranch()));
+ changeActions.setOutputMarkupId(true);
+
+ if (context.getDepot().getBlob(context.getBlobIdent()).getText() != null) {
+ if (context.isOnBranch()) {
+ AjaxLink<Void> link = new ViewStateAwareAjaxLink<Void>("edit") {
+
+ @Override
+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
+ super.updateAjaxAttributes(attributes);
+ attributes.getAjaxCallListeners().add(new ConfirmLeaveListener());
+ }
+
+ @Override
+ public void onClick(AjaxRequestTarget target, String viewState) {
+ RequestCycle.get().setMetaData(DepotFilePage.VIEW_STATE_KEY, viewState);
+ context.onEdit(target);
+ }
+ };
+ link.add(AttributeAppender.append("title", "Edit on branch " + context.getBlobIdent().revision));
+ changeActions.add(link);
+ } else if (context.isOnCommentBranch()) {
+ PageParameters params;
+ DepotFilePage.State state = new DepotFilePage.State();
+ state.blobIdent.revision = GitUtils.ref2branch(context.getOpenComment().getBranchRef());
+ state.blobIdent.path = context.getBlobIdent().path;
+ state.commentId = comment.getId();
+ state.requestId = PullRequest.idOf(context.getPullRequest());
+ state.mode = Mode.EDIT;
+ params = DepotFilePage.paramsOf(context.getDepot(), state);
+ Link<Void> link = new BookmarkablePageLink<Void>("edit", DepotFilePage.class, params);
+ link.add(AttributeAppender.append("title", "Edit on branch " + state.blobIdent.revision));
+ changeActions.add(link);
+ } else {
+ changeActions.add(new WebMarkupContainer("edit").setVisible(false));
+ }
+ } else {
+ changeActions.add(new WebMarkupContainer("edit").setVisible(false));
+ }
+
+ if (context.isOnBranch()) {
+ AjaxLink<Void> link = new PreventDefaultAjaxLink<Void>("delete") {
+
+ @Override
+ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
+ super.updateAjaxAttributes(attributes);
+ attributes.getAjaxCallListeners().add(new ConfirmLeaveListener());
+ }
+
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ context.onDelete(target);
+ }
+
+ };
+ link.add(AttributeAppender.append("title", "Delete from branch " + context.getBlobIdent().revision));
+ changeActions.add(link);
+ } else if (context.isOnCommentBranch()) {
+ DepotFilePage.State state = new DepotFilePage.State();
+ state.blobIdent.revision = GitUtils.ref2branch(context.getOpenComment().getBranchRef());
+ state.blobIdent.path = context.getBlobIdent().path;
+ state.commentId = comment.getId();
+ state.requestId = PullRequest.idOf(context.getPullRequest());
+ state.mode = Mode.DELETE;
+ PageParameters params = DepotFilePage.paramsOf(context.getDepot(), state);
+ Link<Void> link = new BookmarkablePageLink<Void>("delete", DepotFilePage.class, params);
+ link.add(AttributeAppender.append("title", "Delete from branch " + state.blobIdent.revision));
+ changeActions.add(link);
+ } else {
+ changeActions.add(new WebMarkupContainer("delete").setVisible(false));
+ }
+
+ if (target != null) {
+ replace(changeActions);
+ target.add(changeActions);
+ } else {
+ add(changeActions);
+ }
+ }
+
@Override
protected void onInitialize() {
super.onInitialize();
+ add(new ResourceLink<Void>("raw", new BlobResourceReference(),
+ BlobResource.paramsOf(context.getDepot(), context.getBlobIdent())));
+ add(newAdditionalActions("additionalActions"));
+ newChangeActions(null);
+
setOutputMarkupId(true);
}
- public List<MenuItem> getMenuItems(MenuLink menuLink) {
- return new ArrayList<>();
- }
-
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/blob-view.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/blob-view.css
index 7c3dfd0188..79d60ab7a4 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/blob-view.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/blob-view.css
@@ -1,3 +1,11 @@
-.blob-view>.content {
+.blob-view>.body {
overflow: auto;
}
+.blob-view>.head {
+ border-bottom: 1px solid #BBB;
+ padding: 6px 12px;
+ height: 36px;
+}
+.blob-view>.head>.actions>.btn-group:FIRST-CHILD {
+ margin-right: 4px;
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/blob-view.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/blob-view.js
index 8df2fbdfd8..efcbc1afa4 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/blob-view.js
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/blob-view.js
@@ -1,11 +1,12 @@
gitplex.blobView = function(containerId) {
var $blobView = $("#" + containerId + ">.blob-view");
- var $content = $blobView.find(">.content");
+ var $head = $blobView.find(">.head");
+ var $body = $blobView.find(">.body");
$blobView.on("storeViewState", function(e) {
e.stopPropagation();
- pmease.commons.history.setViewState({scroll:{left: $content.scrollLeft(), top: $content.scrollTop()}});
- $content.find(".autofit:visible").first().trigger("storeViewState");
+ pmease.commons.history.setViewState({scroll:{left: $body.scrollLeft(), top: $body.scrollTop()}});
+ $body.find(".autofit:visible").first().trigger("storeViewState");
});
$blobView.on("autofit", function(e, width, height) {
@@ -13,14 +14,15 @@ gitplex.blobView = function(containerId) {
$blobView.outerWidth(width);
$blobView.outerHeight(height);
- height = $blobView.height();
- $content.outerWidth(width).outerHeight(height);
- $content.find(".autofit:visible").first().trigger("autofit", [$content.width(), $content.height()]);
+ console.log($head.outerHeight());
+ height = $blobView.height()-$head.outerHeight();
+ $body.outerWidth(width).outerHeight(height);
+ $body.find(".autofit:visible").first().trigger("autofit", [$body.width(), $body.height()]);
var viewState = pmease.commons.history.getViewState();
if (viewState && viewState.scroll) {
- $content.scrollLeft(viewState.scroll.left);
- $content.scrollTop(viewState.scroll.top);
+ $body.scrollLeft(viewState.scroll.left);
+ $body.scrollTop(viewState.scroll.top);
}
});
};
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/markdown/MarkdownFilePanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/markdown/MarkdownFilePanel.html
index 189969803c..2e6c909ebf 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/markdown/MarkdownFilePanel.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/markdown/MarkdownFilePanel.html
@@ -2,4 +2,7 @@
<div class="markdown-file">
<div wicket:id="markdown"></div>
</div>
+ <wicket:fragment wicket:id="actionsFrag">
+ <a wicket:id="blame" class="btn btn-default btn-xs blame-toggle"><i class="fa fa-user"></i> Blame</a>
+ </wicket:fragment>
</wicket:extend>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/markdown/MarkdownFilePanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/markdown/MarkdownFilePanel.java
index f7d404328f..db6d0fdf82 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/markdown/MarkdownFilePanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/markdown/MarkdownFilePanel.java
@@ -1,27 +1,17 @@
package com.pmease.gitplex.web.component.depotfile.blobview.markdown;
-import java.util.ArrayList;
-import java.util.List;
-
import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
-import org.apache.wicket.markup.html.link.AbstractLink;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.model.Model;
-import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.request.mapper.parameter.PageParameters;
import com.pmease.commons.git.Blob;
-import com.pmease.commons.wicket.behavior.ViewStateAwareBehavior;
import com.pmease.commons.wicket.component.PreventDefaultAjaxLink;
import com.pmease.commons.wicket.component.markdown.MarkdownPanel;
-import com.pmease.commons.wicket.component.menu.MenuItem;
-import com.pmease.commons.wicket.component.menu.MenuLink;
import com.pmease.gitplex.web.component.depotfile.blobview.BlobViewContext;
-import com.pmease.gitplex.web.component.depotfile.blobview.BlobViewContext.Mode;
import com.pmease.gitplex.web.component.depotfile.blobview.BlobViewPanel;
-import com.pmease.gitplex.web.page.depot.file.DepotFilePage;
@SuppressWarnings("serial")
public class MarkdownFilePanel extends BlobViewPanel {
@@ -37,51 +27,22 @@ public class MarkdownFilePanel extends BlobViewPanel {
Blob blob = context.getDepot().getBlob(context.getBlobIdent());
add(new MarkdownPanel("markdown", Model.of(blob.getText().getContent()), null));
}
-
+
@Override
- public List<MenuItem> getMenuItems(MenuLink menuLink) {
- List<MenuItem> menuItems = new ArrayList<>();
- menuItems.add(new MenuItem() {
-
- @Override
- public String getIconClass() {
- return context.getMode() == Mode.BLAME?"fa fa-check":null;
- }
+ protected WebMarkupContainer newAdditionalActions(String id) {
+ WebMarkupContainer actions = new Fragment(id, "actionsFrag", this);
+ actions.add(new PreventDefaultAjaxLink<Void>("blame") {
@Override
- public String getLabel() {
- return "Blame";
- }
-
- @Override
- public AbstractLink newLink(String id) {
- AbstractLink link = new PreventDefaultAjaxLink<Void>(id) {
-
- @Override
- public void onClick(AjaxRequestTarget target) {
- menuLink.close();
- context.onBlameChange(target, true);
- }
-
- };
- PageParameters params;
- DepotFilePage.State state = new DepotFilePage.State();
- state.blobIdent = context.getBlobIdent();
- if (context.getMode() != Mode.BLAME)
- state.mode = Mode.BLAME;
- state.mark = context.getMark();
- params = DepotFilePage.paramsOf(context.getDepot(), state);
- CharSequence url = RequestCycle.get().urlFor(DepotFilePage.class, params);
- link.add(AttributeAppender.replace("href", url.toString()));
- link.add(new ViewStateAwareBehavior());
- return link;
+ public void onClick(AjaxRequestTarget target) {
+ context.onBlameChange(target, true);
}
});
- return menuItems;
+ return actions;
}
-
+
@Override
public void renderHead(IHeaderResponse response) {
super.renderHead(response);
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.html
index 8e95ef9a8e..8d2e79582b 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.html
@@ -41,4 +41,8 @@
</div>
</form>
</wicket:fragment>
+ <wicket:fragment wicket:id="actionsFrag">
+ <a wicket:id="blame" class="btn btn-default btn-xs blame-toggle"><i class="fa fa-user"></i> Blame</a>
+ <a wicket:id="outline" class="btn btn-default btn-xs outline-toggle"><i class="fa fa-list-ul"></i> Outline</a>
+ </wicket:fragment>
</wicket:extend>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.java
index 0db084f8e2..678b7dc7cc 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/SourceViewPanel.java
@@ -20,6 +20,7 @@ import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.behavior.AttributeAppender;
+import org.apache.wicket.event.Broadcast;
import org.apache.wicket.extensions.markup.html.repeater.tree.ITreeProvider;
import org.apache.wicket.extensions.markup.html.repeater.tree.NestedTree;
import org.apache.wicket.extensions.markup.html.repeater.tree.theme.HumanTheme;
@@ -30,7 +31,6 @@ import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.image.Image;
-import org.apache.wicket.markup.html.link.AbstractLink;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
@@ -64,11 +64,8 @@ import com.pmease.commons.lang.extractors.Symbol;
import com.pmease.commons.util.Range;
import com.pmease.commons.wicket.ajaxlistener.ConfirmLeaveListener;
import com.pmease.commons.wicket.behavior.AbstractPostAjaxBehavior;
-import com.pmease.commons.wicket.behavior.ViewStateAwareBehavior;
import com.pmease.commons.wicket.component.DropdownLink;
import com.pmease.commons.wicket.component.PreventDefaultAjaxLink;
-import com.pmease.commons.wicket.component.menu.MenuItem;
-import com.pmease.commons.wicket.component.menu.MenuLink;
import com.pmease.commons.wicket.websocket.WebSocketRenderBehavior;
import com.pmease.gitplex.core.GitPlex;
import com.pmease.gitplex.core.entity.CodeComment;
@@ -81,6 +78,7 @@ import com.pmease.gitplex.core.manager.CodeCommentManager;
import com.pmease.gitplex.core.security.SecurityUtils;
import com.pmease.gitplex.search.hit.QueryHit;
import com.pmease.gitplex.web.component.comment.CodeCommentPanel;
+import com.pmease.gitplex.web.component.comment.CodeCommentToggled;
import com.pmease.gitplex.web.component.comment.CommentInput;
import com.pmease.gitplex.web.component.comment.DepotAttachmentSupport;
import com.pmease.gitplex.web.component.comment.comparecontext.CompareContextPanel;
@@ -148,79 +146,54 @@ public class SourceViewPanel extends BlobViewPanel {
}
@Override
- public List<MenuItem> getMenuItems(MenuLink menuLink) {
- List<MenuItem> menuItems = new ArrayList<>();
- menuItems.add(new MenuItem() {
-
- @Override
- public String getIconClass() {
- return context.getMode() == Mode.BLAME?"fa fa-check":null;
- }
+ public WebMarkupContainer newAdditionalActions(String id) {
+ WebMarkupContainer actions = new Fragment(id, "actionsFrag", this);
+ actions.add(new PreventDefaultAjaxLink<Void>("blame") {
@Override
- public String getLabel() {
- return "Blame";
+ public void onClick(AjaxRequestTarget target) {
+ boolean blamed = (context.getMode() != Mode.BLAME);
+ String jsonOfBlameInfos = getJsonOfBlameInfos(blamed);
+ String script = String.format("gitplex.sourceview.onBlame(%s);", jsonOfBlameInfos);
+ target.appendJavaScript(script);
+ context.onBlameChange(target, blamed);
}
- @Override
- public AbstractLink newLink(String id) {
- AjaxLink<Void> link = new PreventDefaultAjaxLink<Void>(id) {
-
- @Override
- public void onClick(AjaxRequestTarget target) {
- menuLink.close();
- boolean blamed = (context.getMode() != Mode.BLAME);
- String jsonOfBlameInfos = getJsonOfBlameInfos(blamed);
- String script = String.format("gitplex.sourceview.onBlame(%s);", jsonOfBlameInfos);
- target.appendJavaScript(script);
- context.onBlameChange(target, blamed);
- }
+ }.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() {
- };
- PageParameters params;
- DepotFilePage.State state = new DepotFilePage.State();
- state.blobIdent = context.getBlobIdent();
- if (context.getMode() != Mode.BLAME)
- state.mode = Mode.BLAME;
- state.mark = context.getMark();
- params = DepotFilePage.paramsOf(context.getDepot(), state);
- CharSequence url = RequestCycle.get().urlFor(DepotFilePage.class, params);
- link.add(AttributeAppender.replace("href", url.toString()));
- link.add(new ViewStateAwareBehavior());
- return link;
+ @Override
+ public String getObject() {
+ if (context.getMode() == Mode.BLAME)
+ return "active";
+ else
+ return "";
}
- });
+ })));
if (!symbols.isEmpty()) {
- menuItems.add(new MenuItem() {
+ actions.add(new AjaxLink<Void>("outline") {
@Override
- public String getLabel() {
- return "Outline";
+ public void onClick(AjaxRequestTarget target) {
+ toggleOutline(target);
}
+
+ }.add(AttributeAppender.append("class", new AbstractReadOnlyModel<String>() {
@Override
- public String getIconClass() {
- return outlineContainer.isVisible()?"fa fa-check":null;
- }
-
- @Override
- public AbstractLink newLink(String id) {
- return new AjaxLink<Void>(id) {
-
- @Override
- public void onClick(AjaxRequestTarget target) {
- menuLink.close();
- toggleOutline(target);
- }
-
- };
+ public String getObject() {
+ if (outlineContainer.isVisible())
+ return "active";
+ else
+ return "";
}
- });
- }
- return menuItems;
+ })));
+ } else {
+ actions.add(new WebMarkupContainer("outline").setVisible(false));
+ }
+ return actions;
}
private void toggleOutline(AjaxRequestTarget target) {
@@ -377,6 +350,7 @@ public class SourceViewPanel extends BlobViewPanel {
if (context.getOpenComment() != null)
context.onCommentOpened(target, null);
target.appendJavaScript("gitplex.sourceview.onCloseComment();");
+ send(SourceViewPanel.this, Broadcast.BREADTH, new CodeCommentToggled(target));
}
});
@@ -583,6 +557,7 @@ public class SourceViewPanel extends BlobViewPanel {
getJsonOfComment(comment));
target.appendJavaScript(script);
context.onCommentOpened(target, comment);
+ send(SourceViewPanel.this, Broadcast.BREADTH, new CodeCommentToggled(target));
}
});
@@ -625,6 +600,7 @@ public class SourceViewPanel extends BlobViewPanel {
script = String.format("gitplex.sourceview.onOpenComment(%s);", getJsonOfComment(comment));
target.appendJavaScript(script);
context.onCommentOpened(target, comment);
+ send(SourceViewPanel.this, Broadcast.BREADTH, new CodeCommentToggled(target));
break;
}
}
@@ -796,6 +772,7 @@ public class SourceViewPanel extends BlobViewPanel {
getJsonOfComment(comment));
target.appendJavaScript(script);
context.onCommentOpened(target, null);
+ send(SourceViewPanel.this, Broadcast.BREADTH, new CodeCommentToggled(target));
}
private List<Symbol> getChildSymbols(@Nullable Symbol parentSymbol) {
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/source-view.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/source-view.js
index b15770538c..8ddbf8afb6 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/source-view.js
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/blobview/source/source-view.js
@@ -12,7 +12,7 @@ gitplex.sourceview = {
$sourceView.data("markCallback", markCallback);
var $code = $sourceView.children(".code");
- $sourceView.closest(".content").css("overflow", "visible");
+ $sourceView.closest(".scrollable").css("overflow", "visible");
function repositionCommentPopovers() {
$(".comment-popover:visible").each(function() {
@@ -430,6 +430,7 @@ gitplex.sourceview = {
},
onToggleOutline: function() {
gitplex.sourceview.onLayoutChange();
+ $(".outline-toggle").toggleClass("active");
},
highlightCommentTrigger: function() {
var cm = $(".source-view>.code>.CodeMirror")[0].CodeMirror;
@@ -530,6 +531,7 @@ gitplex.sourceview = {
onBlame: function(blameInfos) {
gitplex.sourceview.blame(blameInfos);
gitplex.sourceview.onLayoutChange();
+ $(".blame-toggle").toggleClass("active");
},
scrollToCommentBottom: function() {
var $body = $(".source-view>.comment>.content>.body");
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/filenavigator/FileNavigator.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/filenavigator/FileNavigator.html
index f65260b472..5c175a52b4 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/filenavigator/FileNavigator.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/filenavigator/FileNavigator.html
@@ -7,7 +7,6 @@
<a wicket:id="subtreeDropdownTrigger" class="subtree-dropdown-trigger pull-left"></a>
</div>
<div wicket:id="lastSegment" class="pull-left last-segment"></div>
- <a wicket:id="fileMenu" class="pull-left file-menu"><i class="fa fa-angle-down"></i></a>
</div>
<wicket:fragment wicket:id="blobNameFrag">
<span wicket:id="label" class="name"></span>
@@ -17,6 +16,9 @@
<input wicket:id="name" type="text" placeholder="Name your file" class="name form-control input-sm"></input>
</form>
</wicket:fragment>
+ <wicket:fragment wicket:id="addFileFrag">
+ <a wicket:id="addFile" class="add"><i class="fa fa-plus-square-o"></i></a>
+ </wicket:fragment>
<wicket:fragment wicket:id="treeNodeFrag">
<i wicket:id="icon"></i> <a wicket:id="link"><span wicket:id="label"></span></a>
</wicket:fragment>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/filenavigator/FileNavigator.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/filenavigator/FileNavigator.java
index 5f22acc796..31652a985e 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/filenavigator/FileNavigator.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/filenavigator/FileNavigator.java
@@ -11,7 +11,6 @@ import javax.annotation.Nullable;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.attributes.AjaxRequestAttributes;
-import org.apache.wicket.ajax.attributes.IAjaxCallListener;
import org.apache.wicket.ajax.form.OnChangeAjaxBehavior;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.behavior.AttributeAppender;
@@ -25,10 +24,6 @@ import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.TextField;
-import org.apache.wicket.markup.html.link.AbstractLink;
-import org.apache.wicket.markup.html.link.BookmarkablePageLink;
-import org.apache.wicket.markup.html.link.Link;
-import org.apache.wicket.markup.html.link.ResourceLink;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.panel.Fragment;
@@ -36,7 +31,6 @@ import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.LoadableDetachableModel;
import org.apache.wicket.model.Model;
-import org.apache.wicket.request.cycle.RequestCycle;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.ObjectId;
@@ -48,27 +42,17 @@ import org.eclipse.jgit.treewalk.TreeWalk;
import com.google.common.base.Preconditions;
import com.google.common.base.Splitter;
import com.pmease.commons.git.BlobIdent;
-import com.pmease.commons.git.GitUtils;
import com.pmease.commons.util.StringUtils;
import com.pmease.commons.wicket.ajaxlistener.ConfirmLeaveListener;
import com.pmease.commons.wicket.component.DropdownLink;
import com.pmease.commons.wicket.component.PreventDefaultAjaxLink;
-import com.pmease.commons.wicket.component.ViewStateAwareAjaxLink;
import com.pmease.commons.wicket.component.floating.AlignPlacement;
import com.pmease.commons.wicket.component.floating.FloatingPanel;
-import com.pmease.commons.wicket.component.menu.MenuItem;
-import com.pmease.commons.wicket.component.menu.MenuLink;
-import com.pmease.gitplex.core.entity.CodeComment;
-import com.pmease.gitplex.core.entity.PullRequest;
import com.pmease.gitplex.core.security.SecurityUtils;
import com.pmease.gitplex.web.component.BlobIcon;
import com.pmease.gitplex.web.component.depotfile.blobview.BlobNameChangeCallback;
import com.pmease.gitplex.web.component.depotfile.blobview.BlobViewContext;
-import com.pmease.gitplex.web.component.depotfile.blobview.BlobViewContext.Mode;
-import com.pmease.gitplex.web.page.depot.commit.DepotCommitsPage;
import com.pmease.gitplex.web.page.depot.file.DepotFilePage;
-import com.pmease.gitplex.web.resource.BlobResource;
-import com.pmease.gitplex.web.resource.BlobResourceReference;
@SuppressWarnings("serial")
public abstract class FileNavigator extends Panel {
@@ -305,301 +289,40 @@ public abstract class FileNavigator extends Panel {
if (name.length() == 0)
nameInput.add(AttributeAppender.append("class", "focusable"));
lastSegment.add(AttributeAppender.append("class", "input"));
- } else if (file.isFile()) {
- lastSegment = new Fragment(LAST_SEGMENT_ID, "blobNameFrag", this);
-
- String blobName = file.path;
- if (blobName.contains("/"))
- blobName = StringUtils.substringAfterLast(blobName, "/");
- lastSegment.add(new Label("label", blobName));
- } else {
- lastSegment = new WebMarkupContainer(LAST_SEGMENT_ID);
- }
- add(lastSegment);
-
- if (callback == null) {
- add(new MenuLink("fileMenu") {
+ } else if (file.isTree()) {
+ lastSegment = new Fragment(LAST_SEGMENT_ID, "addFileFrag", this);
+ lastSegment.add(new AjaxLink<Void>("addFile") {
@Override
- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
- super.updateAjaxAttributes(attributes);
- attributes.getAjaxCallListeners().add(new IAjaxCallListener() {
-
- @Override
- public CharSequence getSuccessHandler(Component component) {
- return null;
- }
-
- @Override
- public CharSequence getPrecondition(Component component) {
- return null;
- }
-
- @Override
- public CharSequence getInitHandler(Component component) {
- return null;
- }
-
- @Override
- public CharSequence getFailureHandler(Component component) {
- return null;
- }
-
- @Override
- public CharSequence getDoneHandler(Component component) {
- return null;
- }
-
- @Override
- public CharSequence getCompleteHandler(Component component) {
- return null;
- }
-
- @Override
- public CharSequence getBeforeSendHandler(Component component) {
- return null;
- }
-
- @Override
- public CharSequence getBeforeHandler(Component component) {
- return "$('.autofit:visible').first().trigger('storeViewState');";
- }
-
- @Override
- public CharSequence getAfterHandler(Component component) {
- return null;
- }
-
- });
- }
-
- @Override
- protected List<MenuItem> getMenuItems() {
- List<MenuItem> generalItems = new ArrayList<>();
- generalItems.add(new MenuItem() {
-
- @Override
- public String getIconClass() {
- return "fa-history";
- }
-
- @Override
- public String getLabel() {
- return "History";
- }
-
- @Override
- public AbstractLink newLink(String id) {
- return new Link<Void>(id) {
-
- @Override
- public void onClick() {
- DepotCommitsPage.State state = new DepotCommitsPage.State();
- String commitHash = context.getDepot().getObjectId(file.revision).name();
- state.setCompareWith(commitHash);
- if (file.path != null)
- state.setQuery(String.format("path(%s)", file.path));
- setResponsePage(DepotCommitsPage.class, DepotCommitsPage.paramsOf(context.getDepot(), state));
- }
-
- };
- }
-
- });
- if (file.isFile()) {
- generalItems.add(new MenuItem() {
-
- @Override
- public String getIconClass() {
- return "fa-file-text-o";
- }
-
- @Override
- public String getLabel() {
- return "Raw";
- }
-
- @Override
- public AbstractLink newLink(String id) {
- return new ResourceLink<Void>(id, new BlobResourceReference(),
- BlobResource.paramsOf(context.getDepot(), file)) {
-
- @Override
- protected CharSequence getOnClickScript(CharSequence url) {
- return closeBeforeClick(super.getOnClickScript(url));
- }
-
- };
- }
-
- });
- }
-
+ protected void onConfigure() {
+ super.onConfigure();
String path = file.path;
if (path != null && file.isTree())
path += "/";
-
- List<MenuItem> changeItems = new ArrayList<>();
- if (file.isTree() && context.isOnBranch() && SecurityUtils.canModify(context.getDepot(), file.revision, path)) {
- changeItems.add(new MenuItem() {
-
- @Override
- public String getIconClass() {
- return "fa-plus";
- }
-
- @Override
- public String getLabel() {
- return "Create new file";
- }
-
- @Override
- public AbstractLink newLink(String id) {
- return new AjaxLink<Void>(id) {
-
- @Override
- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
- super.updateAjaxAttributes(attributes);
- attributes.getAjaxCallListeners().add(new ConfirmLeaveListener());
- }
-
- @Override
- public void onClick(AjaxRequestTarget target) {
- close();
- onNewFile(target);
- }
-
- };
- }
-
- });
- }
-
- if (file.isFile() && SecurityUtils.canModify(context.getDepot(), file.revision, path)) {
- CodeComment comment = context.getOpenComment();
- if (context.isOnBranch()
- || comment != null && comment.getBranchRef() != null && context.getDepot().getObjectId(comment.getBranchRef(), false) != null) {
- if (context.getDepot().getBlob(file).getText() != null) {
- changeItems.add(new MenuItem() {
-
- @Override
- public String getIconClass() {
- return "fa-pencil";
- }
-
- @Override
- public String getLabel() {
- return "Edit";
- }
-
- @Override
- public WebMarkupContainer newLink(String id) {
- if (context.isOnBranch()) {
- AjaxLink<Void> link = new ViewStateAwareAjaxLink<Void>(id) {
-
- @Override
- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
- super.updateAjaxAttributes(attributes);
- attributes.getAjaxCallListeners().add(new ConfirmLeaveListener());
- }
-
- @Override
- public void onClick(AjaxRequestTarget target, String viewState) {
- close();
- RequestCycle.get().setMetaData(DepotFilePage.VIEW_STATE_KEY, viewState);
- context.onEdit(target);
- }
- };
- link.add(AttributeAppender.append("title", "Edit on branch " + context.getBlobIdent().revision));
- return link;
- } else {
- CodeComment comment = Preconditions.checkNotNull(context.getOpenComment());
- PageParameters params;
- DepotFilePage.State state = new DepotFilePage.State();
- state.blobIdent.revision = GitUtils.ref2branch(context.getOpenComment().getBranchRef());
- state.blobIdent.path = context.getBlobIdent().path;
- state.commentId = comment.getId();
- state.requestId = PullRequest.idOf(context.getPullRequest());
- state.mode = Mode.EDIT;
- params = DepotFilePage.paramsOf(context.getDepot(), state);
- Link<Void> link = new BookmarkablePageLink<Void>(id, DepotFilePage.class, params);
- link.add(AttributeAppender.append("title", "Edit on branch " + state.blobIdent.revision));
- return link;
- }
- }
- });
- }
-
- changeItems.add(new MenuItem() {
-
- @Override
- public String getIconClass() {
- return "fa-trash";
- }
-
- @Override
- public String getLabel() {
- return "Delete";
- }
-
- @Override
- public WebMarkupContainer newLink(String id) {
- if (context.isOnBranch()) {
- AjaxLink<Void> link = new PreventDefaultAjaxLink<Void>(id) {
-
- @Override
- protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
- super.updateAjaxAttributes(attributes);
- attributes.getAjaxCallListeners().add(new ConfirmLeaveListener());
- }
-
- @Override
- public void onClick(AjaxRequestTarget target) {
- close();
- context.onDelete(target);
- }
-
- };
- link.add(AttributeAppender.append("title", "Delete from branch " + context.getBlobIdent().revision));
- return link;
- } else {
- DepotFilePage.State state = new DepotFilePage.State();
- state.blobIdent.revision = GitUtils.ref2branch(context.getOpenComment().getBranchRef());
- state.blobIdent.path = context.getBlobIdent().path;
- state.commentId = comment.getId();
- state.requestId = PullRequest.idOf(context.getPullRequest());
- state.mode = Mode.DELETE;
- PageParameters params = DepotFilePage.paramsOf(context.getDepot(), state);
- Link<Void> link = new BookmarkablePageLink<Void>(id, DepotFilePage.class, params);
- link.add(AttributeAppender.append("title", "Delete from branch " + state.blobIdent.revision));
- return link;
- }
- }
-
- });
- }
- }
+ setVisible(context.isOnBranch() && SecurityUtils.canModify(context.getDepot(), file.revision, path));
+ }
- List<MenuItem> customItems = context.getMenuItems(this);
-
- List<MenuItem> menuItems = new ArrayList<>(generalItems);
- if (!changeItems.isEmpty()) {
- if (!menuItems.isEmpty())
- menuItems.add(null); // add separator
- menuItems.addAll(changeItems);
- }
- if (!customItems.isEmpty()) {
- if (!menuItems.isEmpty())
- menuItems.add(null); // add separator
- menuItems.addAll(customItems);
- }
- return menuItems;
+ @Override
+ protected void onComponentTag(ComponentTag tag) {
+ super.onComponentTag(tag);
+ tag.put("title", "Add new file");
}
- });
+ @Override
+ public void onClick(AjaxRequestTarget target) {
+ onNewFile(target);
+ }
+
+ });
} else {
- add(new WebMarkupContainer("fileMenu").setVisible(false));
- }
+ lastSegment = new Fragment(LAST_SEGMENT_ID, "blobNameFrag", this);
+
+ String blobName = file.path;
+ if (blobName.contains("/"))
+ blobName = StringUtils.substringAfterLast(blobName, "/");
+ lastSegment.add(new Label("label", blobName));
+ }
+ add(lastSegment);
setOutputMarkupId(true);
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/filenavigator/file-navigator.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/filenavigator/file-navigator.css
index 4374b678c3..d7d1820166 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/filenavigator/file-navigator.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/depotfile/filenavigator/file-navigator.css
@@ -15,18 +15,6 @@
color: #444;
font-size: 13px;
}
-.file-navigator em {
- font-style: normal;
-}
.file-navigator .add {
font-size: 18px;
}
-.file-navigator span.add em {
- color: #BBB;
-}
-.file-navigator .file-menu {
- margin: 1px 0 0 4px;
- font-size: 18px;
- line-height: 16px;
- color: #333;
-}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.java
index 1e6781197b..d4647ddae5 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/blob/text/TextDiffPanel.java
@@ -64,13 +64,13 @@ import com.pmease.gitplex.core.manager.CodeCommentManager;
import com.pmease.gitplex.core.security.SecurityUtils;
import com.pmease.gitplex.search.hit.QueryHit;
import com.pmease.gitplex.web.Constants;
+import com.pmease.gitplex.web.component.comment.CodeCommentToggled;
import com.pmease.gitplex.web.component.depotfile.blobview.BlobViewContext.Mode;
import com.pmease.gitplex.web.component.diff.blob.SourceAware;
import com.pmease.gitplex.web.component.diff.blob.text.MarkAwareDiffBlock.Type;
import com.pmease.gitplex.web.component.diff.diffstat.DiffStatBar;
import com.pmease.gitplex.web.component.diff.difftitle.BlobDiffTitle;
import com.pmease.gitplex.web.component.diff.revision.BlobCommentSupport;
-import com.pmease.gitplex.web.component.diff.revision.CodeCommentToggled;
import com.pmease.gitplex.web.component.diff.revision.DiffViewMode;
import com.pmease.gitplex.web.component.symboltooltip.SymbolTooltipPanel;
import com.pmease.gitplex.web.page.depot.commit.CommitDetailPage;
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java
index f8932eff85..2aa7900091 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/component/diff/revision/RevisionDiffPanel.java
@@ -83,6 +83,7 @@ import com.pmease.gitplex.core.manager.CodeCommentManager;
import com.pmease.gitplex.core.security.SecurityUtils;
import com.pmease.gitplex.web.Constants;
import com.pmease.gitplex.web.component.comment.CodeCommentPanel;
+import com.pmease.gitplex.web.component.comment.CodeCommentToggled;
import com.pmease.gitplex.web.component.comment.CommentInput;
import com.pmease.gitplex.web.component.comment.DepotAttachmentSupport;
import com.pmease.gitplex.web.component.comment.comparecontext.CompareContextPanel;
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/DepotCommitsPage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/DepotCommitsPage.java
index 5d5665af92..0947049f2b 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/DepotCommitsPage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/DepotCommitsPage.java
@@ -27,6 +27,7 @@ import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Fragment;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.IModel;
@@ -361,7 +362,7 @@ public class DepotCommitsPage extends DepotPage {
item.add(AttributeAppender.append("class", " commit-item-" + commitIndex));
}
- private Component newCommitItem(String itemId, final int index) {
+ private Component newCommitItem(String itemId, int index) {
List<RevCommit> current = commitsModel.getObject().current;
RevCommit commit = current.get(index);
@@ -434,14 +435,22 @@ public class DepotCommitsPage extends DepotPage {
}
}
if (state.getCompareWith() != null) {
- RevisionComparePage.State state = new RevisionComparePage.State();
- state.leftSide = new DepotAndRevision(getDepot(), commit.name());
- state.rightSide = new DepotAndRevision(getDepot(), DepotCommitsPage.this.state.getCompareWith());
- state.pathFilter = path;
- state.tabPanel = RevisionComparePage.TabPanel.CHANGES;
+ RevisionComparePage.State compareState = new RevisionComparePage.State();
+ compareState.leftSide = new DepotAndRevision(getDepot(), commit.name());
+ compareState.rightSide = new DepotAndRevision(getDepot(), DepotCommitsPage.this.state.getCompareWith());
+ compareState.pathFilter = path;
+ compareState.tabPanel = RevisionComparePage.TabPanel.CHANGES;
- PageParameters params = RevisionComparePage.paramsOf(getDepot(), state);
- item.add(new BookmarkablePageLink<Void>("compare", RevisionComparePage.class, params));
+ PageParameters params = RevisionComparePage.paramsOf(getDepot(), compareState);
+ Link<Void> compareLink = new BookmarkablePageLink<Void>("compare", RevisionComparePage.class, params);
+ if (state.getCompareWith().equals(commit.name())) {
+ compareLink.setEnabled(false);
+ compareLink.add(AttributeAppender.append("disabled", "disabled"));
+ compareLink.add(AttributeAppender.replace("title", ""));
+ item.add(AttributeAppender.append("class", "compare-base"));
+ item.add(AttributeAppender.append("title", "Base commit for comparison"));
+ }
+ item.add(compareLink);
} else {
item.add(new WebMarkupContainer("compare").setVisible(false));
}
@@ -626,6 +635,8 @@ public class DepotCommitsPage extends DepotPage {
new ParseTreeWalker().walk(new RevListCommandFiller(command), parseTree);
if (command.revisions().isEmpty() && compareWith != null)
command.revisions(Lists.newArrayList(compareWith));
+ } else {
+ command.revisions(Lists.newArrayList(compareWith));
}
}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/depot-commits.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/depot-commits.css
index d271f63fad..4121532e43 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/depot-commits.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/commit/depot-commits.css
@@ -1,71 +1,74 @@
-#repo-commits {
- position: relative;
- padding: 20px;
-}
-#repo-commits>.head>.query {
- margin-bottom: 20px;
-}
-
-#repo-commits>.body .no-commits {
- font-style: italic;
- font-size: 16px;
-}
-#repo-commits>.body li {
- padding: 4px 0;
-}
-#repo-commits>.body li.commit>.avatar {
- margin-top: 4px;
-}
-#repo-commits>.body .label {
- margin: 3px 0 0 4px;
-}
-#repo-commits>.body .hash-and-code {
- text-align: right;
- margin-top: 10px;
- white-space: nowrap;
-}
-#repo-commits>.body .compare {
- margin: 10px 0 0 8px;
-}
-#repo-commits>.body a {
- color: #555;
-}
-#repo-commits>.body a.summary {
- font-weight: bold;
- font-size: 15px;
-}
-#repo-commits>.body .detail {
- padding-left: 8px;
- padding-right: 8px;
-}
-#repo-commits>.body li.commit:hover, #repo-commits>.body li.commit.hover {
- background: #F7ECB9;
-}
-#repo-commits>.body .commit-message .highlight {
- background: yellow;
-}
-#repo-commits>.body li.commit .contribution {
- font-size: 12px;
-}
-#repo-commits>.body li.commit .compare {
- color: #888;
-}
-#repo-commits>.body .message-and-labels {
- margin-bottom: 4px;
-}
-#repo-commits>.body>.list {
- margin-bottom: 0;
-}
-#repo-commits>.foot {
- text-align: center;
-}
-#repo-commits>.foot>.alert, #repo-commits>.foot>.btn {
- margin-top: 8px;
- margin-bottom: 0;
-}
-#repo-commits li.date {
- font-size: 18px;
- margin-top: 12px;
- text-align: left;
- border-bottom: 1px solid #EEE;
-}
+#repo-commits {
+ position: relative;
+ padding: 20px;
+}
+#repo-commits>.head>.query {
+ margin-bottom: 20px;
+}
+
+#repo-commits>.body .no-commits {
+ font-style: italic;
+ font-size: 16px;
+}
+#repo-commits>.body li {
+ padding: 4px 0;
+}
+#repo-commits>.body li.commit>.avatar {
+ margin-top: 4px;
+}
+#repo-commits>.body .label {
+ margin: 3px 0 0 4px;
+}
+#repo-commits>.body .hash-and-code {
+ text-align: right;
+ margin-top: 10px;
+ white-space: nowrap;
+}
+#repo-commits>.body .compare {
+ margin: 10px 0 0 8px;
+}
+#repo-commits>.body a {
+ color: #555;
+}
+#repo-commits>.body a.summary {
+ font-weight: bold;
+ font-size: 15px;
+}
+#repo-commits>.body .detail {
+ padding-left: 8px;
+ padding-right: 8px;
+}
+#repo-commits>.body li.commit:hover, #repo-commits>.body li.commit.hover {
+ background: #F7ECB9;
+}
+#repo-commits>.body .commit-message .highlight {
+ background: yellow;
+}
+#repo-commits>.body li.commit .contribution {
+ font-size: 12px;
+}
+#repo-commits>.body li.commit .compare {
+ color: #888;
+}
+#repo-commits>.body .message-and-labels {
+ margin-bottom: 4px;
+}
+#repo-commits>.body>.list {
+ margin-bottom: 0;
+}
+#repo-commits>.foot {
+ text-align: center;
+}
+#repo-commits>.foot>.alert, #repo-commits>.foot>.btn {
+ margin-top: 8px;
+ margin-bottom: 0;
+}
+#repo-commits li.date {
+ font-size: 18px;
+ margin-top: 12px;
+ text-align: left;
+ border-bottom: 1px solid #EEE;
+}
+#repo-commits li.commit.compare-base {
+ background: #E8E8E8;
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/depot.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/depot.css
index f35593ba23..5c6abec764 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/depot.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/depot.css
@@ -1,52 +1,52 @@
-#depot-head .separator {
- margin: 0 8px;
-}
-#depot-head .more-info {
- background: #444;
- padding: 0 8px;
- border-radius: 4px;
- font-size: 14px;
- margin-top: 6px;
- margin-left: 8px;
-}
-#depot-head .more-info:hover {
- background: #777;
-}
-
-#depot>.sidebar>table>tbody>tr>td.nav>.mini-toggle {
- display: block;
- margin-top: -20px;
- text-align: right;
- font-size: 20px;
- padding-right: 20px;
- border-bottom: 1px solid #BBB;
- text-decoration: none;
- color: #666;
- height: 31px;
-}
-#depot>.sidebar>table>tbody>tr>td.nav>.mini-toggle:hover {
- color: #333;
-}
-#depot>.sidebar>table>tbody>tr>td.nav>.mini-toggle>span:before {
- font-family: "FontAwesome";
- content: "\f100";
-}
-#depot>.sidebar>table>tbody>tr>td.mini.nav>.mini-toggle>span:before {
- content: "\f101";
-}
-#depot>.sidebar>table>tbody>tr>td.nav>.mini-toggle:hover {
- background: #EEE;
-}
-#depot>.sidebar>table>tbody>tr>td.nav>.tabs>li>a {
- width: 220px;
-}
-#depot>.sidebar>table>tbody>tr>td.mini.nav>.tabs>li>a {
- width: auto;
-}
-#depot>.sidebar>table>tbody>tr>td.mini.nav {
- width: 40px;
-}
-#depot>.sidebar>table>tbody>tr>td.mini.nav>.tabs>li>a>.text,
-#depot>.sidebar>table>tbody>tr>td.mini.nav>.tabs>li>a>.badge {
- display: none;
-}
+#depot-head .separator {
+ margin: 0 8px;
+}
+#depot-head .more-info {
+ background: #444;
+ padding: 0 8px;
+ border-radius: 4px;
+ font-size: 14px;
+ margin-top: 6px;
+ margin-left: 8px;
+}
+#depot-head .more-info:hover, #depot-head .more-info.dropdown-open {
+ background: #777;
+}
+
+#depot>.sidebar>table>tbody>tr>td.nav>.mini-toggle {
+ display: block;
+ margin-top: -20px;
+ text-align: right;
+ font-size: 20px;
+ padding-right: 20px;
+ border-bottom: 1px solid #BBB;
+ text-decoration: none;
+ color: #666;
+ height: 31px;
+}
+#depot>.sidebar>table>tbody>tr>td.nav>.mini-toggle:hover {
+ color: #333;
+}
+#depot>.sidebar>table>tbody>tr>td.nav>.mini-toggle>span:before {
+ font-family: "FontAwesome";
+ content: "\f100";
+}
+#depot>.sidebar>table>tbody>tr>td.mini.nav>.mini-toggle>span:before {
+ content: "\f101";
+}
+#depot>.sidebar>table>tbody>tr>td.nav>.mini-toggle:hover {
+ background: #EEE;
+}
+#depot>.sidebar>table>tbody>tr>td.nav>.tabs>li>a {
+ width: 220px;
+}
+#depot>.sidebar>table>tbody>tr>td.mini.nav>.tabs>li>a {
+ width: auto;
+}
+#depot>.sidebar>table>tbody>tr>td.mini.nav {
+ width: 40px;
+}
+#depot>.sidebar>table>tbody>tr>td.mini.nav>.tabs>li>a>.text,
+#depot>.sidebar>table>tbody>tr>td.mini.nav>.tabs>li>a>.badge {
+ display: none;
+}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/ContributionPanel.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/ContributionPanel.html
deleted file mode 100644
index 24441e099d..0000000000
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/ContributionPanel.html
+++ /dev/null
@@ -1,20 +0,0 @@
-<wicket:panel>
- <div class="contribution clearfix">
- <div class="pull-left avatar">
- <a wicket:id="avatar"></a>
- </div>
- <div wicket:id="contributor" class="pull-left contributor"></div>
- <div class="pull-left message"><a wicket:id="messageLink"><span wicket:id="message"></span></a></div>
- <div class="contributors pull-left">
- <a wicket:id="contributors" title="Contributors"><i class="fa fa-group"></i> <i class="fa fa-caret-down"></i></a>
- </div>
- <div class="pull-right date"><span wicket:id="date"></span></div>
- </div>
- <wicket:fragment wicket:id="contributorsFrag">
- <ul class="contributors list-unstyled">
- <li wicket:id="contributors">
- <a wicket:id="link"><img wicket:id="avatar"></img> <span wicket:id="name"></span></a>
- </li>
- </ul>
- </wicket:fragment>
-</wicket:panel>
\ No newline at end of file
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/ContributionPanel.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/ContributionPanel.java
deleted file mode 100644
index 3e487ab5dc..0000000000
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/ContributionPanel.java
+++ /dev/null
@@ -1,169 +0,0 @@
-package com.pmease.gitplex.web.page.depot.file;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.wicket.Component;
-import org.apache.wicket.extensions.ajax.markup.html.AjaxLazyLoadPanel;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.link.BookmarkablePageLink;
-import org.apache.wicket.markup.html.link.Link;
-import org.apache.wicket.markup.html.list.ListItem;
-import org.apache.wicket.markup.html.list.ListView;
-import org.apache.wicket.markup.html.panel.Fragment;
-import org.apache.wicket.markup.html.panel.Panel;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.LoadableDetachableModel;
-import org.eclipse.jgit.lib.ObjectId;
-import org.eclipse.jgit.lib.PersonIdent;
-import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.revwalk.RevWalk;
-
-import com.google.common.collect.Lists;
-import com.pmease.commons.git.BlobIdent;
-import com.pmease.commons.git.NameAndEmail;
-import com.pmease.commons.git.command.RevListCommand;
-import com.pmease.commons.wicket.component.DropdownLink;
-import com.pmease.commons.wicket.component.loadingindicator.LoadingIndicator;
-import com.pmease.gitplex.core.entity.Depot;
-import com.pmease.gitplex.web.component.avatar.Avatar;
-import com.pmease.gitplex.web.component.avatar.AvatarLink;
-import com.pmease.gitplex.web.component.contributorpanel.ContributorPanel;
-import com.pmease.gitplex.web.page.depot.commit.CommitDetailPage;
-import com.pmease.gitplex.web.page.depot.commit.DepotCommitsPage;
-import com.pmease.gitplex.web.util.DateUtils;
-
-@SuppressWarnings("serial")
-class ContributionPanel extends Panel {
-
- private static final int MAX_CONTRIBUTORS = 1000;
-
- private final IModel<Depot> depotModel;
-
- private final IModel<RevCommit> commitModel = new LoadableDetachableModel<RevCommit>() {
-
- @Override
- protected RevCommit load() {
- // call revlist command for performance reason
- RevListCommand command = new RevListCommand(depotModel.getObject().getDirectory());
- command.revisions(Lists.newArrayList(blobIdent.revision));
- if (blobIdent.path != null)
- command.paths(Lists.newArrayList(blobIdent.path));
- command.count(1);
- String commitId = command.call().iterator().next();
- return depotModel.getObject().getRevCommit(commitId);
- }
-
- };
-
- private final BlobIdent blobIdent;
-
- public ContributionPanel(String id, IModel<Depot> depotModel, BlobIdent blobIdent) {
- super(id);
-
- this.depotModel = depotModel;
-
- this.blobIdent = blobIdent;
- }
-
- @Override
- protected void onInitialize() {
- super.onInitialize();
-
- RevCommit commit = commitModel.getObject();
- add(new AvatarLink("avatar", commit.getAuthorIdent()));
- add(new ContributorPanel("contributor", commit.getAuthorIdent(),
- commit.getCommitterIdent(), false));
-
- Link<Void> link = new BookmarkablePageLink<Void>("messageLink", CommitDetailPage.class,
- CommitDetailPage.paramsOf(depotModel.getObject(), commit.name()));
- link.add(new Label("message", commit.getShortMessage()));
- add(link);
-
- add(new Label("date", DateUtils.formatAge(commit.getCommitterIdent().getWhen())));
-
- add(new DropdownLink("contributors") {
-
- @Override
- protected Component newContent(String id) {
- return new AjaxLazyLoadPanel(id) {
-
- @Override
- public Component getLoadingComponent(String markupId) {
- return new LoadingIndicator(markupId);
- }
-
- @Override
- public Component getLazyLoadComponent(String markupId) {
- Fragment fragment = new Fragment(id, "contributorsFrag", ContributionPanel.this);
- fragment.add(new ListView<NameAndEmail>("contributors", new LoadableDetachableModel<List<NameAndEmail>>() {
-
- @Override
- protected List<NameAndEmail> load() {
- Depot depot = depotModel.getObject();
- RevListCommand revList = new RevListCommand(depot.getDirectory());
- if (blobIdent.path != null)
- revList.paths(Lists.newArrayList(blobIdent.path));
- revList.revisions(Lists.newArrayList(blobIdent.revision));
- revList.count(MAX_CONTRIBUTORS);
- Set<NameAndEmail> setOfAuthors = new HashSet<>();
- try (RevWalk revWalk = new RevWalk(depot.getRepository())) {
- for (String commitHash: revList.call()) {
- RevCommit commit = revWalk.parseCommit(ObjectId.fromString(commitHash));
- setOfAuthors.add(new NameAndEmail(commit.getAuthorIdent()));
- }
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- List<NameAndEmail> listOfAuthors = new ArrayList<>(setOfAuthors);
- Collections.sort(listOfAuthors);
- return listOfAuthors;
- }
-
- }) {
-
- @Override
- protected void populateItem(ListItem<NameAndEmail> item) {
- NameAndEmail nameAndEmail = item.getModelObject();
- PersonIdent person = new PersonIdent(nameAndEmail.getName(), nameAndEmail.getEmailAddress());
- DepotCommitsPage.State state = new DepotCommitsPage.State();
- state.setCompareWith(blobIdent.revision);
- if (blobIdent.path != null) {
- state.setQuery(String.format("path(%s) author(%s <%s>)",
- blobIdent.path, nameAndEmail.getName(), nameAndEmail.getEmailAddress()));
- } else {
- state.setQuery(String.format("author(%s <%s>)",
- nameAndEmail.getName(), nameAndEmail.getEmailAddress()));
- }
- Link<Void> link = new BookmarkablePageLink<Void>("link", DepotCommitsPage.class,
- DepotCommitsPage.paramsOf(depotModel.getObject(), state));
- link.add(new Avatar("avatar", person));
- link.add(new Label("name", person.getName()));
- item.add(link);
- }
-
- });
- return fragment;
- }
-
- };
- }
-
- });
-
- setOutputMarkupId(true);
- }
-
- @Override
- protected void onDetach() {
- commitModel.detach();
- depotModel.detach();
-
- super.onDetach();
- }
-
-}
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/DepotFilePage.html b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/DepotFilePage.html
index 8aa37c688f..a19d6637e1 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/DepotFilePage.html
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/DepotFilePage.html
@@ -6,6 +6,7 @@
<div class="operations">
<span wicket:id="instantSearch"></span>
<a wicket:id="advancedSearch" title="Advanced search of symbols, files and texts"><i class="fa fa-binoculars"></i></a>
+ <a wicket:id="history" title="Commit history of this path"><i class="fa fa-history"></i></a>
<a wicket:id="download" title="Download zip archive of whole repository at this revision"><i class="fa fa-download"></i></a>
</div>
</div>
@@ -15,7 +16,6 @@
<img wicket:id="icon"></img>
<span>Revision indexing in progress... (search in this revision will be accurate after indexed)</span>
</div>
- <div wicket:id="contribution" class="contribution"></div>
<div wicket:id="fileViewer" class="file-viewer"></div>
<div wicket:id="searchResultContainer" class="search-result">
<div id="search-result-resize-handle" class="ui-resizable-handle ui-resizable-n"></div>
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/DepotFilePage.java b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/DepotFilePage.java
index 32fa1a45fd..f3036e215b 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/DepotFilePage.java
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/DepotFilePage.java
@@ -20,17 +20,14 @@ import org.apache.wicket.RestartResponseException;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;
-import org.apache.wicket.extensions.ajax.markup.html.AjaxLazyLoadPanel;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.image.Image;
+import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.protocol.ws.api.WebSocketRequestHandler;
-import org.apache.wicket.request.IRequestHandler;
import org.apache.wicket.request.cycle.RequestCycle;
-import org.apache.wicket.request.handler.resource.ResourceReferenceRequestHandler;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.resource.PackageResourceReference;
import org.eclipse.jgit.lib.FileMode;
@@ -49,9 +46,6 @@ import com.pmease.commons.hibernate.UnitOfWork;
import com.pmease.commons.lang.diff.DiffUtils;
import com.pmease.commons.lang.extractors.TokenPosition;
import com.pmease.commons.loader.ListenerRegistry;
-import com.pmease.commons.wicket.behavior.AbstractPostAjaxBehavior;
-import com.pmease.commons.wicket.component.menu.MenuItem;
-import com.pmease.commons.wicket.component.menu.MenuLink;
import com.pmease.commons.wicket.component.modal.ModalLink;
import com.pmease.commons.wicket.websocket.WebSocketManager;
import com.pmease.commons.wicket.websocket.WebSocketRegion;
@@ -92,6 +86,7 @@ import com.pmease.gitplex.web.component.depotfile.filenavigator.FileNavigator;
import com.pmease.gitplex.web.component.revisionpicker.RevisionPicker;
import com.pmease.gitplex.web.page.depot.DepotPage;
import com.pmease.gitplex.web.page.depot.NoBranchesPage;
+import com.pmease.gitplex.web.page.depot.commit.DepotCommitsPage;
import com.pmease.gitplex.web.page.depot.compare.RevisionComparePage;
import com.pmease.gitplex.web.page.depot.pullrequest.requestdetail.changes.RequestChangesPage;
import com.pmease.gitplex.web.websocket.CodeCommentChangedRegion;
@@ -133,8 +128,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
private static final String FILE_NAVIGATOR_ID = "fileNavigator";
- private static final String CONTRIBUTION_ID = "contribution";
-
private static final String FILE_VIEWER_ID = "fileViewer";
private static final String SEARCH_RESULD_ID = "searchResult";
@@ -328,6 +321,19 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
}
});
+
+ add(new Link<Void>("history") {
+
+ @Override
+ public void onClick() {
+ DepotCommitsPage.State state = new DepotCommitsPage.State();
+ state.setCompareWith(resolvedRevision.name());
+ if (blobIdent.path != null)
+ state.setQuery(String.format("path(%s)", blobIdent.path));
+ setResponsePage(DepotCommitsPage.class, DepotCommitsPage.paramsOf(getDepot(), state));
+ }
+
+ });
add(new ArchiveMenuLink("download", depotModel) {
@@ -366,7 +372,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
});
- newContributionPanel(null);
newFileViewer(null);
add(searchResultContainer = new WebMarkupContainer("searchResultContainer"));
@@ -451,7 +456,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
mode = Mode.EDIT;
newFileNavigator(target);
- newContributionPanel(target);
newFileViewer(target);
pushState(target);
@@ -467,42 +471,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
}
}
- private void newContributionPanel(@Nullable AjaxRequestTarget target) {
- Component contributionPanel;
- if (mode != Mode.EDIT) {
- contributionPanel = new AjaxLazyLoadPanel(CONTRIBUTION_ID) {
-
- @Override
- public Component getLoadingComponent(String markupId) {
- IRequestHandler handler = new ResourceReferenceRequestHandler(AbstractPostAjaxBehavior.INDICATOR);
- String html = "<img src='" + RequestCycle.get().urlFor(handler) + "' class='loading'/> Loading latest commit...";
- return new Label(markupId, html).setEscapeModelStrings(false);
- }
-
- @Override
- protected void onComponentLoaded(Component component, AjaxRequestTarget target) {
- super.onComponentLoaded(component, target);
- resizeWindow(target);
- }
-
- @Override
- public Component getLazyLoadComponent(String markupId) {
- return new ContributionPanel(markupId, depotModel, blobIdent);
- }
-
- };
- } else {
- contributionPanel = new WebMarkupContainer(CONTRIBUTION_ID).setVisible(false);
- }
- contributionPanel.setOutputMarkupPlaceholderTag(true);
- if (target != null) {
- replace(contributionPanel);
- target.add(contributionPanel);
- } else {
- add(contributionPanel);
- }
- }
-
private BlobViewPanel renderBlobViewer(String panelId) {
for (BlobRenderer renderer: GitPlex.getExtensions(BlobRenderer.class)) {
BlobViewPanel panel = renderer.render(panelId, this);
@@ -573,7 +541,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
protected void onCancel(AjaxRequestTarget target) {
mode = null;
newFileNavigator(target);
- newContributionPanel(target);
newFileViewer(target);
pushState(target);
resizeWindow(target);
@@ -831,7 +798,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
target.add(revisionIndexing);
- newContributionPanel(target);
newFileViewer(target);
}
@@ -988,7 +954,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
GitPlex.getInstance(WebSocketManager.class).onRegionChange(this);
newFileNavigator(target);
- newContributionPanel(target);
newFileViewer(target);
resizeWindow(target);
@@ -1027,7 +992,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
mode = Mode.EDIT;
newFileNavigator(target);
- newContributionPanel(target);
newFileViewer(target);
pushState(target);
resizeWindow(target);
@@ -1058,6 +1022,12 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
return getDepot().getBranchRef(blobIdent.revision) != null;
}
+ @Override
+ public boolean isOnCommentBranch() {
+ CodeComment comment = getOpenComment();
+ return comment != null && comment.getBranchRef() != null && getDepot().getObjectId(comment.getBranchRef(), false) != null;
+ }
+
@Override
public RevCommit getCommit() {
return getDepot().getRevCommit(getBlobIdent().revision);
@@ -1068,18 +1038,6 @@ public class DepotFilePage extends DepotPage implements BlobViewContext {
return false;
}
- @Override
- public List<MenuItem> getMenuItems(MenuLink menuLink) {
- if (mode != Mode.EDIT && mode != Mode.DELETE) {
- Component fileViewer = get(FILE_VIEWER_ID);
- if (fileViewer instanceof BlobViewPanel) {
- BlobViewPanel blobViewPanel = (BlobViewPanel) fileViewer;
- return blobViewPanel.getMenuItems(menuLink);
- }
- }
- return new ArrayList<>();
- }
-
@Override
public Collection<WebSocketRegion> getWebSocketRegions() {
List<WebSocketRegion> regions = new ArrayList<>();
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/depot-file.css b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/depot-file.css
index a6194a37a2..892059ba8b 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/depot-file.css
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/depot-file.css
@@ -81,28 +81,6 @@
padding: 2px 0 3px 0;
}
-#repo-file>.contribution {
- padding: 6px 12px;
- background: #F9F9F9;
- border-bottom: 1px solid #DDD;
- color: #999;
-}
-#repo-file>.contribution img.loading {
- padding: 4px 0;
-}
-#repo-file>.contribution a {
- color: #666;
-}
-#repo-file>.contribution .contributors a {
- text-decoration: none;
-}
-#repo-file>.contribution .pull-left {
- margin-right: 12px;
-}
-#repo-file>.contribution .date {
- margin-left: 12px;
-}
-
#repo-file>.revision-indexing {
padding: 8px 8px 9px 8px;
background: #fcf8e3;
diff --git a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/depot-file.js b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/depot-file.js
index 6add1463a4..0f2c023a0d 100644
--- a/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/depot-file.js
+++ b/gitplex.web/src/main/java/com/pmease/gitplex/web/page/depot/file/depot-file.js
@@ -34,7 +34,7 @@ $(window).load(function() {
var headWidth = $("#depot").width() - $("#depot>.sidebar>table>tbody>tr>td.nav").outerWidth();
// below code moves file navigator to bottom if it is too wide
- var maxWidth = headWidth - $revisionPicker.outerWidth() - 80;
+ var maxWidth = headWidth - $revisionPicker.outerWidth() - 110;
var maxHeight = $head.height();
var $fileNavigator = $head.find(">.file-navigator");