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:
parent
ba2e453920
commit
fb3e5b43b8
@ -53,6 +53,7 @@ public class GerritConfig implements Cloneable {
|
||||
protected int suggestFrom;
|
||||
protected int changeUpdateDelay;
|
||||
protected AccountGeneralPreferences.ChangeScreen changeScreen;
|
||||
protected boolean index;
|
||||
|
||||
public String getLoginUrl() {
|
||||
return loginUrl;
|
||||
@ -280,4 +281,12 @@ public class GerritConfig implements Cloneable {
|
||||
public void setChangeScreen(AccountGeneralPreferences.ChangeScreen ui) {
|
||||
this.changeScreen = ui;
|
||||
}
|
||||
|
||||
public boolean hasIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(boolean index) {
|
||||
this.index = index;
|
||||
}
|
||||
}
|
||||
|
@ -190,38 +190,40 @@ class RelatedChanges extends TabPanel {
|
||||
}
|
||||
});
|
||||
|
||||
StringBuilder conflictsQuery = new StringBuilder();
|
||||
conflictsQuery.append("status:open");
|
||||
conflictsQuery.append(" ").append(op("conflicts", info.legacy_id().get()));
|
||||
conflictsQuery.append(" -age:1month");
|
||||
ChangeList.query(conflictsQuery.toString(),
|
||||
EnumSet.of(ListChangesOption.CURRENT_REVISION, ListChangesOption.CURRENT_COMMIT),
|
||||
new AsyncCallback<ChangeList>() {
|
||||
@Override
|
||||
public void onSuccess(ChangeList result) {
|
||||
JsArray<ChangeAndCommit> changes = convertChangeList(result);
|
||||
if (changes.length() > 0) {
|
||||
getTab().setTitle(Resources.M.conflictingChanges(changes.length()));
|
||||
getTab().setChanges(info.project(), revision, changes);
|
||||
if (Gerrit.getConfig().hasIndex()) {
|
||||
StringBuilder conflictsQuery = new StringBuilder();
|
||||
conflictsQuery.append("status:open");
|
||||
conflictsQuery.append(" ").append(op("conflicts", info.legacy_id().get()));
|
||||
conflictsQuery.append(" -age:1month");
|
||||
ChangeList.query(conflictsQuery.toString(),
|
||||
EnumSet.of(ListChangesOption.CURRENT_REVISION, ListChangesOption.CURRENT_COMMIT),
|
||||
new AsyncCallback<ChangeList>() {
|
||||
@Override
|
||||
public void onSuccess(ChangeList result) {
|
||||
JsArray<ChangeAndCommit> changes = convertChangeList(result);
|
||||
if (changes.length() > 0) {
|
||||
getTab().setTitle(Resources.M.conflictingChanges(changes.length()));
|
||||
getTab().setChanges(info.project(), revision, changes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable err) {
|
||||
getTab().setTitle(
|
||||
Resources.M.conflictingChanges(Resources.C.notAvailable()));
|
||||
getTab().setError(err.getMessage());
|
||||
}
|
||||
|
||||
private RelatedChangesTab getTab() {
|
||||
if (conflictingChangesTab == null) {
|
||||
conflictingChangesTab =
|
||||
createTab(Resources.C.conflictingChanges(),
|
||||
Resources.C.conflictingChangesTooltip());
|
||||
@Override
|
||||
public void onFailure(Throwable err) {
|
||||
getTab().setTitle(
|
||||
Resources.M.conflictingChanges(Resources.C.notAvailable()));
|
||||
getTab().setError(err.getMessage());
|
||||
}
|
||||
return conflictingChangesTab;
|
||||
}
|
||||
});
|
||||
|
||||
private RelatedChangesTab getTab() {
|
||||
if (conflictingChangesTab == null) {
|
||||
conflictingChangesTab =
|
||||
createTab(Resources.C.conflictingChanges(),
|
||||
Resources.C.conflictingChangesTooltip());
|
||||
}
|
||||
return conflictingChangesTab;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void setMaxHeight(int height) {
|
||||
|
@ -26,6 +26,7 @@ import com.google.gerrit.server.config.ConfigUtil;
|
||||
import com.google.gerrit.server.config.DownloadConfig;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
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.ssh.SshInfo;
|
||||
import com.google.inject.Inject;
|
||||
@ -49,6 +50,7 @@ class GerritConfigProvider implements Provider<GerritConfig> {
|
||||
private final GitWebConfig gitWebConfig;
|
||||
private final AllProjectsName wildProject;
|
||||
private final SshInfo sshInfo;
|
||||
private final IndexCollection indexCollection;
|
||||
|
||||
private EmailSender emailSender;
|
||||
private final ContactStore contactStore;
|
||||
@ -59,6 +61,7 @@ class GerritConfigProvider implements Provider<GerritConfig> {
|
||||
GerritConfigProvider(final Realm r, @GerritServerConfig final Config gsc,
|
||||
final AuthConfig ac, final GitWebConfig gwc, final AllProjectsName wp,
|
||||
final SshInfo si, final ContactStore cs,
|
||||
final IndexCollection ic,
|
||||
final ServletContext sc, final DownloadConfig dc,
|
||||
final @AnonymousCowardName String acn) {
|
||||
realm = r;
|
||||
@ -67,6 +70,7 @@ class GerritConfigProvider implements Provider<GerritConfig> {
|
||||
downloadConfig = dc;
|
||||
gitWebConfig = gwc;
|
||||
sshInfo = si;
|
||||
indexCollection = ic;
|
||||
wildProject = wp;
|
||||
contactStore = cs;
|
||||
servletContext = sc;
|
||||
@ -128,6 +132,7 @@ class GerritConfigProvider implements Provider<GerritConfig> {
|
||||
config.setChangeScreen(cfg.getEnum(
|
||||
"gerrit", null, "changeScreen",
|
||||
AccountGeneralPreferences.ChangeScreen.CHANGE_SCREEN2));
|
||||
config.setIndex(indexCollection.getSearchIndex() != null);
|
||||
|
||||
config.setReportBugUrl(cfg.getString("gerrit", null, "reportBugUrl"));
|
||||
if (config.getReportBugUrl() == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user