Merge "ChangeScreen2: linkify change author"
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/CommitBox.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/CommitBox.java
index 86b313b..5cb0443 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/CommitBox.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/CommitBox.java
@@ -22,6 +22,9 @@
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 @@
@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 @@
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 @@
}
}
- 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 "";
+ }
+ }
}
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/CommitBox.ui.xml b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/CommitBox.ui.xml
index c1a6d24..a095926 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/CommitBox.ui.xml
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/change/CommitBox.ui.xml
@@ -16,7 +16,8 @@
-->
<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 @@
</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>
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/AccountLinkPanel.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/AccountLinkPanel.java
index ef52176..7f11df7 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/AccountLinkPanel.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/AccountLinkPanel.java
@@ -65,7 +65,7 @@
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) {