Show parent commits on change screen if merge commit is viewed
For reviewing merge commits it may be interesting to look at the parent commits. Change-Id: I8d1257ae3ad2649f1a10d87ccd83c0156e31d6f8 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
parent
3eb809dd03
commit
b6c2a3b1b0
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
@ -107,6 +107,10 @@ is also a link to the commit in the Git web browser.
|
||||
|
||||
image::images/user-review-ui-change-screen-commit-info.png[width=800, link="images/user-review-ui-change-screen-commit-info.png"]
|
||||
|
||||
For merge commits the parent commits are also shown.
|
||||
|
||||
image::images/user-review-ui-change-screen-commit-info-merge-commit.png[width=800, link="images/user-review-ui-change-screen-commit-info-merge-commit.png"]
|
||||
|
||||
[[change-info]]
|
||||
=== Change Info Block
|
||||
|
||||
|
@ -21,11 +21,13 @@ import com.google.gerrit.client.changes.ChangeInfo;
|
||||
import com.google.gerrit.client.changes.ChangeInfo.CommitInfo;
|
||||
import com.google.gerrit.client.changes.ChangeInfo.GitPerson;
|
||||
import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo;
|
||||
import com.google.gerrit.client.rpc.Natives;
|
||||
import com.google.gerrit.client.ui.CommentLinkProcessor;
|
||||
import com.google.gerrit.client.ui.InlineHyperlink;
|
||||
import com.google.gerrit.common.PageLinks;
|
||||
import com.google.gerrit.reviewdb.client.Change.Status;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.core.client.JsArray;
|
||||
import com.google.gwt.dom.client.AnchorElement;
|
||||
import com.google.gwt.dom.client.Element;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
@ -33,12 +35,15 @@ import com.google.gwt.resources.client.CssResource;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.uibinder.client.UiHandler;
|
||||
import com.google.gwt.user.client.ui.Anchor;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||
import com.google.gwt.user.client.ui.ScrollPanel;
|
||||
import com.google.gwt.user.client.ui.UIObject;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwtexpui.clippy.client.CopyableLabel;
|
||||
import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
|
||||
|
||||
@ -49,11 +54,16 @@ class CommitBox extends Composite {
|
||||
interface Style extends CssResource {
|
||||
String collapsed();
|
||||
String expanded();
|
||||
String clippy();
|
||||
String parentWebLink();
|
||||
}
|
||||
|
||||
@UiField Style style;
|
||||
@UiField CopyableLabel commitName;
|
||||
@UiField AnchorElement browserLink;
|
||||
@UiField Element parents;
|
||||
@UiField FlowPanel parentCommits;
|
||||
@UiField VerticalPanel parentWebLinks;
|
||||
@UiField InlineHyperlink authorNameEmail;
|
||||
@UiField Element authorDate;
|
||||
@UiField InlineHyperlink committerNameEmail;
|
||||
@ -108,6 +118,27 @@ class CommitBox extends Composite {
|
||||
} else {
|
||||
UIObject.setVisible(browserLink, false);
|
||||
}
|
||||
|
||||
if (revInfo.commit().parents().length() > 1) {
|
||||
setParents(change.project(), revInfo.commit().parents());
|
||||
}
|
||||
}
|
||||
|
||||
private void setParents(String project, JsArray<CommitInfo> commits) {
|
||||
setVisible(parents, true);
|
||||
for (CommitInfo c : Natives.asList(commits)) {
|
||||
CopyableLabel copyLabel = new CopyableLabel(c.commit());
|
||||
copyLabel.setStyleName(style.clippy());
|
||||
parentCommits.add(copyLabel);
|
||||
|
||||
GitwebLink gw = Gerrit.getGitwebLink();
|
||||
if (gw != null) {
|
||||
Anchor a =
|
||||
new Anchor(gw.toRevision(project, c.commit()), gw.getLinkName());
|
||||
a.setStyleName(style.parentWebLink());
|
||||
parentWebLinks.add(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void formatLink(GitPerson person, InlineHyperlink name,
|
||||
|
@ -78,7 +78,11 @@ limitations under the License.
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
right: -16px;
|
||||
}
|
||||
}
|
||||
<!-- To make room for the copyableLabel from the adjacent column -->
|
||||
.parentWebLink {
|
||||
margin-left:16px;
|
||||
}
|
||||
</ui:style>
|
||||
<g:HTMLPanel>
|
||||
<g:ScrollPanel styleName='{style.scroll}' ui:field='scroll'>
|
||||
@ -116,6 +120,15 @@ limitations under the License.
|
||||
<td><clippy:CopyableLabel styleName='{style.clippy}' ui:field='commitName'/></td>
|
||||
<td><a style="margin-left:16px;" ui:field='browserLink' href=""/></td>
|
||||
</tr>
|
||||
<tr ui:field='parents' style='display: none'>
|
||||
<th><ui:msg>Parents</ui:msg></th>
|
||||
<td>
|
||||
<g:FlowPanel ui:field='parentCommits'/>
|
||||
</td>
|
||||
<td>
|
||||
<g:VerticalPanel ui:field='parentWebLinks'/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><ui:msg>Change-Id</ui:msg></th>
|
||||
<td><clippy:CopyableLabel styleName='{style.clippy}' ui:field='idText'/></td>
|
||||
|
Loading…
x
Reference in New Issue
Block a user