Don't use Account class in GWT UI code

We would like to move the Account class out of the reviewdb.client
package and then the GWT UI can no longer use it.

Change-Id: Ic3cc3603ca4924ba8293d8d858a786d44f433868
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2018-02-05 10:11:01 +01:00
parent c89f32404c
commit e647c35474
6 changed files with 13 additions and 21 deletions

View File

@@ -14,7 +14,6 @@
package com.google.gerrit.client.info;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.core.client.JsArrayString;
@@ -22,10 +21,6 @@ import com.google.gwtjsonrpc.client.impl.ser.JavaSqlTimestamp_JsonSerializer;
import java.sql.Timestamp;
public class AccountInfo extends JavaScriptObject {
public final Account.Id getId() {
return new Account.Id(_accountId());
}
public final native int _accountId() /*-{ return this._account_id || 0; }-*/;
public final native String name() /*-{ return this.name; }-*/;

View File

@@ -96,7 +96,6 @@ import com.google.gerrit.client.ui.Screen;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.common.PageLinks;
import com.google.gerrit.extensions.client.GeneralPreferencesInfo.DiffView;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AccountGroup;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Patch;
@@ -107,7 +106,6 @@ import com.google.gwt.core.client.RunAsyncCallback;
import com.google.gwt.http.client.URL;
import com.google.gwtexpui.user.client.UserAgent;
import com.google.gwtorm.client.KeyUtil;
import java.util.Optional;
public class Dispatcher {
public static String toPatch(
@@ -300,7 +298,7 @@ public class Dispatcher {
private static Screen mine() {
if (Gerrit.isSignedIn()) {
return new AccountDashboardScreen(Gerrit.getUserAccount().getId());
return new AccountDashboardScreen(Gerrit.getUserAccount()._accountId());
}
Screen r = new AccountDashboardScreen(null);
r.setRequiresSignIn(true);
@@ -309,15 +307,15 @@ public class Dispatcher {
private static void dashboard(String token) {
String rest = skip(token);
Optional<Account.Id> accountId = Account.Id.tryParse(rest);
if (accountId.isPresent()) {
Gerrit.display(token, new AccountDashboardScreen(accountId.get()));
if (rest.matches("[0-9]+")) {
int accountId = Integer.parseInt(rest);
Gerrit.display(token, new AccountDashboardScreen(accountId));
return;
}
if (rest.equals("self")) {
if (Gerrit.isSignedIn()) {
Gerrit.display(token, new AccountDashboardScreen(Gerrit.getUserAccount().getId()));
Gerrit.display(token, new AccountDashboardScreen(Gerrit.getUserAccount()._accountId()));
} else {
Screen s = new AccountDashboardScreen(null);
s.setRequiresSignIn(true);

View File

@@ -122,6 +122,6 @@ public class MyProfileScreen extends SettingsScreen {
info.setText(row++, fieldIdx, account.name());
info.setText(row++, fieldIdx, account.email());
info.setText(row++, fieldIdx, mediumFormat(account.registeredOn()));
info.setText(row, fieldIdx, account.getId().toString());
info.setText(row, fieldIdx, Integer.toString(account._accountId()));
}
}

View File

@@ -373,7 +373,7 @@ public class ReplyBox extends Composite {
fmt.setStyleName(row, labelHelpColumn, style.label_help());
ApprovalInfo self =
Gerrit.isSignedIn() ? lv.info.forUser(Gerrit.getUserAccount().getId().get()) : null;
Gerrit.isSignedIn() ? lv.info.forUser(Gerrit.getUserAccount()._accountId()) : null;
final LabelRadioGroup group = new LabelRadioGroup(row, id, lv.permitted.size());
for (int i = 0; i < columns.size(); i++) {
@@ -395,7 +395,7 @@ public class ReplyBox extends Composite {
private void renderCheckBox(int row, LabelAndValues lv) {
ApprovalInfo self =
Gerrit.isSignedIn() ? lv.info.forUser(Gerrit.getUserAccount().getId().get()) : null;
Gerrit.isSignedIn() ? lv.info.forUser(Gerrit.getUserAccount()._accountId()) : null;
final String id = lv.info.name();
final CheckBox b = new CheckBox();

View File

@@ -23,7 +23,6 @@ import com.google.gerrit.client.ui.InlineHyperlink;
import com.google.gerrit.client.ui.Screen;
import com.google.gerrit.common.PageLinks;
import com.google.gerrit.extensions.client.ListChangesOption;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gwt.core.client.JsArray;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwtexpui.globalkey.client.KeyCommand;
@@ -43,7 +42,7 @@ public class AccountDashboardScreen extends Screen implements ChangeListScreen {
MY_DASHBOARD_OPTIONS = Collections.unmodifiableSet(options);
}
private final Account.Id ownerId;
private final Integer ownerId;
private final boolean mine;
private ChangeTable table;
private ChangeTable.Section workInProgress;
@@ -51,9 +50,9 @@ public class AccountDashboardScreen extends Screen implements ChangeListScreen {
private ChangeTable.Section incoming;
private ChangeTable.Section closed;
public AccountDashboardScreen(Account.Id id) {
ownerId = id;
mine = Gerrit.isSignedIn() && ownerId.equals(Gerrit.getUserAccount().getId());
public AccountDashboardScreen(Integer accountId) {
ownerId = accountId;
mine = Gerrit.isSignedIn() && ownerId == Gerrit.getUserAccount()._accountId();
}
@Override

View File

@@ -259,7 +259,7 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
if (c.assignee() != null) {
table.setWidget(row, C_ASSIGNEE, AccountLinkPanel.forAssignee(c.assignee()));
if (Gerrit.getUserPreferences().highlightAssigneeInChangeTable()
&& Objects.equals(c.assignee().getId(), Gerrit.getUserAccount().getId())) {
&& Objects.equals(c.assignee()._accountId(), Gerrit.getUserAccount()._accountId())) {
table.getRowFormatter().addStyleName(row, Gerrit.RESOURCES.css().cASSIGNEDTOME());
}
} else {