Merge "Populate 'My' menu from user preferences"

This commit is contained in:
Shawn Pearce
2014-03-25 02:29:40 +00:00
committed by Gerrit Code Review
3 changed files with 60 additions and 7 deletions

View File

@@ -18,8 +18,10 @@ import static com.google.gerrit.common.data.GlobalCapability.ADMINISTRATE_SERVER
import static com.google.gerrit.common.data.GlobalCapability.CREATE_GROUP;
import static com.google.gerrit.common.data.GlobalCapability.CREATE_PROJECT;
import com.google.gerrit.client.account.AccountApi;
import com.google.gerrit.client.account.AccountCapabilities;
import com.google.gerrit.client.account.AccountInfo;
import com.google.gerrit.client.account.Preferences;
import com.google.gerrit.client.admin.ProjectScreen;
import com.google.gerrit.client.api.ApiGlue;
import com.google.gerrit.client.api.PluginLoader;
@@ -70,6 +72,7 @@ import com.google.gwt.user.client.Cookies;
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.Window.Location;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.FocusPanel;
@@ -585,14 +588,21 @@ public class Gerrit implements EntryPoint {
menuLeft.add(m, C.menuAll());
if (signedIn) {
m = new LinkMenuBar();
final LinkMenuBar myBar = new LinkMenuBar();
menuBars.put(GerritTopMenu.MY.menuName, m);
addLink(m, C.menuMyChanges(), PageLinks.MINE);
addLink(m, C.menuMyDrafts(), PageLinks.toChangeQuery("is:draft"));
addLink(m, C.menuMyDraftComments(), PageLinks.toChangeQuery("has:draft"));
addLink(m, C.menuMyWatchedChanges(), PageLinks.toChangeQuery("is:watched status:open"));
addLink(m, C.menuMyStarredChanges(), PageLinks.toChangeQuery("is:starred"));
menuLeft.add(m, C.menuMine());
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) {
}
});
menuLeft.add(myBar, C.menuMine());
menuLeft.selectTab(1);
} else {
menuLeft.selectTab(0);

View File

@@ -0,0 +1,27 @@
// Copyright (C) 2014 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client.account;
import com.google.gerrit.client.extensions.TopMenuItem;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
public class Preferences extends JavaScriptObject {
public final native JsArray<TopMenuItem> my() /*-{ return this.my; }-*/;
protected Preferences() {
}
}