Make PolyGerrit the default UI

Turn PolyGerrit UI status from experimental to default UI. Remove the
option to disable PolyGerrit UI. This is the next step toward removing
of GWT UI.

We keep gerrit.enableGwtUi option, so that gerrit site administrators can
remove GWT UI and make PolyGerrit the only supported UI already now and
not wait until GWT UI is removed in upcoming releases.

Change-Id: Ie5c658488962911c3a113b08ce1768858f12db07
This commit is contained in:
Paladox none
2018-06-12 16:33:38 +00:00
parent 00bef8f13d
commit b8da4ff335
8 changed files with 12 additions and 124 deletions

View File

@@ -2226,20 +2226,6 @@ A good name should be short but precise enough so that users can identify the in
Defaults to the full hostname of the Gerrit server.
[[gerrit.ui]]gerrit.ui::
+
Default UI when the user does not request a different preference via argument
or cookie.
+
* `GWT` for the old-style Google Web Toolkit-based interface.
* `POLYGERRIT` for the new Polymer-based HTML5 Web interface.
+
A sanity check during startup is performed that the value of
gerrit.ui is an enabled UI.
+
Defaults to GWT (if GWT is enabled) or POLYGERRIT (if POLYGERRIT is
enabled and GWT is disabled)
[[gerrit.serverId]]gerrit.serverId::
+
Used by NoteDb to, amongst other things, identify author identities from

View File

