The first 'My' menu item defines the default screen
The screen that is configured to load from the first 'My' menu item is now loaded as default screen when '/' is accessed. With this users can use the 'g' -> 'i' keys to navigate to their favourite screen. Change-Id: I431ee5ffe8c0043de4ef7976a84a6f9b463351db Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -233,7 +233,12 @@ public class Dispatcher {
|
||||
extension(token);
|
||||
|
||||
} else if (matchExact(MINE, token)) {
|
||||
Gerrit.display(token, mine(token));
|
||||
String defaultScreenToken = Gerrit.getDefaultScreenToken();
|
||||
if (defaultScreenToken != null && !MINE.equals(defaultScreenToken)) {
|
||||
select(defaultScreenToken);
|
||||
} else {
|
||||
Gerrit.display(token, mine(token));
|
||||
}
|
||||
|
||||
} else if (matchPrefix("/dashboard/", token)) {
|
||||
dashboard(token);
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.google.gerrit.client.extensions.TopMenu;
|
||||
import com.google.gerrit.client.extensions.TopMenuItem;
|
||||
import com.google.gerrit.client.extensions.TopMenuList;
|
||||
import com.google.gerrit.client.patches.PatchScreen;
|
||||
import com.google.gerrit.client.rpc.CallbackGroup;
|
||||
import com.google.gerrit.client.rpc.GerritCallback;
|
||||
import com.google.gerrit.client.rpc.Natives;
|
||||
import com.google.gerrit.client.ui.LinkMenuBar;
|
||||
@@ -107,6 +108,7 @@ public class Gerrit implements EntryPoint {
|
||||
private static GerritConfig myConfig;
|
||||
private static HostPageData.Theme myTheme;
|
||||
private static Account myAccount;
|
||||
private static String defaultScreenToken;
|
||||
private static AccountDiffPreference myAccountDiffPref;
|
||||
private static String xGerritAuth;
|
||||
|
||||
@@ -268,6 +270,10 @@ public class Gerrit implements EntryPoint {
|
||||
return topMenu.isVisible();
|
||||
}
|
||||
|
||||
public static String getDefaultScreenToken() {
|
||||
return defaultScreenToken;
|
||||
}
|
||||
|
||||
public static RootPanel getBottomMenu() {
|
||||
return bottomMenu;
|
||||
}
|
||||
@@ -540,7 +546,7 @@ public class Gerrit implements EntryPoint {
|
||||
|
||||
applyUserPreferences();
|
||||
populateBottomMenu(bottomMenu, hpd);
|
||||
refreshMenuBar();
|
||||
refreshMenuBar(false);
|
||||
|
||||
History.addValueChangeHandler(new ValueChangeHandler<String>() {
|
||||
@Override
|
||||
@@ -550,18 +556,27 @@ public class Gerrit implements EntryPoint {
|
||||
});
|
||||
JumpKeys.register(body);
|
||||
|
||||
String token = History.getToken();
|
||||
if (token.isEmpty()) {
|
||||
token = isSignedIn()
|
||||
? PageLinks.MINE
|
||||
: PageLinks.toChangeQuery("status:open");
|
||||
}
|
||||
|
||||
saveDefaultTheme();
|
||||
if (hpd.messages != null) {
|
||||
new MessageOfTheDayBar(hpd.messages).show();
|
||||
}
|
||||
PluginLoader.load(hpd.plugins, token);
|
||||
CallbackGroup cbg = new CallbackGroup();
|
||||
if (isSignedIn()) {
|
||||
AccountApi.self().view("preferences").get(cbg.add(createMyMenuBarCallback()));
|
||||
}
|
||||
PluginLoader.load(hpd.plugins,
|
||||
cbg.addFinal(new GerritCallback<VoidResult>() {
|
||||
@Override
|
||||
public void onSuccess(VoidResult result) {
|
||||
String token = History.getToken();
|
||||
if (token.isEmpty()) {
|
||||
token = isSignedIn()
|
||||
? PageLinks.MINE
|
||||
: PageLinks.toChangeQuery("status:open");
|
||||
}
|
||||
display(token);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private void saveDefaultTheme() {
|
||||
@@ -571,6 +586,10 @@ public class Gerrit implements EntryPoint {
|
||||
}
|
||||
|
||||
public static void refreshMenuBar() {
|
||||
refreshMenuBar(true);
|
||||
}
|
||||
|
||||
private static void refreshMenuBar(boolean populateMyMenu) {
|
||||
menuLeft.clear();
|
||||
menuRight.clear();
|
||||
|
||||
@@ -588,20 +607,11 @@ public class Gerrit implements EntryPoint {
|
||||
menuLeft.add(m, C.menuAll());
|
||||
|
||||
if (signedIn) {
|
||||
final LinkMenuBar myBar = new LinkMenuBar();
|
||||
LinkMenuBar myBar = new LinkMenuBar();
|
||||
menuBars.put(GerritTopMenu.MY.menuName, myBar);
|
||||
AccountApi.self().view("preferences").get(new AsyncCallback<Preferences>() {
|
||||
@Override
|
||||
public void onSuccess(Preferences prefs) {
|
||||
for (TopMenuItem item : Natives.asList(prefs.my())) {
|
||||
addExtensionLink(myBar, item);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
}
|
||||
});
|
||||
if (populateMyMenu) {
|
||||
AccountApi.self().view("preferences").get(createMyMenuBarCallback());
|
||||
}
|
||||
menuLeft.add(myBar, C.menuMine());
|
||||
menuLeft.selectTab(1);
|
||||
} else {
|
||||
@@ -757,6 +767,27 @@ public class Gerrit implements EntryPoint {
|
||||
});
|
||||
}
|
||||
|
||||
private static AsyncCallback<Preferences> createMyMenuBarCallback() {
|
||||
return new GerritCallback<Preferences>() {
|
||||
@Override
|
||||
public void onSuccess(Preferences prefs) {
|
||||
LinkMenuBar myBar = menuBars.get(GerritTopMenu.MY.menuName);
|
||||
myBar.clear();
|
||||
List<TopMenuItem> myMenuItems = Natives.asList(prefs.my());
|
||||
String url = null;
|
||||
if (!myMenuItems.isEmpty()) {
|
||||
if (myMenuItems.get(0).getUrl().startsWith("#")) {
|
||||
url = myMenuItems.get(0).getUrl().substring(1);
|
||||
}
|
||||
for (TopMenuItem item : myMenuItems) {
|
||||
addExtensionLink(myBar, item);
|
||||
}
|
||||
}
|
||||
defaultScreenToken = url;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static void applyUserPreferences() {
|
||||
if (myAccount != null) {
|
||||
final AccountGeneralPreferences p = myAccount.getGeneralPreferences();
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.client.api;
|
||||
|
||||
import com.google.gerrit.client.ErrorDialog;
|
||||
import com.google.gerrit.client.Gerrit;
|
||||
import com.google.gerrit.client.VoidResult;
|
||||
import com.google.gerrit.client.rpc.NativeMap;
|
||||
import com.google.gerrit.client.rpc.Natives;
|
||||
import com.google.gwt.core.client.Callback;
|
||||
@@ -23,6 +24,7 @@ import com.google.gwt.core.client.CodeDownloadException;
|
||||
import com.google.gwt.core.client.ScriptInjector;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.DialogBox;
|
||||
import com.google.gwtexpui.progress.client.ProgressBar;
|
||||
|
||||
@@ -33,11 +35,12 @@ public class PluginLoader extends DialogBox {
|
||||
private static final int MAX_LOAD_TIME_MILLIS = 5000;
|
||||
private static PluginLoader self;
|
||||
|
||||
public static void load(List<String> plugins, final String token) {
|
||||
public static void load(List<String> plugins,
|
||||
AsyncCallback<VoidResult> callback) {
|
||||
if (plugins == null || plugins.isEmpty()) {
|
||||
Gerrit.display(token);
|
||||
callback.onSuccess(VoidResult.create());
|
||||
} else {
|
||||
self = new PluginLoader(token);
|
||||
self = new PluginLoader(callback);
|
||||
self.load(plugins);
|
||||
self.startTimers();
|
||||
self.center();
|
||||
@@ -48,16 +51,16 @@ public class PluginLoader extends DialogBox {
|
||||
self.loadedOne();
|
||||
}
|
||||
|
||||
private final String token;
|
||||
private final AsyncCallback<VoidResult> callback;
|
||||
private ProgressBar progress;
|
||||
private Timer show;
|
||||
private Timer update;
|
||||
private Timer timeout;
|
||||
private boolean visible;
|
||||
|
||||
private PluginLoader(String tokenToDisplay) {
|
||||
private PluginLoader(AsyncCallback<VoidResult> cb) {
|
||||
super(/* auto hide */false, /* modal */true);
|
||||
token = tokenToDisplay;
|
||||
callback = cb;
|
||||
progress = new ProgressBar(Gerrit.C.loadingPlugins());
|
||||
|
||||
setStyleName(Gerrit.RESOURCES.css().errorDialog());
|
||||
@@ -139,7 +142,7 @@ public class PluginLoader extends DialogBox {
|
||||
}
|
||||
}
|
||||
|
||||
Gerrit.display(token);
|
||||
callback.onSuccess(VoidResult.create());
|
||||
}
|
||||
|
||||
private boolean hadFailures() {
|
||||
|
||||
Reference in New Issue
Block a user