Merge "Add username to Display In Review Category user preference"

This commit is contained in:
David Pursehouse 2014-07-11 03:31:06 +00:00 committed by Gerrit Code Review
commit b867c94dd7
13 changed files with 38 additions and 10 deletions

View File

@ -21,6 +21,7 @@ public class AccountInfo {
protected Account.Id id;
protected String fullName;
protected String preferredEmail;
protected String username;
protected AccountInfo() {
}
@ -45,6 +46,7 @@ public class AccountInfo {
id = a.getId();
fullName = a.getFullName();
preferredEmail = a.getPreferredEmail();
username = a.getUserName();
}
/** @return the unique local id of the account */
@ -70,6 +72,11 @@ public class AccountInfo {
preferredEmail = email;
}
/** @return the username of the account holder */
public String getUsername() {
return username;
}
/**
* Formats an account name.
* <p>
@ -87,7 +94,7 @@ public class AccountInfo {
}
/**
* Formats an account as an name and an email address.
* Formats an account as a name and an email address.
* <p>
* Example output:
* <ul>

View File

@ -180,21 +180,23 @@ public class FormatUtil {
public static AccountInfo asInfo(Account acct) {
if (acct == null) {
return AccountInfo.create(0, null, null);
return AccountInfo.create(0, null, null, null);
}
return AccountInfo.create(
acct.getId() != null ? acct.getId().get() : 0,
acct.getFullName(),
acct.getPreferredEmail());
acct.getPreferredEmail(),
acct.getUserName());
}
public static AccountInfo asInfo(com.google.gerrit.common.data.AccountInfo acct) {
if (acct == null) {
return AccountInfo.create(0, null, null);
return AccountInfo.create(0, null, null, null);
}
return AccountInfo.create(
acct.getId() != null ? acct.getId().get() : 0,
acct.getFullName(),
acct.getPreferredEmail());
acct.getPreferredEmail(),
acct.getUsername());
}
}

View File

@ -39,6 +39,7 @@ public interface AccountConstants extends Constants {
String messageShowInReviewCategoryNone();
String messageShowInReviewCategoryName();
String messageShowInReviewCategoryEmail();
String messageShowInReviewCategoryUsername();
String messageShowInReviewCategoryAbbrev();
String buttonSaveChanges();
String showRelativeDateInChangeTable();

View File

@ -14,6 +14,7 @@ reviewCategoryLabel = Display In Review Category
messageShowInReviewCategoryNone = None (default)
messageShowInReviewCategoryName = Show Name
messageShowInReviewCategoryEmail = Show Email
messageShowInReviewCategoryUsername = Show Username
messageShowInReviewCategoryAbbrev = Show Abbreviation
maximumPageSizeFieldLabel = Maximum Page Size:

View File

@ -21,6 +21,7 @@ public class AccountInfo extends JavaScriptObject {
public final native int _account_id() /*-{ return this._account_id || 0; }-*/;
public final native String name() /*-{ return this.name; }-*/;
public final native String email() /*-{ return this.email; }-*/;
public final native String username() /*-{ return this.username; }-*/;
/**
* @return true if the server supplied avatar information about this account.
@ -46,8 +47,9 @@ public class AccountInfo extends JavaScriptObject {
/*-{ return this.avatars }-*/;
public static native AccountInfo create(int id, String name,
String email) /*-{
return {'_account_id': id, 'name': name, 'email': email};
String email, String username) /*-{
return {'_account_id': id, 'name': name, 'email': email,
'username': username};
}-*/;
protected AccountInfo() {

View File

@ -86,6 +86,9 @@ public class MyPreferencesScreen extends SettingsScreen {
reviewCategoryStrategy.addItem(
Util.C.messageShowInReviewCategoryEmail(),
AccountGeneralPreferences.ReviewCategoryStrategy.EMAIL.name());
reviewCategoryStrategy.addItem(
Util.C.messageShowInReviewCategoryUsername(),
AccountGeneralPreferences.ReviewCategoryStrategy.USERNAME.name());
reviewCategoryStrategy.addItem(
Util.C.messageShowInReviewCategoryAbbrev(),
AccountGeneralPreferences.ReviewCategoryStrategy.ABBREV.name());

View File

@ -175,7 +175,7 @@ class CommitBox extends Composite {
avatar = new AvatarImage(change.owner());
} else {
avatar = new AvatarImage(
AccountInfo.create(0, person.name(), person.email()));
AccountInfo.create(0, person.name(), person.email(), person.username()));
}
p.insert(avatar, 0);
}

View File

@ -260,6 +260,7 @@ public class ChangeInfo extends JavaScriptObject {
public static class GitPerson extends JavaScriptObject {
public final native String name() /*-{ return this.name; }-*/;
public final native String email() /*-{ return this.email; }-*/;
public final native String username() /*-{ return this.username; }-*/;
private final native String dateRaw() /*-{ return this.date; }-*/;
public final Timestamp date() {

View File

@ -664,7 +664,7 @@ public class ChangeScreen extends Screen
if (msg.getAuthor() != null) {
author = FormatUtil.asInfo(accts.get(msg.getAuthor()));
} else {
author = AccountInfo.create(0, Util.C.messageNoAuthor(), null);
author = AccountInfo.create(0, Util.C.messageNoAuthor(), null, null);
}
boolean isRecent;

View File

@ -352,6 +352,8 @@ public class ChangeTable2 extends NavigationTable<ChangeInfo> {
return accountInfo.name();
case EMAIL:
return accountInfo.email();
case USERNAME:
return accountInfo.username();
case ABBREV:
return getAbbreviation(accountInfo.name(), " ");
default:

View File

@ -41,7 +41,8 @@ public class AccountLinkPanel extends FlowPanel {
this(AccountInfo.create(
ident.getAccount().get(),
ident.getName(),
ident.getEmail()));
ident.getEmail(),
ident.getUsername()));
}
public AccountLinkPanel(AccountInfo info) {

View File

@ -79,6 +79,7 @@ public final class AccountGeneralPreferences {
NONE,
NAME,
EMAIL,
USERNAME,
ABBREV
}

View File

@ -23,6 +23,9 @@ public final class UserIdentity {
/** Email address (or user@host style string anyway). */
protected String email;
/** Username of the user. */
protected String username;
/** Time (in UTC) when the identity was constructed. */
protected Timestamp when;
@ -48,6 +51,10 @@ public final class UserIdentity {
email = e;
}
public String getUsername() {
return username;
}
public Timestamp getDate() {
return when;
}