Merge topic 'my-menu'
* changes: Allow users to reset the 'My' menu entries to the server defaults Add REST endpoints to get/set default user preferences
This commit is contained in:
@@ -232,6 +232,7 @@ public interface GerritCss extends CssResource {
|
|||||||
String sshHostKeyPanelKnownHostEntry();
|
String sshHostKeyPanelKnownHostEntry();
|
||||||
String sshKeyPanelEncodedKey();
|
String sshKeyPanelEncodedKey();
|
||||||
String sshKeyPanelInvalid();
|
String sshKeyPanelInvalid();
|
||||||
|
String stringListPanelButtons();
|
||||||
String topMostCell();
|
String topMostCell();
|
||||||
String topmenu();
|
String topmenu();
|
||||||
String topmenuMenuLeft();
|
String topmenuMenuLeft();
|
||||||
|
|||||||
@@ -40,10 +40,11 @@ import java.util.List;
|
|||||||
|
|
||||||
public class StringListPanel extends FlowPanel {
|
public class StringListPanel extends FlowPanel {
|
||||||
private final StringListTable t;
|
private final StringListTable t;
|
||||||
private final Button deleteButton;
|
|
||||||
private final HorizontalPanel titlePanel;
|
private final HorizontalPanel titlePanel;
|
||||||
|
protected final HorizontalPanel buttonPanel;
|
||||||
|
private final Button deleteButton;
|
||||||
private Image info;
|
private Image info;
|
||||||
private FocusWidget widget;
|
protected FocusWidget widget;
|
||||||
|
|
||||||
public StringListPanel(String title, List<String> fieldNames, FocusWidget w,
|
public StringListPanel(String title, List<String> fieldNames, FocusWidget w,
|
||||||
boolean autoSort) {
|
boolean autoSort) {
|
||||||
@@ -56,9 +57,10 @@ public class StringListPanel extends FlowPanel {
|
|||||||
t = new StringListTable(fieldNames, autoSort);
|
t = new StringListTable(fieldNames, autoSort);
|
||||||
add(t);
|
add(t);
|
||||||
|
|
||||||
|
buttonPanel = new HorizontalPanel();
|
||||||
|
buttonPanel.setStyleName(Gerrit.RESOURCES.css().stringListPanelButtons());
|
||||||
deleteButton = new Button(Gerrit.C.stringListPanelDelete());
|
deleteButton = new Button(Gerrit.C.stringListPanelDelete());
|
||||||
deleteButton.setEnabled(false);
|
deleteButton.setEnabled(false);
|
||||||
add(deleteButton);
|
|
||||||
deleteButton.addClickHandler(new ClickHandler() {
|
deleteButton.addClickHandler(new ClickHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(ClickEvent event) {
|
public void onClick(ClickEvent event) {
|
||||||
@@ -66,6 +68,8 @@ public class StringListPanel extends FlowPanel {
|
|||||||
t.deleteChecked();
|
t.deleteChecked();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
buttonPanel.add(deleteButton);
|
||||||
|
add(buttonPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void display(List<List<String>> values) {
|
public void display(List<List<String>> values) {
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ public interface AccountConstants extends Constants {
|
|||||||
String myMenuInfo();
|
String myMenuInfo();
|
||||||
String myMenuName();
|
String myMenuName();
|
||||||
String myMenuUrl();
|
String myMenuUrl();
|
||||||
|
String myMenuReset();
|
||||||
|
|
||||||
String changeScreenOldUi();
|
String changeScreenOldUi();
|
||||||
String changeScreenNewUi();
|
String changeScreenNewUi();
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ myMenu = My Menu
|
|||||||
myMenuInfo = Menu Items for the 'My' top level menu.
|
myMenuInfo = Menu Items for the 'My' top level menu.
|
||||||
myMenuName = Name
|
myMenuName = Name
|
||||||
myMenuUrl = URL
|
myMenuUrl = URL
|
||||||
|
myMenuReset = Reset
|
||||||
|
|
||||||
changeScreenOldUi = Old Screen
|
changeScreenOldUi = Old Screen
|
||||||
changeScreenNewUi = New Screen
|
changeScreenNewUi = New Screen
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import static com.google.gerrit.reviewdb.client.AccountGeneralPreferences.PAGESI
|
|||||||
import com.google.gerrit.client.Dispatcher;
|
import com.google.gerrit.client.Dispatcher;
|
||||||
import com.google.gerrit.client.Gerrit;
|
import com.google.gerrit.client.Gerrit;
|
||||||
import com.google.gerrit.client.StringListPanel;
|
import com.google.gerrit.client.StringListPanel;
|
||||||
|
import com.google.gerrit.client.config.ConfigServerApi;
|
||||||
import com.google.gerrit.client.extensions.TopMenuItem;
|
import com.google.gerrit.client.extensions.TopMenuItem;
|
||||||
import com.google.gerrit.client.rpc.GerritCallback;
|
import com.google.gerrit.client.rpc.GerritCallback;
|
||||||
import com.google.gerrit.client.rpc.Natives;
|
import com.google.gerrit.client.rpc.Natives;
|
||||||
@@ -27,6 +28,7 @@ import com.google.gerrit.client.rpc.ScreenLoadCallback;
|
|||||||
import com.google.gerrit.client.ui.OnEditEnabler;
|
import com.google.gerrit.client.ui.OnEditEnabler;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.CommentVisibilityStrategy;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.CommentVisibilityStrategy;
|
||||||
|
import com.google.gwt.core.client.JsArray;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||||
@@ -208,10 +210,7 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
myMenus = new StringListPanel(Util.C.myMenu(),
|
myMenus = new MyMenuPanel(save);
|
||||||
Arrays.asList(Util.C.myMenuName(), Util.C.myMenuUrl()),
|
|
||||||
save, false);
|
|
||||||
myMenus.setInfo(Util.C.myMenuInfo());
|
|
||||||
add(myMenus);
|
add(myMenus);
|
||||||
|
|
||||||
add(save);
|
add(save);
|
||||||
@@ -282,9 +281,12 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
setListBox(diffView,
|
setListBox(diffView,
|
||||||
AccountGeneralPreferences.DiffView.SIDE_BY_SIDE,
|
AccountGeneralPreferences.DiffView.SIDE_BY_SIDE,
|
||||||
p.diffView());
|
p.diffView());
|
||||||
|
display(p.my());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void display(JsArray<TopMenuItem> items) {
|
||||||
List<List<String>> values = new ArrayList<>();
|
List<List<String>> values = new ArrayList<>();
|
||||||
for (TopMenuItem item : Natives.asList(p.my())) {
|
for (TopMenuItem item : Natives.asList(items)) {
|
||||||
values.add(Arrays.asList(item.getName(), item.getUrl()));
|
values.add(Arrays.asList(item.getName(), item.getUrl()));
|
||||||
}
|
}
|
||||||
myMenus.display(values);
|
myMenus.display(values);
|
||||||
@@ -409,4 +411,28 @@ public class MyPreferencesScreen extends SettingsScreen {
|
|||||||
return ui.name();
|
return ui.name();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class MyMenuPanel extends StringListPanel {
|
||||||
|
MyMenuPanel(Button save) {
|
||||||
|
super(Util.C.myMenu(), Arrays.asList(Util.C.myMenuName(),
|
||||||
|
Util.C.myMenuUrl()), save, false);
|
||||||
|
|
||||||
|
setInfo(Util.C.myMenuInfo());
|
||||||
|
|
||||||
|
Button resetButton = new Button(Util.C.myMenuReset());
|
||||||
|
resetButton.addClickHandler(new ClickHandler() {
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
ConfigServerApi.defaultPreferences(new GerritCallback<Preferences>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(Preferences p) {
|
||||||
|
MyPreferencesScreen.this.display(p.my());
|
||||||
|
widget.setEnabled(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
buttonPanel.add(resetButton);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.client.config;
|
package com.google.gerrit.client.config;
|
||||||
|
|
||||||
|
import com.google.gerrit.client.account.Preferences;
|
||||||
import com.google.gerrit.client.extensions.TopMenuList;
|
import com.google.gerrit.client.extensions.TopMenuList;
|
||||||
import com.google.gerrit.client.rpc.NativeMap;
|
import com.google.gerrit.client.rpc.NativeMap;
|
||||||
import com.google.gerrit.client.rpc.RestApi;
|
import com.google.gerrit.client.rpc.RestApi;
|
||||||
@@ -32,4 +33,8 @@ public class ConfigServerApi {
|
|||||||
public static void topMenus(AsyncCallback<TopMenuList> cb) {
|
public static void topMenus(AsyncCallback<TopMenuList> cb) {
|
||||||
new RestApi("/config/server/top-menus").get(cb);
|
new RestApi("/config/server/top-menus").get(cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void defaultPreferences(AsyncCallback<Preferences> cb) {
|
||||||
|
new RestApi("/config/server/preferences").get(cb);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1628,3 +1628,13 @@ a:hover.downloadLink {
|
|||||||
padding-top: 5px;
|
padding-top: 5px;
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* StringListPanel */
|
||||||
|
.stringListPanelButtons {
|
||||||
|
margin-left: 0.5em;
|
||||||
|
}
|
||||||
|
.stringListPanelButtons .gwt-Button {
|
||||||
|
margin-right: 2em;
|
||||||
|
font-size: 7pt;
|
||||||
|
padding: 1px;
|
||||||
|
}
|
||||||
|
|||||||
@@ -76,10 +76,10 @@ public class GetPreferences implements RestReadView<AccountResource> {
|
|||||||
rsrc.getUser().getAccountId(), allUsers);
|
rsrc.getUser().getAccountId(), allUsers);
|
||||||
}
|
}
|
||||||
|
|
||||||
static class PreferenceInfo {
|
public static class PreferenceInfo {
|
||||||
final String kind = "gerritcodereview#preferences";
|
final String kind = "gerritcodereview#preferences";
|
||||||
|
|
||||||
short changesPerPage;
|
Short changesPerPage;
|
||||||
Boolean showSiteHeader;
|
Boolean showSiteHeader;
|
||||||
Boolean useFlashClipboard;
|
Boolean useFlashClipboard;
|
||||||
DownloadScheme downloadScheme;
|
DownloadScheme downloadScheme;
|
||||||
@@ -96,29 +96,36 @@ public class GetPreferences implements RestReadView<AccountResource> {
|
|||||||
ChangeScreen changeScreen;
|
ChangeScreen changeScreen;
|
||||||
List<TopMenu.MenuItem> my;
|
List<TopMenu.MenuItem> my;
|
||||||
|
|
||||||
PreferenceInfo(AccountGeneralPreferences p, Account.Id accountId,
|
public PreferenceInfo(AccountGeneralPreferences p, Account.Id accountId,
|
||||||
ProjectState allUsers) {
|
ProjectState allUsers) {
|
||||||
changesPerPage = p.getMaximumPageSize();
|
this(p, RefNames.refsUsers(accountId), allUsers);
|
||||||
showSiteHeader = p.isShowSiteHeader() ? true : null;
|
|
||||||
useFlashClipboard = p.isUseFlashClipboard() ? true : null;
|
|
||||||
downloadScheme = p.getDownloadUrl();
|
|
||||||
downloadCommand = p.getDownloadCommand();
|
|
||||||
copySelfOnEmail = p.isCopySelfOnEmails() ? true : null;
|
|
||||||
dateFormat = p.getDateFormat();
|
|
||||||
timeFormat = p.getTimeFormat();
|
|
||||||
reversePatchSetOrder = p.isReversePatchSetOrder() ? true : null;
|
|
||||||
showUsernameInReviewCategory = p.isShowUsernameInReviewCategory() ? true : null;
|
|
||||||
relativeDateInChangeTable = p.isRelativeDateInChangeTable() ? true : null;
|
|
||||||
sizeBarInChangeTable = p.isSizeBarInChangeTable() ? true : null;
|
|
||||||
commentVisibilityStrategy = p.getCommentVisibilityStrategy();
|
|
||||||
diffView = p.getDiffView();
|
|
||||||
changeScreen = p.getChangeScreen();
|
|
||||||
my = my(accountId, allUsers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<TopMenu.MenuItem> my(Account.Id accountId, ProjectState allUsers) {
|
public PreferenceInfo(AccountGeneralPreferences p, String ref,
|
||||||
List<TopMenu.MenuItem> my = my(allUsers, RefNames.refsUsers(accountId));
|
ProjectState allUsers) {
|
||||||
if (my.isEmpty()) {
|
if (p != null) {
|
||||||
|
changesPerPage = p.getMaximumPageSize();
|
||||||
|
showSiteHeader = p.isShowSiteHeader() ? true : null;
|
||||||
|
useFlashClipboard = p.isUseFlashClipboard() ? true : null;
|
||||||
|
downloadScheme = p.getDownloadUrl();
|
||||||
|
downloadCommand = p.getDownloadCommand();
|
||||||
|
copySelfOnEmail = p.isCopySelfOnEmails() ? true : null;
|
||||||
|
dateFormat = p.getDateFormat();
|
||||||
|
timeFormat = p.getTimeFormat();
|
||||||
|
reversePatchSetOrder = p.isReversePatchSetOrder() ? true : null;
|
||||||
|
showUsernameInReviewCategory = p.isShowUsernameInReviewCategory() ? true : null;
|
||||||
|
relativeDateInChangeTable = p.isRelativeDateInChangeTable() ? true : null;
|
||||||
|
sizeBarInChangeTable = p.isSizeBarInChangeTable() ? true : null;
|
||||||
|
commentVisibilityStrategy = p.getCommentVisibilityStrategy();
|
||||||
|
diffView = p.getDiffView();
|
||||||
|
changeScreen = p.getChangeScreen();
|
||||||
|
}
|
||||||
|
my = my(ref, allUsers);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<TopMenu.MenuItem> my(String ref, ProjectState allUsers) {
|
||||||
|
List<TopMenu.MenuItem> my = my(allUsers, ref);
|
||||||
|
if (my.isEmpty() && !ref.equals(RefNames.REFS_USER + "default")) {
|
||||||
my = my(allUsers, RefNames.REFS_USER + "default");
|
my = my(allUsers, RefNames.REFS_USER + "default");
|
||||||
}
|
}
|
||||||
if (my.isEmpty()) {
|
if (my.isEmpty()) {
|
||||||
|
|||||||
@@ -53,23 +53,23 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SetPreferences implements RestModifyView<AccountResource, Input> {
|
public class SetPreferences implements RestModifyView<AccountResource, Input> {
|
||||||
static class Input {
|
public static class Input {
|
||||||
Short changesPerPage;
|
public Short changesPerPage;
|
||||||
Boolean showSiteHeader;
|
public Boolean showSiteHeader;
|
||||||
Boolean useFlashClipboard;
|
public Boolean useFlashClipboard;
|
||||||
DownloadScheme downloadScheme;
|
public DownloadScheme downloadScheme;
|
||||||
DownloadCommand downloadCommand;
|
public DownloadCommand downloadCommand;
|
||||||
Boolean copySelfOnEmail;
|
public Boolean copySelfOnEmail;
|
||||||
DateFormat dateFormat;
|
public DateFormat dateFormat;
|
||||||
TimeFormat timeFormat;
|
public TimeFormat timeFormat;
|
||||||
Boolean reversePatchSetOrder;
|
public Boolean reversePatchSetOrder;
|
||||||
Boolean showUsernameInReviewCategory;
|
public Boolean showUsernameInReviewCategory;
|
||||||
Boolean relativeDateInChangeTable;
|
public Boolean relativeDateInChangeTable;
|
||||||
Boolean sizeBarInChangeTable;
|
public Boolean sizeBarInChangeTable;
|
||||||
CommentVisibilityStrategy commentVisibilityStrategy;
|
public CommentVisibilityStrategy commentVisibilityStrategy;
|
||||||
DiffView diffView;
|
public DiffView diffView;
|
||||||
ChangeScreen changeScreen;
|
public ChangeScreen changeScreen;
|
||||||
List<TopMenu.MenuItem> my;
|
public List<TopMenu.MenuItem> my;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Provider<CurrentUser> self;
|
private final Provider<CurrentUser> self;
|
||||||
@@ -173,9 +173,13 @@ public class SetPreferences implements RestModifyView<AccountResource, Input> {
|
|||||||
|
|
||||||
private void storeMyMenus(Account.Id accountId, List<TopMenu.MenuItem> my)
|
private void storeMyMenus(Account.Id accountId, List<TopMenu.MenuItem> my)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
storeMyMenus(RefNames.refsUsers(accountId), my);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void storeMyMenus(String ref, List<TopMenu.MenuItem> my)
|
||||||
|
throws IOException {
|
||||||
ProjectLevelConfig prefsCfg =
|
ProjectLevelConfig prefsCfg =
|
||||||
allUsers.getConfig(PREFERENCES,
|
allUsers.getConfig(PREFERENCES, ref);
|
||||||
RefNames.refsUsers(accountId));
|
|
||||||
Config cfg = prefsCfg.get();
|
Config cfg = prefsCfg.get();
|
||||||
if (my != null) {
|
if (my != null) {
|
||||||
unsetSection(cfg, MY);
|
unsetSection(cfg, MY);
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
// 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.server.config;
|
||||||
|
|
||||||
|
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||||
|
import com.google.gerrit.reviewdb.client.RefNames;
|
||||||
|
import com.google.gerrit.server.account.GetPreferences.PreferenceInfo;
|
||||||
|
import com.google.gerrit.server.project.ProjectCache;
|
||||||
|
import com.google.gerrit.server.project.ProjectState;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
|
||||||
|
public class GetPreferences implements RestReadView<ConfigResource> {
|
||||||
|
private final ProjectState allUsers;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public GetPreferences(ProjectCache projectCache) {
|
||||||
|
this.allUsers = projectCache.getAllUsers();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PreferenceInfo apply(ConfigResource rsrc) {
|
||||||
|
return new PreferenceInfo(null, RefNames.REFS_USER + "default", allUsers);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,5 +30,7 @@ public class Module extends RestApiModule {
|
|||||||
child(CONFIG_KIND, "capabilities").to(CapabilitiesCollection.class);
|
child(CONFIG_KIND, "capabilities").to(CapabilitiesCollection.class);
|
||||||
child(CONFIG_KIND, "top-menus").to(TopMenuCollection.class);
|
child(CONFIG_KIND, "top-menus").to(TopMenuCollection.class);
|
||||||
get(CONFIG_KIND, "version").to(GetVersion.class);
|
get(CONFIG_KIND, "version").to(GetVersion.class);
|
||||||
|
get(CONFIG_KIND, "preferences").to(GetPreferences.class);
|
||||||
|
put(CONFIG_KIND, "preferences").to(SetPreferences.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
// 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.server.config;
|
||||||
|
|
||||||
|
import com.google.gerrit.common.data.GlobalCapability;
|
||||||
|
import com.google.gerrit.extensions.annotations.RequiresCapability;
|
||||||
|
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||||
|
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||||
|
import com.google.gerrit.reviewdb.client.RefNames;
|
||||||
|
import com.google.gerrit.server.account.SetPreferences.Input;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Provider;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||||
|
public class SetPreferences implements RestModifyView<ConfigResource, Input> {
|
||||||
|
private final Provider<com.google.gerrit.server.account.SetPreferences> setPreferences;
|
||||||
|
private final Provider<GetPreferences> getDefaultPreferences;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
SetPreferences(
|
||||||
|
Provider<com.google.gerrit.server.account.SetPreferences> setPreferences,
|
||||||
|
Provider<GetPreferences> getDefaultPreferences) {
|
||||||
|
this.setPreferences = setPreferences;
|
||||||
|
this.getDefaultPreferences = getDefaultPreferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object apply(ConfigResource rsrc, Input i) throws BadRequestException,
|
||||||
|
IOException {
|
||||||
|
if (i.changesPerPage != null || i.showSiteHeader != null
|
||||||
|
|| i.useFlashClipboard != null || i.downloadScheme != null
|
||||||
|
|| i.downloadCommand != null || i.copySelfOnEmail != null
|
||||||
|
|| i.dateFormat != null || i.timeFormat != null
|
||||||
|
|| i.reversePatchSetOrder != null
|
||||||
|
|| i.showUsernameInReviewCategory != null
|
||||||
|
|| i.relativeDateInChangeTable != null
|
||||||
|
|| i.sizeBarInChangeTable != null
|
||||||
|
|| i.commentVisibilityStrategy != null || i.diffView != null
|
||||||
|
|| i.changeScreen != null) {
|
||||||
|
throw new BadRequestException("unsupported option");
|
||||||
|
}
|
||||||
|
if (i.my != null) {
|
||||||
|
setPreferences.get().storeMyMenus(RefNames.REFS_USER + "default", i.my);
|
||||||
|
}
|
||||||
|
return getDefaultPreferences.get().apply(rsrc);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user