mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 21:42:27 +00:00
Show the warning & config only when it's relevant
This commit is contained in:
1 parent
5db8cecae3
commit
062f9d4845
3 files changed
+26
-10
No files matched your search
@@ -3,6 +3,7 @@ package jenkins.security.admin;
|
||||
import hudson.Extension;
|
||||
import jenkins.model.GlobalConfiguration;
|
||||
import jenkins.model.GlobalConfigurationCategory;
|
||||
import jenkins.model.Jenkins;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
|
||||
@@ -19,6 +20,9 @@ public class MasterKillSwitchConfiguration extends GlobalConfiguration {
|
||||
@Inject
|
||||
AdminWhitelistRule rule;
|
||||
|
||||
@Inject
|
||||
Jenkins jenkins;
|
||||
|
||||
@Override
|
||||
public GlobalConfigurationCategory getCategory() {
|
||||
return GlobalConfigurationCategory.get(GlobalConfigurationCategory.Security.class);
|
||||
@@ -30,8 +34,22 @@ public class MasterKillSwitchConfiguration extends GlobalConfiguration {
|
||||
|
||||
@Override
|
||||
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
|
||||
rule.setMasterKillSwitch(!json.has("masterToSlaveAccessControl"));
|
||||
if (isRelevant()) {
|
||||
// don't record on/off unless this becomes relevant, so that we can differentiate
|
||||
// those who have disabled vs those who haven't cared.
|
||||
rule.setMasterKillSwitch(!json.has("masterToSlaveAccessControl"));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the configuration of this subsystem becomes relevant.
|
||||
* Unless this option is relevant, we don't let users choose this.
|
||||
*/
|
||||
public boolean isRelevant() {
|
||||
return jenkins.getComputers().length>1 // if there's no slave, there's no point
|
||||
&& jenkins.isUseSecurity() // if security is off, likewise this is pointless
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package jenkins.security.admin;
|
||||
|
||||
import hudson.Extension;
|
||||
import hudson.model.AdministrativeMonitor;
|
||||
import jenkins.model.Jenkins;
|
||||
import org.kohsuke.stapler.HttpResponse;
|
||||
import org.kohsuke.stapler.HttpResponses;
|
||||
import org.kohsuke.stapler.QueryParameter;
|
||||
@@ -22,14 +21,11 @@ public class MasterKillSwitchWarning extends AdministrativeMonitor {
|
||||
AdminWhitelistRule rule;
|
||||
|
||||
@Inject
|
||||
Jenkins jenkins;
|
||||
MasterKillSwitchConfiguration config;
|
||||
|
||||
@Override
|
||||
public boolean isActivated() {
|
||||
return rule.getMasterKillSwitch()
|
||||
&& jenkins.getComputers().length>1 // if there's no slave, there's no point
|
||||
&& jenkins.isUseSecurity() // if security is off, likewise this is pointless
|
||||
;
|
||||
return rule.getMasterKillSwitch() && config.isRelevant();
|
||||
}
|
||||
|
||||
public HttpResponse doAct(@QueryParameter String dismiss) throws IOException {
|
||||
|
||||
Reference in new issue
Block a user