Start splitting our code to reduce initial download
This isn't perfect, but we shave about 162 KiB off the initial download by shifting the user settings, administration panels and patch viewers into their own split points. During the build we compress the deferredjs/ code, just like with the *.cache.html files. This is OK for the deferred code as GWT dynamically loads the other segments by XHR rather than relying on a <script /> tag. Change-Id: Idc7fcdb78ebb54b4631596ff56f4355d1558d96b Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -35,9 +35,10 @@ public class PageLinks {
|
|||||||
public static final String MINE_STARRED = "mine,starred";
|
public static final String MINE_STARRED = "mine,starred";
|
||||||
public static final String MINE_DRAFTS = "mine,drafts";
|
public static final String MINE_DRAFTS = "mine,drafts";
|
||||||
|
|
||||||
public static final String ALL_ABANDONED = "all,abandoned,n,z";
|
public static final String TOP = "n,z";
|
||||||
public static final String ALL_MERGED = "all,merged,n,z";
|
public static final String ALL_ABANDONED = "all,abandoned," + TOP;
|
||||||
public static final String ALL_OPEN = "all,open,n,z";
|
public static final String ALL_MERGED = "all,merged," + TOP;
|
||||||
|
public static final String ALL_OPEN = "all,open," + TOP;
|
||||||
|
|
||||||
public static final String ADMIN_GROUPS = "admin,groups";
|
public static final String ADMIN_GROUPS = "admin,groups";
|
||||||
public static final String ADMIN_PROJECTS = "admin,projects";
|
public static final String ADMIN_PROJECTS = "admin,projects";
|
||||||
@@ -59,7 +60,7 @@ public class PageLinks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String toChangeQuery(final String query) {
|
public static String toChangeQuery(final String query) {
|
||||||
return "q," + KeyUtil.encode(query) + ",n,z";
|
return "q," + KeyUtil.encode(query) + "," + TOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PageLinks() {
|
protected PageLinks() {
|
||||||
|
|||||||
@@ -216,8 +216,11 @@ limitations under the License.
|
|||||||
<mkdir dir="${app}"/>
|
<mkdir dir="${app}"/>
|
||||||
<apply executable="gzip" addsourcefile="false">
|
<apply executable="gzip" addsourcefile="false">
|
||||||
<arg value="-9"/>
|
<arg value="-9"/>
|
||||||
<fileset dir="${app}"
|
<fileset dir="${app}">
|
||||||
includes="**/*.html,**/*.css"/>
|
<include name="**/*.html"/>
|
||||||
|
<include name="**/*.css"/>
|
||||||
|
<include name="deferredjs/**/*.js"/>
|
||||||
|
</fileset>
|
||||||
<redirector>
|
<redirector>
|
||||||
<inputmapper type="glob" from="*" to="${app}/*"/>
|
<inputmapper type="glob" from="*" to="${app}/*"/>
|
||||||
<outputmapper type="glob" from="*" to="${app}/*.gz"/>
|
<outputmapper type="glob" from="*" to="${app}/*.gz"/>
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ package com.google.gerrit.client;
|
|||||||
|
|
||||||
import static com.google.gerrit.common.PageLinks.ADMIN_GROUPS;
|
import static com.google.gerrit.common.PageLinks.ADMIN_GROUPS;
|
||||||
import static com.google.gerrit.common.PageLinks.ADMIN_PROJECTS;
|
import static com.google.gerrit.common.PageLinks.ADMIN_PROJECTS;
|
||||||
import static com.google.gerrit.common.PageLinks.ALL_OPEN;
|
|
||||||
import static com.google.gerrit.common.PageLinks.MINE;
|
import static com.google.gerrit.common.PageLinks.MINE;
|
||||||
import static com.google.gerrit.common.PageLinks.MINE_DRAFTS;
|
import static com.google.gerrit.common.PageLinks.MINE_DRAFTS;
|
||||||
import static com.google.gerrit.common.PageLinks.MINE_STARRED;
|
import static com.google.gerrit.common.PageLinks.MINE_STARRED;
|
||||||
@@ -24,6 +23,7 @@ import static com.google.gerrit.common.PageLinks.REGISTER;
|
|||||||
import static com.google.gerrit.common.PageLinks.SETTINGS;
|
import static com.google.gerrit.common.PageLinks.SETTINGS;
|
||||||
import static com.google.gerrit.common.PageLinks.SETTINGS_NEW_AGREEMENT;
|
import static com.google.gerrit.common.PageLinks.SETTINGS_NEW_AGREEMENT;
|
||||||
import static com.google.gerrit.common.PageLinks.SETTINGS_WEBIDENT;
|
import static com.google.gerrit.common.PageLinks.SETTINGS_WEBIDENT;
|
||||||
|
import static com.google.gerrit.common.PageLinks.TOP;
|
||||||
|
|
||||||
import com.google.gerrit.client.account.AccountSettings;
|
import com.google.gerrit.client.account.AccountSettings;
|
||||||
import com.google.gerrit.client.account.NewAgreementScreen;
|
import com.google.gerrit.client.account.NewAgreementScreen;
|
||||||
@@ -46,6 +46,7 @@ import com.google.gerrit.client.changes.ChangeQueryResultsScreen;
|
|||||||
import com.google.gerrit.client.changes.ChangeScreen;
|
import com.google.gerrit.client.changes.ChangeScreen;
|
||||||
import com.google.gerrit.client.changes.MineDraftsScreen;
|
import com.google.gerrit.client.changes.MineDraftsScreen;
|
||||||
import com.google.gerrit.client.changes.MineStarredScreen;
|
import com.google.gerrit.client.changes.MineStarredScreen;
|
||||||
|
import com.google.gerrit.client.changes.PatchTable;
|
||||||
import com.google.gerrit.client.changes.PublishCommentScreen;
|
import com.google.gerrit.client.changes.PublishCommentScreen;
|
||||||
import com.google.gerrit.client.patches.PatchScreen;
|
import com.google.gerrit.client.patches.PatchScreen;
|
||||||
import com.google.gerrit.client.ui.Screen;
|
import com.google.gerrit.client.ui.Screen;
|
||||||
@@ -58,6 +59,7 @@ import com.google.gerrit.reviewdb.PatchSet;
|
|||||||
import com.google.gerrit.reviewdb.Project;
|
import com.google.gerrit.reviewdb.Project;
|
||||||
import com.google.gerrit.reviewdb.Change.Status;
|
import com.google.gerrit.reviewdb.Change.Status;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.core.client.RunAsyncCallback;
|
||||||
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||||
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||||
import com.google.gwtorm.client.KeyUtil;
|
import com.google.gwtorm.client.KeyUtil;
|
||||||
@@ -98,118 +100,124 @@ public class HistoryHandler implements ValueChangeHandler<String> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onValueChange(final ValueChangeEvent<String> event) {
|
public void onValueChange(final ValueChangeEvent<String> event) {
|
||||||
final String token = event.getValue();
|
final String token = event.getValue();
|
||||||
Screen s;
|
|
||||||
try {
|
try {
|
||||||
s = select(token);
|
select(token);
|
||||||
} catch (RuntimeException err) {
|
} catch (RuntimeException err) {
|
||||||
GWT.log("Error parsing history token: " + token, err);
|
GWT.log("Error parsing history token: " + token, err);
|
||||||
s = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s != null) {
|
|
||||||
Gerrit.display(s);
|
|
||||||
} else {
|
|
||||||
Gerrit.display(new NotFoundScreen());
|
Gerrit.display(new NotFoundScreen());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Screen select(final String token) {
|
private static void select(final String token) {
|
||||||
String p;
|
|
||||||
|
|
||||||
if (token == null) {
|
if (token == null) {
|
||||||
return null;
|
Gerrit.display(new NotFoundScreen());
|
||||||
}
|
|
||||||
|
|
||||||
if (SETTINGS.equals(token) || token.startsWith("settings,")) {
|
} else if (token.startsWith("patch,")) {
|
||||||
if (SETTINGS_NEW_AGREEMENT.equals(token)) {
|
patch(token, null, 0, null);
|
||||||
return new NewAgreementScreen();
|
|
||||||
}
|
|
||||||
p = SETTINGS_NEW_AGREEMENT + ",";
|
|
||||||
if (token.startsWith(p)) {
|
|
||||||
return new NewAgreementScreen(skip(p, token));
|
|
||||||
}
|
|
||||||
return new AccountSettings(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
} else if (token.startsWith("change,publish,")) {
|
||||||
|
publish(token);
|
||||||
|
|
||||||
|
} else if (MINE.equals(token) || token.startsWith("mine,")) {
|
||||||
|
Gerrit.display(mine(token));
|
||||||
|
|
||||||
|
} else if (token.startsWith("all,")) {
|
||||||
|
Gerrit.display(all(token));
|
||||||
|
|
||||||
|
} else if (token.startsWith("project,")) {
|
||||||
|
Gerrit.display(project(token));
|
||||||
|
|
||||||
|
} else if (SETTINGS.equals(token) //
|
||||||
|
|| REGISTER.equals(token) //
|
||||||
|
|| token.startsWith("settings,") //
|
||||||
|
|| token.startsWith("register,") //
|
||||||
|
|| token.startsWith("VE,") //
|
||||||
|
|| token.startsWith("SignInFailure,")) {
|
||||||
|
settings(token);
|
||||||
|
|
||||||
|
} else if (token.startsWith("admin,")) {
|
||||||
|
admin(token);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Gerrit.display(core(token));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Screen mine(final String token) {
|
||||||
if (MINE.equals(token)) {
|
if (MINE.equals(token)) {
|
||||||
if (Gerrit.isSignedIn()) {
|
if (Gerrit.isSignedIn()) {
|
||||||
return new AccountDashboardScreen(Gerrit.getUserAccount().getId());
|
return new AccountDashboardScreen(Gerrit.getUserAccount().getId());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
final Screen r = new AccountDashboardScreen(null);
|
final Screen r = new AccountDashboardScreen(null);
|
||||||
r.setRequiresSignIn(true);
|
r.setRequiresSignIn(true);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (MINE_STARRED.equals(token)) {
|
||||||
|
return new MineStarredScreen();
|
||||||
|
|
||||||
|
} else if (MINE_DRAFTS.equals(token)) {
|
||||||
|
return new MineDraftsScreen();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return new NotFoundScreen();
|
||||||
}
|
}
|
||||||
if (token.startsWith("mine,")) {
|
}
|
||||||
if (MINE_STARRED.equals(token)) {
|
|
||||||
return new MineStarredScreen();
|
private static Screen all(final String token) {
|
||||||
}
|
String p;
|
||||||
if (MINE_DRAFTS.equals(token)) {
|
|
||||||
return new MineDraftsScreen();
|
p = "all,abandoned,";
|
||||||
}
|
if (token.startsWith(p)) {
|
||||||
|
return new AllAbandonedChangesScreen(skip(p, token));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token.startsWith("all,")) {
|
p = "all,merged,";
|
||||||
p = "all,abandoned,";
|
if (token.startsWith(p)) {
|
||||||
if (token.startsWith(p)) {
|
return new AllMergedChangesScreen(skip(p, token));
|
||||||
return new AllAbandonedChangesScreen(skip(p, token));
|
|
||||||
}
|
|
||||||
|
|
||||||
p = "all,merged,";
|
|
||||||
if (token.startsWith(p)) {
|
|
||||||
return new AllMergedChangesScreen(skip(p, token));
|
|
||||||
}
|
|
||||||
|
|
||||||
p = "all,open,";
|
|
||||||
if (token.startsWith(p)) {
|
|
||||||
return new AllOpenChangesScreen(skip(p, token));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token.startsWith("project,")) {
|
p = "all,open,";
|
||||||
p = "project,open,";
|
if (token.startsWith(p)) {
|
||||||
if (token.startsWith(p)) {
|
return new AllOpenChangesScreen(skip(p, token));
|
||||||
final String s = skip(p, token);
|
}
|
||||||
final int c = s.indexOf(',');
|
return new NotFoundScreen();
|
||||||
return new ByProjectOpenChangesScreen(Project.NameKey.parse(s
|
}
|
||||||
.substring(0, c)), s.substring(c + 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
p = "project,merged,";
|
private static Screen project(final String token) {
|
||||||
if (token.startsWith(p)) {
|
String p;
|
||||||
final String s = skip(p, token);
|
|
||||||
final int c = s.indexOf(',');
|
|
||||||
return new ByProjectMergedChangesScreen(Project.NameKey.parse(s
|
|
||||||
.substring(0, c)), s.substring(c + 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
p = "project,abandoned,";
|
p = "project,open,";
|
||||||
if (token.startsWith(p)) {
|
if (token.startsWith(p)) {
|
||||||
final String s = skip(p, token);
|
final String s = skip(p, token);
|
||||||
final int c = s.indexOf(',');
|
final int c = s.indexOf(',');
|
||||||
return new ByProjectAbandonedChangesScreen(Project.NameKey.parse(s
|
return new ByProjectOpenChangesScreen(Project.NameKey.parse(s.substring(
|
||||||
.substring(0, c)), s.substring(c + 1));
|
0, c)), s.substring(c + 1));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token.startsWith("patch,")) {
|
p = "project,merged,";
|
||||||
p = "patch,sidebyside,";
|
if (token.startsWith(p)) {
|
||||||
if (token.startsWith(p))
|
final String s = skip(p, token);
|
||||||
return new PatchScreen.SideBySide(Patch.Key.parse(skip(p, token)),
|
final int c = s.indexOf(',');
|
||||||
0 /* patchIndex */, null /* patchTable */);
|
return new ByProjectMergedChangesScreen(Project.NameKey.parse(s
|
||||||
|
.substring(0, c)), s.substring(c + 1));
|
||||||
p = "patch,unified,";
|
|
||||||
if (token.startsWith(p))
|
|
||||||
return new PatchScreen.Unified(Patch.Key.parse(skip(p, token)),
|
|
||||||
0 /* patchIndex */, null /* patchTable */);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p = "change,publish,";
|
p = "project,abandoned,";
|
||||||
if (token.startsWith(p))
|
if (token.startsWith(p)) {
|
||||||
return new PublishCommentScreen(PatchSet.Id.parse(skip(p, token)));
|
final String s = skip(p, token);
|
||||||
|
final int c = s.indexOf(',');
|
||||||
|
return new ByProjectAbandonedChangesScreen(Project.NameKey.parse(s
|
||||||
|
.substring(0, c)), s.substring(c + 1));
|
||||||
|
}
|
||||||
|
return new NotFoundScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Screen core(final String token) {
|
||||||
|
String p;
|
||||||
|
|
||||||
p = "change,";
|
p = "change,";
|
||||||
if (token.startsWith(p))
|
if (token.startsWith(p))
|
||||||
@@ -226,64 +234,161 @@ public class HistoryHandler implements ValueChangeHandler<String> {
|
|||||||
return new ChangeQueryResultsScreen(s.substring(0, c), s.substring(c + 1));
|
return new ChangeQueryResultsScreen(s.substring(0, c), s.substring(c + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token.startsWith("admin,")) {
|
return new NotFoundScreen();
|
||||||
p = "admin,group,";
|
}
|
||||||
if (token.startsWith(p))
|
|
||||||
return new AccountGroupScreen(AccountGroup.Id.parse(skip(p, token)));
|
|
||||||
|
|
||||||
p = "admin,project,";
|
private static void publish(final String token) {
|
||||||
if (token.startsWith(p)) {
|
new RunAsyncCallback() {
|
||||||
p = skip(p, token);
|
public void onSuccess() {
|
||||||
final int c = p.indexOf(',');
|
Gerrit.display(select());
|
||||||
final String idstr = p.substring(0, c);
|
|
||||||
return new ProjectAdminScreen(Project.NameKey.parse(idstr), token);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ADMIN_GROUPS.equals(token)) {
|
private Screen select() {
|
||||||
return new GroupListScreen();
|
String p = "change,publish,";
|
||||||
|
if (token.startsWith(p))
|
||||||
|
return new PublishCommentScreen(PatchSet.Id.parse(skip(p, token)));
|
||||||
|
return new NotFoundScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ADMIN_PROJECTS.equals(token)) {
|
public void onFailure(Throwable reason) {
|
||||||
return new ProjectListScreen();
|
new ErrorDialog(reason).center();
|
||||||
}
|
}
|
||||||
}
|
}.onSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
p = REGISTER + ",";
|
public static void patch(final String token, final Patch.Key id,
|
||||||
if (token.startsWith(p)) {
|
final int patchIndex, final PatchTable patchTable) {
|
||||||
return new RegisterScreen(skip(p, token));
|
GWT.runAsync(new RunAsyncCallback() {
|
||||||
} else if (REGISTER.equals(token)) {
|
public void onSuccess() {
|
||||||
return new RegisterScreen(MINE);
|
Gerrit.display(select());
|
||||||
}
|
|
||||||
|
|
||||||
p = "VE,";
|
|
||||||
if (token.startsWith(p)) {
|
|
||||||
return new ValidateEmailScreen(skip(p, token));
|
|
||||||
}
|
|
||||||
|
|
||||||
p = "SignInFailure,";
|
|
||||||
if (token.startsWith(p)) {
|
|
||||||
final String[] args = skip(p, token).split(",");
|
|
||||||
final SignInMode mode = SignInMode.valueOf(args[0]);
|
|
||||||
final String msg = KeyUtil.decode(args[1]);
|
|
||||||
switch (Gerrit.getConfig().getAuthType()) {
|
|
||||||
case OPENID:
|
|
||||||
new OpenIdSignInDialog(mode, msg).center();
|
|
||||||
break;
|
|
||||||
case LDAP:
|
|
||||||
new UserPassSignInDialog(msg).center();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
switch (mode) {
|
|
||||||
case SIGN_IN:
|
|
||||||
return select(ALL_OPEN);
|
|
||||||
case LINK_IDENTIY:
|
|
||||||
return new AccountSettings(SETTINGS_WEBIDENT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
private Screen select() {
|
||||||
|
String p;
|
||||||
|
|
||||||
|
p = "patch,sidebyside,";
|
||||||
|
if (token.startsWith(p)) {
|
||||||
|
return new PatchScreen.SideBySide( //
|
||||||
|
id != null ? id : Patch.Key.parse(skip(p, token)), //
|
||||||
|
patchIndex, //
|
||||||
|
patchTable //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
p = "patch,unified,";
|
||||||
|
if (token.startsWith(p)) {
|
||||||
|
return new PatchScreen.Unified( //
|
||||||
|
id != null ? id : Patch.Key.parse(skip(p, token)), //
|
||||||
|
patchIndex, //
|
||||||
|
patchTable //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new NotFoundScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onFailure(Throwable reason) {
|
||||||
|
new ErrorDialog(reason).center();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void settings(final String token) {
|
||||||
|
GWT.runAsync(new RunAsyncCallback() {
|
||||||
|
public void onSuccess() {
|
||||||
|
Gerrit.display(select());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Screen select() {
|
||||||
|
String p;
|
||||||
|
|
||||||
|
p = "register,";
|
||||||
|
if (token.startsWith(p)) {
|
||||||
|
return new RegisterScreen(skip(p, token));
|
||||||
|
} else if (REGISTER.equals(token)) {
|
||||||
|
return new RegisterScreen(MINE);
|
||||||
|
}
|
||||||
|
|
||||||
|
p = "VE,";
|
||||||
|
if (token.startsWith(p))
|
||||||
|
return new ValidateEmailScreen(skip(p, token));
|
||||||
|
|
||||||
|
p = "SignInFailure,";
|
||||||
|
if (token.startsWith(p)) {
|
||||||
|
final String[] args = skip(p, token).split(",");
|
||||||
|
final SignInMode mode = SignInMode.valueOf(args[0]);
|
||||||
|
final String msg = KeyUtil.decode(args[1]);
|
||||||
|
switch (Gerrit.getConfig().getAuthType()) {
|
||||||
|
case OPENID:
|
||||||
|
new OpenIdSignInDialog(mode, msg).center();
|
||||||
|
break;
|
||||||
|
case LDAP:
|
||||||
|
new UserPassSignInDialog(msg).center();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
switch (mode) {
|
||||||
|
case SIGN_IN:
|
||||||
|
return new AllOpenChangesScreen(TOP);
|
||||||
|
case LINK_IDENTIY:
|
||||||
|
return new AccountSettings(SETTINGS_WEBIDENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SETTINGS_NEW_AGREEMENT.equals(token))
|
||||||
|
return new NewAgreementScreen();
|
||||||
|
|
||||||
|
p = SETTINGS_NEW_AGREEMENT + ",";
|
||||||
|
if (token.startsWith(p)) {
|
||||||
|
return new NewAgreementScreen(skip(p, token));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new AccountSettings(token);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onFailure(Throwable reason) {
|
||||||
|
new ErrorDialog(reason).center();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void admin(final String token) {
|
||||||
|
GWT.runAsync(new RunAsyncCallback() {
|
||||||
|
public void onSuccess() {
|
||||||
|
Gerrit.display(select());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Screen select() {
|
||||||
|
String p;
|
||||||
|
|
||||||
|
p = "admin,group,";
|
||||||
|
if (token.startsWith(p))
|
||||||
|
return new AccountGroupScreen(AccountGroup.Id.parse(skip(p, token)));
|
||||||
|
|
||||||
|
p = "admin,project,";
|
||||||
|
if (token.startsWith(p)) {
|
||||||
|
p = skip(p, token);
|
||||||
|
final int c = p.indexOf(',');
|
||||||
|
final String idstr = p.substring(0, c);
|
||||||
|
return new ProjectAdminScreen(Project.NameKey.parse(idstr), token);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ADMIN_GROUPS.equals(token)) {
|
||||||
|
return new GroupListScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ADMIN_PROJECTS.equals(token)) {
|
||||||
|
return new ProjectListScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
return new NotFoundScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onFailure(Throwable reason) {
|
||||||
|
new ErrorDialog(reason).center();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String skip(final String prefix, final String in) {
|
private static String skip(final String prefix, final String in) {
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ public class AccountDashboardLink extends DirectScreenLink {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Screen createScreen() {
|
public void go() {
|
||||||
return new AccountDashboardScreen(accountId);
|
Gerrit.display(getTargetHistoryToken(), //
|
||||||
|
new AccountDashboardScreen(accountId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.client.ui;
|
package com.google.gerrit.client.ui;
|
||||||
|
|
||||||
|
import com.google.gerrit.client.Gerrit;
|
||||||
import com.google.gerrit.client.changes.ChangeScreen;
|
import com.google.gerrit.client.changes.ChangeScreen;
|
||||||
import com.google.gerrit.common.PageLinks;
|
import com.google.gerrit.common.PageLinks;
|
||||||
import com.google.gerrit.common.data.ChangeInfo;
|
import com.google.gerrit.common.data.ChangeInfo;
|
||||||
@@ -41,7 +42,11 @@ public class ChangeLink extends DirectScreenLink {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Screen createScreen() {
|
public void go() {
|
||||||
|
Gerrit.display(getTargetHistoryToken(), createScreen());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Screen createScreen() {
|
||||||
return info != null ? new ChangeScreen(info) : new ChangeScreen(id);
|
return info != null ? new ChangeScreen(info) : new ChangeScreen(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ package com.google.gerrit.client.ui;
|
|||||||
|
|
||||||
import static com.google.gerrit.client.ui.LinkMenuItem.impl;
|
import static com.google.gerrit.client.ui.LinkMenuItem.impl;
|
||||||
|
|
||||||
import com.google.gerrit.client.Gerrit;
|
|
||||||
import com.google.gwt.user.client.DOM;
|
import com.google.gwt.user.client.DOM;
|
||||||
import com.google.gwt.user.client.Event;
|
import com.google.gwt.user.client.Event;
|
||||||
import com.google.gwt.user.client.ui.InlineHyperlink;
|
import com.google.gwt.user.client.ui.InlineHyperlink;
|
||||||
@@ -50,10 +49,5 @@ public abstract class DirectScreenLink extends InlineHyperlink {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Create the screen and start rendering, updating the browser history. */
|
/** Create the screen and start rendering, updating the browser history. */
|
||||||
public void go() {
|
public abstract void go();
|
||||||
Gerrit.display(getTargetHistoryToken(), createScreen());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Create the screen this link wants to display. */
|
|
||||||
protected abstract Screen createScreen();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ package com.google.gerrit.client.ui;
|
|||||||
|
|
||||||
import com.google.gerrit.client.HistoryHandler;
|
import com.google.gerrit.client.HistoryHandler;
|
||||||
import com.google.gerrit.client.changes.PatchTable;
|
import com.google.gerrit.client.changes.PatchTable;
|
||||||
import com.google.gerrit.client.patches.PatchScreen;
|
|
||||||
import com.google.gerrit.reviewdb.Patch;
|
import com.google.gerrit.reviewdb.Patch;
|
||||||
|
|
||||||
public abstract class PatchLink extends DirectScreenLink {
|
public abstract class PatchLink extends DirectScreenLink {
|
||||||
@@ -31,35 +30,38 @@ public abstract class PatchLink extends DirectScreenLink {
|
|||||||
* @param historyToken The history token
|
* @param historyToken The history token
|
||||||
* @param parentPatchTable The table used to display this link
|
* @param parentPatchTable The table used to display this link
|
||||||
*/
|
*/
|
||||||
public PatchLink(final String text, final Patch.Key patchKey, final int patchIndex,
|
public PatchLink(final String text, final Patch.Key patchKey,
|
||||||
final String historyToken, PatchTable parentPatchTable) {
|
final int patchIndex, final String historyToken,
|
||||||
|
PatchTable parentPatchTable) {
|
||||||
super(text, historyToken);
|
super(text, historyToken);
|
||||||
this.patchKey = patchKey;
|
this.patchKey = patchKey;
|
||||||
this.patchIndex = patchIndex;
|
this.patchIndex = patchIndex;
|
||||||
this.parentPatchTable = parentPatchTable;
|
this.parentPatchTable = parentPatchTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class SideBySide extends PatchLink {
|
@Override
|
||||||
public SideBySide(final String text, final Patch.Key patchKey, final int patchIndex,
|
public void go() {
|
||||||
PatchTable parentPatchTable) {
|
HistoryHandler.patch( //
|
||||||
super(text, patchKey, patchIndex, HistoryHandler.toPatchSideBySide(patchKey), parentPatchTable);
|
getTargetHistoryToken(), //
|
||||||
}
|
patchKey, //
|
||||||
|
patchIndex, //
|
||||||
|
parentPatchTable //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
public static class SideBySide extends PatchLink {
|
||||||
protected Screen createScreen() {
|
public SideBySide(final String text, final Patch.Key patchKey,
|
||||||
return new PatchScreen.SideBySide(patchKey, patchIndex, parentPatchTable);
|
final int patchIndex, PatchTable parentPatchTable) {
|
||||||
|
super(text, patchKey, patchIndex, HistoryHandler
|
||||||
|
.toPatchSideBySide(patchKey), parentPatchTable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Unified extends PatchLink {
|
public static class Unified extends PatchLink {
|
||||||
public Unified(final String text, final Patch.Key patchKey, final int patchIndex,
|
public Unified(final String text, final Patch.Key patchKey,
|
||||||
PatchTable parentPatchTable) {
|
final int patchIndex, PatchTable parentPatchTable) {
|
||||||
super(text, patchKey, patchIndex, HistoryHandler.toPatchUnified(patchKey), parentPatchTable);
|
super(text, patchKey, patchIndex,
|
||||||
}
|
HistoryHandler.toPatchUnified(patchKey), parentPatchTable);
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Screen createScreen() {
|
|
||||||
return new PatchScreen.Unified(patchKey, patchIndex, parentPatchTable);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.client.ui;
|
package com.google.gerrit.client.ui;
|
||||||
|
|
||||||
|
import com.google.gerrit.client.Gerrit;
|
||||||
import com.google.gerrit.client.HistoryHandler;
|
import com.google.gerrit.client.HistoryHandler;
|
||||||
import com.google.gerrit.client.changes.ByProjectAbandonedChangesScreen;
|
import com.google.gerrit.client.changes.ByProjectAbandonedChangesScreen;
|
||||||
import com.google.gerrit.client.changes.ByProjectMergedChangesScreen;
|
import com.google.gerrit.client.changes.ByProjectMergedChangesScreen;
|
||||||
@@ -39,7 +40,11 @@ public class ProjectLink extends DirectScreenLink {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Screen createScreen() {
|
public void go() {
|
||||||
|
Gerrit.display(getTargetHistoryToken(), createScreen());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Screen createScreen() {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case ABANDONED:
|
case ABANDONED:
|
||||||
return new ByProjectAbandonedChangesScreen(project, "n,z");
|
return new ByProjectAbandonedChangesScreen(project, "n,z");
|
||||||
|
|||||||
Reference in New Issue
Block a user