Merge "Support to enable/disable the RTC integration in the UI"
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/rtc/RTCModule.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/rtc/RTCModule.java
index 2eefa6c..78cb4c6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/rtc/RTCModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/rtc/RTCModule.java
@@ -22,14 +22,18 @@
 import org.slf4j.LoggerFactory;
 
 import com.google.gerrit.common.ChangeListener;
+import com.google.gerrit.extensions.annotations.Exports;
 import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.extensions.registration.DynamicSet;
 import com.google.gerrit.server.config.GerritServerConfig;
+import com.google.gerrit.server.config.PluginConfigFactory;
+import com.google.gerrit.server.config.ProjectConfigEntry;
 import com.google.gerrit.server.git.validators.CommitValidationListener;
 import com.google.inject.AbstractModule;
 import com.google.inject.Inject;
 
 import com.googlesource.gerrit.plugins.hooks.its.ItsFacade;
+import com.googlesource.gerrit.plugins.hooks.its.ItsHookEnabledConfigEntry;
 import com.googlesource.gerrit.plugins.hooks.rtc.filters.RTCAddComment;
 import com.googlesource.gerrit.plugins.hooks.rtc.filters.RTCAddRelatedLinkToChangeId;
 import com.googlesource.gerrit.plugins.hooks.rtc.filters.RTCAddRelatedLinkToGitWeb;
@@ -43,12 +47,14 @@
 
   private final String pluginName;
   private final Config gerritConfig;
+  private final PluginConfigFactory pluginCfgFactory;
 
   @Inject
   public RTCModule(@PluginName String pluginName,
-      @GerritServerConfig final Config config) {
+      @GerritServerConfig Config config, PluginConfigFactory pluginCfgFactory) {
     this.pluginName = pluginName;
     this.gerritConfig = config;
+    this.pluginCfgFactory = pluginCfgFactory;
   }
 
   @Override
@@ -57,6 +63,11 @@
       LOG.info("RTC is configured as ITS");
       bind(ItsFacade.class).to(RTCItsFacade.class);
 
+      bind(ProjectConfigEntry.class)
+          .annotatedWith(Exports.named("enabled"))
+          .toInstance(new ItsHookEnabledConfigEntry(
+              pluginName, pluginCfgFactory));
+
       DynamicSet.bind(binder(), CommitValidationListener.class).to(
           ItsValidateComment.class);
 
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md
index ac8b4a9..65d30a3 100644
--- a/src/main/resources/Documentation/config.md
+++ b/src/main/resources/Documentation/config.md
@@ -42,6 +42,12 @@
 a project can enforce the RTC integration for all child projects by
 setting `plugin.its-rtc.enabled` to `enforced`.
 
+On the project info screen there is a dropdown list for the
+`plugin.its-rtc.enabled` parameter which offers the values `true`,
+`false`, `enforced` and `INHERIT`. Project owners can change this
+parameter and save it. If the RTC integration is enforced by a parent
+project the dropdown list is disabled.
+
 The RTC integration can be limited to specific branches by setting
 `plugin.its-rtc.branch`. The branches may be configured using explicit
 branch names, ref patterns, or regular expressions. Multiple branches