Show tab with conflicting changes only if secondary index is enabled

This tab makes use of the 'conflicts' operator which is only supported
if a secondary index is enabled.

Change-Id: I25cc023e10f10a80efce12c1a3e62a65cb8940f3
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin 2013-11-22 15:11:05 +01:00 committed by Shawn Pearce
parent ba2e453920
commit fb3e5b43b8
3 changed files with 45 additions and 29 deletions

View File

@ -53,6 +53,7 @@ public class GerritConfig implements Cloneable {
protected int suggestFrom; protected int suggestFrom;
protected int changeUpdateDelay; protected int changeUpdateDelay;
protected AccountGeneralPreferences.ChangeScreen changeScreen; protected AccountGeneralPreferences.ChangeScreen changeScreen;
protected boolean index;
public String getLoginUrl() { public String getLoginUrl() {
return loginUrl; return loginUrl;
@ -280,4 +281,12 @@ public class GerritConfig implements Cloneable {
public void setChangeScreen(AccountGeneralPreferences.ChangeScreen ui) { public void setChangeScreen(AccountGeneralPreferences.ChangeScreen ui) {
this.changeScreen = ui; this.changeScreen = ui;
} }
public boolean hasIndex() {
return index;
}
public void setIndex(boolean index) {
this.index = index;
}
} }

View File

@ -190,6 +190,7 @@ class RelatedChanges extends TabPanel {
} }
}); });
if (Gerrit.getConfig().hasIndex()) {
StringBuilder conflictsQuery = new StringBuilder(); StringBuilder conflictsQuery = new StringBuilder();
conflictsQuery.append("status:open"); conflictsQuery.append("status:open");
conflictsQuery.append(" ").append(op("conflicts", info.legacy_id().get())); conflictsQuery.append(" ").append(op("conflicts", info.legacy_id().get()));
@ -223,6 +224,7 @@ class RelatedChanges extends TabPanel {
} }
}); });
} }
}
void setMaxHeight(int height) { void setMaxHeight(int height) {
maxHeight = height - (getTabBar().getOffsetHeight() + 2 /* padding */); maxHeight = height - (getTabBar().getOffsetHeight() + 2 /* padding */);

View File

@ -26,6 +26,7 @@ import com.google.gerrit.server.config.ConfigUtil;
import com.google.gerrit.server.config.DownloadConfig; import com.google.gerrit.server.config.DownloadConfig;
import com.google.gerrit.server.config.GerritServerConfig; import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.contact.ContactStore; import com.google.gerrit.server.contact.ContactStore;
import com.google.gerrit.server.index.IndexCollection;
import com.google.gerrit.server.mail.EmailSender; import com.google.gerrit.server.mail.EmailSender;
import com.google.gerrit.server.ssh.SshInfo; import com.google.gerrit.server.ssh.SshInfo;
import com.google.inject.Inject; import com.google.inject.Inject;
@ -49,6 +50,7 @@ class GerritConfigProvider implements Provider<GerritConfig> {
private final GitWebConfig gitWebConfig; private final GitWebConfig gitWebConfig;
private final AllProjectsName wildProject; private final AllProjectsName wildProject;
private final SshInfo sshInfo; private final SshInfo sshInfo;
private final IndexCollection indexCollection;
private EmailSender emailSender; private EmailSender emailSender;
private final ContactStore contactStore; private final ContactStore contactStore;
@ -59,6 +61,7 @@ class GerritConfigProvider implements Provider<GerritConfig> {
GerritConfigProvider(final Realm r, @GerritServerConfig final Config gsc, GerritConfigProvider(final Realm r, @GerritServerConfig final Config gsc,
final AuthConfig ac, final GitWebConfig gwc, final AllProjectsName wp, final AuthConfig ac, final GitWebConfig gwc, final AllProjectsName wp,
final SshInfo si, final ContactStore cs, final SshInfo si, final ContactStore cs,
final IndexCollection ic,
final ServletContext sc, final DownloadConfig dc, final ServletContext sc, final DownloadConfig dc,
final @AnonymousCowardName String acn) { final @AnonymousCowardName String acn) {
realm = r; realm = r;
@ -67,6 +70,7 @@ class GerritConfigProvider implements Provider<GerritConfig> {
downloadConfig = dc; downloadConfig = dc;
gitWebConfig = gwc; gitWebConfig = gwc;
sshInfo = si; sshInfo = si;
indexCollection = ic;
wildProject = wp; wildProject = wp;
contactStore = cs; contactStore = cs;
servletContext = sc; servletContext = sc;
@ -128,6 +132,7 @@ class GerritConfigProvider implements Provider<GerritConfig> {
config.setChangeScreen(cfg.getEnum( config.setChangeScreen(cfg.getEnum(
"gerrit", null, "changeScreen", "gerrit", null, "changeScreen",
AccountGeneralPreferences.ChangeScreen.CHANGE_SCREEN2)); AccountGeneralPreferences.ChangeScreen.CHANGE_SCREEN2));
config.setIndex(indexCollection.getSearchIndex() != null);
config.setReportBugUrl(cfg.getString("gerrit", null, "reportBugUrl")); config.setReportBugUrl(cfg.getString("gerrit", null, "reportBugUrl"));
if (config.getReportBugUrl() == null) { if (config.getReportBugUrl() == null) {