Merge "Show mini avatar for all account links"

This commit is contained in:
Shawn Pearce
2013-04-25 15:21:10 +00:00
committed by Gerrit Code Review
9 changed files with 52 additions and 27 deletions

View File

@@ -21,6 +21,7 @@ public interface GerritCss extends CssResource {
String accountContactPrivacyDetails();
String accountDashboard();
String accountInfoBlock();
String accountLinkPanel();
String accountName();
String accountPassword();
String accountUsername();

View File

@@ -23,7 +23,7 @@ import com.google.gerrit.client.groups.GroupInfo;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.Natives;
import com.google.gerrit.client.ui.AccountGroupSuggestOracle;
import com.google.gerrit.client.ui.AccountLink;
import com.google.gerrit.client.ui.AccountLinkPanel;
import com.google.gerrit.client.ui.AddMemberBox;
import com.google.gerrit.client.ui.FancyFlexTable;
import com.google.gerrit.client.ui.Hyperlink;
@@ -318,7 +318,7 @@ public class AccountGroupMembersScreen extends AccountGroupScreen {
CheckBox checkBox = new CheckBox();
table.setWidget(row, 1, checkBox);
checkBox.setEnabled(enabled);
table.setWidget(row, 2, new AccountLink(i));
table.setWidget(row, 2, new AccountLinkPanel(i));
table.setText(row, 3, i.email());
final FlexCellFormatter fmt = table.getFlexCellFormatter();

View File

@@ -27,7 +27,7 @@ import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.NativeMap;
import com.google.gerrit.client.rpc.NativeString;
import com.google.gerrit.client.rpc.Natives;
import com.google.gerrit.client.ui.AccountLink;
import com.google.gerrit.client.ui.AccountLinkPanel;
import com.google.gerrit.client.ui.AddMemberBox;
import com.google.gerrit.client.ui.ReviewerSuggestOracle;
import com.google.gerrit.common.data.ApprovalDetail;
@@ -329,7 +329,7 @@ public class ApprovalTable extends Composite {
final CellFormatter fmt = table.getCellFormatter();
int col = 0;
table.setWidget(row, col++, new AccountLink(account));
table.setWidget(row, col++, new AccountLinkPanel(account));
rows.put(account._account_id(), row);
if (ad.canRemove()) {

View File

@@ -18,7 +18,7 @@ import static com.google.gerrit.client.FormatUtil.mediumFormat;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.AccountLink;
import com.google.gerrit.client.ui.AccountLinkPanel;
import com.google.gerrit.client.ui.BranchLink;
import com.google.gerrit.client.ui.CommentedActionDialog;
import com.google.gerrit.client.ui.InlineHyperlink;
@@ -104,7 +104,7 @@ public class ChangeInfoBlock extends Composite {
changeIdLabel.setPreviewText(chg.getKey().get());
table.setWidget(R_CHANGE_ID, 1, changeIdLabel);
table.setWidget(R_OWNER, 1, AccountLink.link(acc, chg.getOwner()));
table.setWidget(R_OWNER, 1, AccountLinkPanel.link(acc, chg.getOwner()));
final FlowPanel p = new FlowPanel();
p.add(new ProjectSearchLink(chg.getProject()));

View File

@@ -17,7 +17,7 @@ package com.google.gerrit.client.changes;
import static com.google.gerrit.client.FormatUtil.shortFormat;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.ui.AccountLink;
import com.google.gerrit.client.ui.AccountLinkPanel;
import com.google.gerrit.client.ui.BranchLink;
import com.google.gerrit.client.ui.ChangeLink;
import com.google.gerrit.client.ui.NavigationTable;
@@ -182,8 +182,8 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
}
}
private AccountLink link(final Account.Id id) {
return AccountLink.link(accountCache, id);
private AccountLinkPanel link(final Account.Id id) {
return AccountLinkPanel.link(accountCache, id);
}
public void addSection(final Section s) {

View File

@@ -19,7 +19,7 @@ import static com.google.gerrit.client.FormatUtil.shortFormat;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.changes.ChangeInfo.LabelInfo;
import com.google.gerrit.client.ui.AccountLink;
import com.google.gerrit.client.ui.AccountLinkPanel;
import com.google.gerrit.client.ui.BranchLink;
import com.google.gerrit.client.ui.ChangeLink;
import com.google.gerrit.client.ui.NavigationTable;
@@ -198,7 +198,7 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
table.setWidget(row, C_SUBJECT, new TableChangeLink(subject, c));
if (c.owner() != null) {
table.setWidget(row, C_OWNER, new AccountLink(c.owner(), status));
table.setWidget(row, C_OWNER, new AccountLinkPanel(c.owner(), status));
} else {
table.setText(row, C_OWNER, "");
}

View File

@@ -21,7 +21,7 @@ import com.google.gerrit.client.GitwebLink;
import com.google.gerrit.client.download.DownloadPanel;
import com.google.gerrit.client.patches.PatchUtil;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.ui.AccountLink;
import com.google.gerrit.client.ui.AccountLinkPanel;
import com.google.gerrit.client.ui.CommentedActionDialog;
import com.google.gerrit.client.ui.ComplexDisclosurePanel;
import com.google.gerrit.client.ui.ListenableAccountDiffPreference;
@@ -255,7 +255,7 @@ class PatchSetComplexDisclosurePanel extends ComplexDisclosurePanel
fp.setStyleName(Gerrit.RESOURCES.css().patchSetUserIdentity());
if (who.getName() != null) {
if (who.getAccount() != null) {
fp.add(new AccountLink(who));
fp.add(new AccountLinkPanel(who));
} else {
final InlineLabel lbl = new InlineLabel(who.getName());
lbl.setStyleName(Gerrit.RESOURCES.css().accountName());

View File

@@ -86,6 +86,21 @@ a:hover {
text-decoration: underline;
}
.accountLinkPanel {
display: inline;
}
.accountLinkPanel img {
margin-right: 0.2em;
position: relative;
top: 2px;
}
.accountLinkPanel a {
position: relative;
top: -1px;
}
.accountName {
white-space: nowrap;
}

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.client.ui;
import com.google.gerrit.client.AvatarImage;
import com.google.gerrit.client.FormatUtil;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.account.AccountInfo;
@@ -22,33 +23,46 @@ import com.google.gerrit.common.data.AccountInfoCache;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.UserIdentity;
import com.google.gwt.user.client.ui.FlowPanel;
/** Link to any user's account dashboard. */
public class AccountLink extends InlineHyperlink {
public class AccountLinkPanel extends FlowPanel {
/** Create a link after locating account details from an active cache. */
public static AccountLink link(AccountInfoCache cache, Account.Id id) {
public static AccountLinkPanel link(AccountInfoCache cache, Account.Id id) {
com.google.gerrit.common.data.AccountInfo ai = cache.get(id);
return ai != null ? new AccountLink(ai) : null;
return ai != null ? new AccountLinkPanel(ai) : null;
}
public AccountLink(com.google.gerrit.common.data.AccountInfo ai) {
public AccountLinkPanel(com.google.gerrit.common.data.AccountInfo ai) {
this(FormatUtil.asInfo(ai));
}
public AccountLink(UserIdentity ident) {
public AccountLinkPanel(UserIdentity ident) {
this(AccountInfo.create(
ident.getAccount().get(),
ident.getName(),
ident.getEmail()));
}
public AccountLink(AccountInfo info) {
public AccountLinkPanel(AccountInfo info) {
this(info, Change.Status.NEW);
}
public AccountLink(AccountInfo info, Change.Status status) {
super(FormatUtil.name(info), PageLinks.toAccountQuery(owner(info), status));
setTitle(FormatUtil.nameEmail(info));
public AccountLinkPanel(AccountInfo info, Change.Status status) {
addStyleName(Gerrit.RESOURCES.css().accountLinkPanel());
InlineHyperlink l =
new InlineHyperlink(FormatUtil.name(info), PageLinks.toAccountQuery(
owner(info), status)) {
@Override
public void go() {
Gerrit.display(getTargetHistoryToken());
}
};
l.setTitle(FormatUtil.nameEmail(info));
add(new AvatarImage(info, 16));
add(l);
}
private static String owner(AccountInfo ai) {
@@ -62,9 +76,4 @@ public class AccountLink extends InlineHyperlink {
return "";
}
}
@Override
public void go() {
Gerrit.display(getTargetHistoryToken());
}
}