Restore /c2/ URL handling

The ChangeScreen2 experiment is still fairly new.  A number of links
exist outside of Gerrit using /#/c2/...  to view a change and enable
new UI.  Continue to accept /c2/ as a temporary override in the
current tab.

Leave a hack inside of Dispatcher for now.  Once ChangeScreen2 becomes
the default most of the hack can go away, but it may be necessary to
continue to accept /#/c2/ as an alias for /#/c/ to prevent breaking
some URLs.

Change-Id: I4134869cddb1d81abf0f0f2e52d20fb25ba59bae
This commit is contained in:
Shawn Pearce
2013-09-25 09:59:31 -07:00
parent 95967375ec
commit fcfe4ad4c6
2 changed files with 11 additions and 0 deletions

View File

@@ -94,6 +94,8 @@ import com.google.gwt.user.client.Window;
import com.google.gwtorm.client.KeyUtil;
public class Dispatcher {
public static boolean changeScreen2;
public static String toPatchSideBySide(final Patch.Key id) {
return toPatch("", null, id);
}
@@ -223,6 +225,9 @@ public class Dispatcher {
} else if (matchPrefix("/admin/", token)) {
admin(token);
} else if (/* DEPRECATED URL */matchPrefix("/c2/", token)) {
changeScreen2 = true;
change(token);
} else if (/* LEGACY URL */matchPrefix("all,", token)) {
redirectFromLegacyToken(token, legacyAll(token));
} else if (/* LEGACY URL */matchPrefix("mine,", token)
@@ -521,6 +526,10 @@ public class Dispatcher {
}
private static boolean isChangeScreen2() {
if (changeScreen2) {
return true;
}
AccountGeneralPreferences.ChangeScreen ui = null;
if (Gerrit.isSignedIn()) {
ui = Gerrit.getUserAccount()

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.client.account;
import static com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DEFAULT_PAGESIZE;
import static com.google.gerrit.reviewdb.client.AccountGeneralPreferences.PAGESIZE_CHOICES;
import com.google.gerrit.client.Dispatcher;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.client.rpc.ScreenLoadCallback;
@@ -342,6 +343,7 @@ public class MyPreferencesScreen extends SettingsScreen {
public void onSuccess(final VoidResult result) {
Gerrit.getUserAccount().setGeneralPreferences(p);
Gerrit.applyUserPreferences();
Dispatcher.changeScreen2 = false;
enable(true);
}