@@ -51,7 +51,6 @@ import com.google.gerrit.common.data.SystemInfoService;
import com.google.gerrit.extensions.client.DiffPreferencesInfo;
import com.google.gerrit.extensions.client.EditPreferencesInfo;
import com.google.gerrit.extensions.client.GerritTopMenu;
import com.google.gerrit.extensions.client.UiType;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gwt.aria.client.Roles;
import com.google.gwt.core.client.EntryPoint;
@@ -583,12 +582,10 @@ public class Gerrit implements EntryPoint {
btmmenu.add(new InlineHTML(M.poweredBy(vs)));
if (info().gerrit().webUis().contains(UiType.POLYGERRIT)) {
btmmenu.add(new InlineLabel(" | "));
uiSwitcherLink = new Anchor(C.newUi(), getUiSwitcherUrl(History.getToken()));
uiSwitcherLink.setStyleName("");
btmmenu.add(uiSwitcherLink);
}
btmmenu.add(new InlineLabel(" | "));
uiSwitcherLink = new Anchor(C.newUi(), getUiSwitcherUrl(History.getToken()));
uiSwitcherLink.setStyleName("");
btmmenu.add(uiSwitcherLink);
String reportBugUrl = info().gerrit().reportBugUrl();
if (reportBugUrl != null) {

View File

@@ -15,7 +15,6 @@
package com.google.gerrit.httpd.raw;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static java.nio.file.Files.exists;
import static java.nio.file.Files.isReadable;
@@ -134,9 +133,9 @@ public class StaticModule extends ServletModule {
if (!options.headless()) {
install(new CoreStaticModule());
}
if (options.enablePolyGerrit()) {
install(new PolyGerritModule());
}
install(new PolyGerritModule());
if (options.enableGwtUi()) {
install(new GwtUiModule());
}
@@ -430,8 +429,6 @@ public class StaticModule extends ServletModule {
this.polygerritUI = polygerritUI;
this.bowerComponentServlet = bowerComponentServlet;
this.fontServlet = fontServlet;
checkState(
options.enablePolyGerrit(), "can't install PolyGerritFilter when PolyGerrit is disabled");
}
@Override
@@ -520,7 +517,7 @@ public class StaticModule extends ServletModule {
}
private boolean isPolyGerritCookie(HttpServletRequest req) {
UiType type = options.defaultUi();
UiType type = UiType.POLYGERRIT;
Cookie[] all = req.getCookies();
if (all != null) {
for (Cookie c : all) {
@@ -537,10 +534,10 @@ public class StaticModule extends ServletModule {
}
private void setPolyGerritCookie(HttpServletRequest req, HttpServletResponse res, UiType pref) {
// Only actually set a cookie if both UIs are enabled in the server;
// Only actually set a cookie if GWT UI is enabled in addition to default PG UI;
// otherwise clear it.
Cookie cookie = new Cookie(GERRIT_UI_COOKIE, pref.name());
if (options.enablePolyGerrit() && options.enableGwtUi()) {
if (options.enableGwtUi()) {
cookie.setPath("/");
cookie.setSecure(isSecure(req));
cookie.setMaxAge(GERRIT_UI_COOKIE_MAX_AGE);

View File

@@ -1,54 +0,0 @@
// Copyright (C) 2017 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.pgm.init;
import com.google.gerrit.extensions.client.UiType;
import com.google.gerrit.pgm.init.api.ConsoleUI;
import com.google.gerrit.pgm.init.api.InitStep;
import com.google.gerrit.pgm.init.api.Section;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.Locale;
@Singleton
class InitExperimental implements InitStep {
private final ConsoleUI ui;
private final Section gerrit;
@Inject
InitExperimental(ConsoleUI ui, Section.Factory sections) {
this.ui = ui;
this.gerrit = sections.get("gerrit", null);
}
@Override
public void run() {
ui.header("Experimental features");
if (!ui.yesno(false, "Enable any experimental features")) {
return;
}
initUis();
}
private void initUis() {
boolean pg = ui.yesno(true, "Default to PolyGerrit UI");
UiType uiType = pg ? UiType.POLYGERRIT : UiType.GWT;
gerrit.set("ui", uiType.name().toLowerCase(Locale.US));
if (pg) {
gerrit.set("enableGwtUi", Boolean.toString(ui.yesno(true, "Enable GWT UI")));
}
}
}

View File

@@ -62,7 +62,6 @@ public class InitModule extends FactoryModule {
step().to(InitCache.class);
step().to(InitPlugins.class);
step().to(InitDev.class);
step().to(InitExperimental.class);
}
protected LinkedBindingBuilder<InitStep> step() {

View File

@@ -14,43 +14,19 @@
package com.google.gerrit.server.config;
import static com.google.common.base.MoreObjects.firstNonNull;
import static com.google.common.base.Preconditions.checkArgument;
import com.google.gerrit.extensions.client.UiType;
import org.eclipse.jgit.lib.Config;
public class GerritOptions {
private final boolean headless;
private final boolean slave;
private final boolean enablePolyGerrit;
private final boolean enableGwtUi;
private final boolean forcePolyGerritDev;
private final UiType defaultUi;
public GerritOptions(Config cfg, boolean headless, boolean slave, boolean forcePolyGerritDev) {
this.slave = slave;
this.enablePolyGerrit =
forcePolyGerritDev || cfg.getBoolean("gerrit", null, "enablePolyGerrit", true);
this.enableGwtUi = cfg.getBoolean("gerrit", null, "enableGwtUi", true);
this.forcePolyGerritDev = forcePolyGerritDev;
this.headless = headless || (!enableGwtUi && !enablePolyGerrit);
UiType defaultUi = enablePolyGerrit && !enableGwtUi ? UiType.POLYGERRIT : UiType.GWT;
String uiStr = firstNonNull(cfg.getString("gerrit", null, "ui"), defaultUi.name());
this.defaultUi = firstNonNull(UiType.parse(uiStr), UiType.NONE);
switch (defaultUi) {
case GWT:
checkArgument(enableGwtUi, "gerrit.ui = %s but GWT UI is disabled", defaultUi);
break;
case POLYGERRIT:
checkArgument(enablePolyGerrit, "gerrit.ui = %s but PolyGerrit is disabled", defaultUi);
break;
case NONE:
default:
throw new IllegalArgumentException("invalid gerrit.ui: " + uiStr);
}
this.headless = headless;
}
public boolean headless() {
@@ -65,15 +41,7 @@ public class GerritOptions {
return !slave;
}
public boolean enablePolyGerrit() {
return !headless && enablePolyGerrit;
}
public boolean forcePolyGerritDev() {
return !headless && forcePolyGerritDev;
}
public UiType defaultUi() {
return defaultUi;
}
}

View File

@@ -314,12 +314,10 @@ public class GetServerInfo implements RestReadView<ConfigResource> {
info.editGpgKeys =
toBoolean(enableSignedPush && cfg.getBoolean("gerrit", null, "editGpgKeys", true));
info.webUis = EnumSet.noneOf(UiType.class);
info.webUis.add(UiType.POLYGERRIT);
if (gerritOptions.enableGwtUi()) {
info.webUis.add(UiType.GWT);
}
if (gerritOptions.enablePolyGerrit()) {
info.webUis.add(UiType.POLYGERRIT);
}
return info;
}

View File

@@ -115,9 +115,6 @@ public class ServerInfoIT extends AbstractDaemonTest {
assertThat(i.gerrit.reportBugUrl).isEqualTo("https://example.com/report");
assertThat(i.gerrit.reportBugText).isEqualTo("REPORT BUG");
// Acceptance tests force --headless even when UIs are specified in config.
assertThat(i.gerrit.webUis).isEmpty();
// plugin
assertThat(i.plugin.jsResourcePaths).isEmpty();