ChangeScreen2: linkify change author
Bug: issue 2075 Change-Id: I99d9932f3408797d3819a4c03010dbe9ab542f8f
This commit is contained in:
committed by
Shawn Pearce
parent
3402ff3e80
commit
49caaf5d89
@@ -22,6 +22,9 @@ 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.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.dom.client.AnchorElement;
|
||||
import com.google.gwt.dom.client.Element;
|
||||
@@ -38,9 +41,9 @@ class CommitBox extends Composite {
|
||||
|
||||
@UiField Element commitName;
|
||||
@UiField AnchorElement browserLink;
|
||||
@UiField Element authorNameEmail;
|
||||
@UiField InlineHyperlink authorNameEmail;
|
||||
@UiField Element authorDate;
|
||||
@UiField Element committerNameEmail;
|
||||
@UiField InlineHyperlink committerNameEmail;
|
||||
@UiField Element committerDate;
|
||||
@UiField Element commitMessageText;
|
||||
|
||||
@@ -55,8 +58,10 @@ class CommitBox extends Composite {
|
||||
CommitInfo commit = revInfo.commit();
|
||||
|
||||
commitName.setInnerText(revision);
|
||||
format(commit.author(), authorNameEmail, authorDate);
|
||||
format(commit.committer(), committerNameEmail, committerDate);
|
||||
formatLink(commit.author(), authorNameEmail,
|
||||
authorDate, change.status());
|
||||
formatLink(commit.committer(), committerNameEmail,
|
||||
committerDate, change.status());
|
||||
commitMessageText.setInnerSafeHtml(commentLinkProcessor.apply(
|
||||
new SafeHtmlBuilder().append(commit.message()).linkify()));
|
||||
|
||||
@@ -69,8 +74,25 @@ class CommitBox extends Composite {
|
||||
}
|
||||
}
|
||||
|
||||
private void format(GitPerson person, Element name, Element date) {
|
||||
name.setInnerText(person.name() + " <" + person.email() + ">");
|
||||
private static void formatLink(GitPerson person, InlineHyperlink name,
|
||||
Element date, Status status) {
|
||||
name.setText(renderName(person));
|
||||
name.setTargetHistoryToken(PageLinks
|
||||
.toAccountQuery(owner(person), status));
|
||||
date.setInnerText(FormatUtil.mediumFormat(person.date()));
|
||||
}
|
||||
|
||||
private static String renderName(GitPerson person) {
|
||||
return person.name() + " <" + person.email() + ">";
|
||||
}
|
||||
|
||||
public static String owner(GitPerson person) {
|
||||
if (person.email() != null) {
|
||||
return person.email();
|
||||
} else if (person.name() != null) {
|
||||
return person.name();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ limitations under the License.
|
||||
-->
|
||||
<ui:UiBinder
|
||||
xmlns:ui='urn:ui:com.google.gwt.uibinder'
|
||||
xmlns:g='urn:import:com.google.gwt.user.client.ui'>
|
||||
xmlns:g='urn:import:com.google.gwt.user.client.ui'
|
||||
xmlns:x='urn:import:com.google.gerrit.client.ui'>
|
||||
<ui:style>
|
||||
.commitHeader {
|
||||
border-spacing: 0;
|
||||
@@ -46,12 +47,20 @@ limitations under the License.
|
||||
</tr>
|
||||
<tr>
|
||||
<th><ui:msg>Author</ui:msg></th>
|
||||
<td ui:field='authorNameEmail'/>
|
||||
<td><x:InlineHyperlink ui:field='authorNameEmail'
|
||||
title='Search for changes by this user'>
|
||||
<ui:attribute name='title'/>
|
||||
</x:InlineHyperlink>
|
||||
</td>
|
||||
<td ui:field='authorDate'/>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><ui:msg>Committer</ui:msg></th>
|
||||
<td ui:field='committerNameEmail'/>
|
||||
<td><x:InlineHyperlink ui:field='committerNameEmail'
|
||||
title='Search for changes by this user'>
|
||||
<ui:attribute name='title'/>
|
||||
</x:InlineHyperlink>
|
||||
</td>
|
||||
<td ui:field='committerDate'/>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -65,7 +65,7 @@ public class AccountLinkPanel extends FlowPanel {
|
||||
add(l);
|
||||
}
|
||||
|
||||
private static String owner(AccountInfo ai) {
|
||||
public static String owner(AccountInfo ai) {
|
||||
if (ai.email() != null) {
|
||||
return ai.email();
|
||||
} else if (ai.name() != null) {
|
||||
|
||||
Reference in New Issue
Block a user