ChangeScreen2: linkify change author

Bug: issue 2075
Change-Id: I99d9932f3408797d3819a4c03010dbe9ab542f8f
This commit is contained in:
David Ostrovsky
2013-10-12 18:53:57 +02:00
committed by Shawn Pearce
parent 3402ff3e80
commit 49caaf5d89
3 changed files with 41 additions and 10 deletions

View File

@@ -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.GitPerson;
import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo; import com.google.gerrit.client.changes.ChangeInfo.RevisionInfo;
import com.google.gerrit.client.ui.CommentLinkProcessor; 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.GWT;
import com.google.gwt.dom.client.AnchorElement; import com.google.gwt.dom.client.AnchorElement;
import com.google.gwt.dom.client.Element; import com.google.gwt.dom.client.Element;
@@ -38,9 +41,9 @@ class CommitBox extends Composite {
@UiField Element commitName; @UiField Element commitName;
@UiField AnchorElement browserLink; @UiField AnchorElement browserLink;
@UiField Element authorNameEmail; @UiField InlineHyperlink authorNameEmail;
@UiField Element authorDate; @UiField Element authorDate;
@UiField Element committerNameEmail; @UiField InlineHyperlink committerNameEmail;
@UiField Element committerDate; @UiField Element committerDate;
@UiField Element commitMessageText; @UiField Element commitMessageText;
@@ -55,8 +58,10 @@ class CommitBox extends Composite {
CommitInfo commit = revInfo.commit(); CommitInfo commit = revInfo.commit();
commitName.setInnerText(revision); commitName.setInnerText(revision);
format(commit.author(), authorNameEmail, authorDate); formatLink(commit.author(), authorNameEmail,
format(commit.committer(), committerNameEmail, committerDate); authorDate, change.status());
formatLink(commit.committer(), committerNameEmail,
committerDate, change.status());
commitMessageText.setInnerSafeHtml(commentLinkProcessor.apply( commitMessageText.setInnerSafeHtml(commentLinkProcessor.apply(
new SafeHtmlBuilder().append(commit.message()).linkify())); new SafeHtmlBuilder().append(commit.message()).linkify()));
@@ -69,8 +74,25 @@ class CommitBox extends Composite {
} }
} }
private void format(GitPerson person, Element name, Element date) { private static void formatLink(GitPerson person, InlineHyperlink name,
name.setInnerText(person.name() + " <" + person.email() + ">"); Element date, Status status) {
name.setText(renderName(person));
name.setTargetHistoryToken(PageLinks
.toAccountQuery(owner(person), status));
date.setInnerText(FormatUtil.mediumFormat(person.date())); 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 "";
}
}
} }

View File

@@ -16,7 +16,8 @@ limitations under the License.
--> -->
<ui:UiBinder <ui:UiBinder
xmlns:ui='urn:ui:com.google.gwt.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> <ui:style>
.commitHeader { .commitHeader {
border-spacing: 0; border-spacing: 0;
@@ -46,12 +47,20 @@ limitations under the License.
</tr> </tr>
<tr> <tr>
<th><ui:msg>Author</ui:msg></th> <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'/> <td ui:field='authorDate'/>
</tr> </tr>
<tr> <tr>
<th><ui:msg>Committer</ui:msg></th> <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'/> <td ui:field='committerDate'/>
</tr> </tr>
</table> </table>

View File

@@ -65,7 +65,7 @@ public class AccountLinkPanel extends FlowPanel {
add(l); add(l);
} }
private static String owner(AccountInfo ai) { public static String owner(AccountInfo ai) {
if (ai.email() != null) { if (ai.email() != null) {
return ai.email(); return ai.email();
} else if (ai.name() != null) { } else if (ai.name() != null) {