diff --git a/core/src/main/java/jenkins/model/GlobalCloudConfiguration.java b/core/src/main/java/jenkins/model/GlobalCloudConfiguration.java index 9c6635ab05e1a4ae09898adaf722e5d6b1a58779..9ac2222ad5771a8684f461d0780fd099b6660e23 100644 --- a/core/src/main/java/jenkins/model/GlobalCloudConfiguration.java +++ b/core/src/main/java/jenkins/model/GlobalCloudConfiguration.java @@ -1,30 +1,56 @@ package jenkins.model; import hudson.Extension; +import hudson.RestrictedSince; +import hudson.model.Descriptor; +import hudson.model.RootAction; import hudson.slaves.Cloud; +import hudson.util.FormApply; import net.sf.json.JSONObject; import org.jenkinsci.Symbol; +import org.kohsuke.accmod.Restricted; +import org.kohsuke.accmod.restrictions.NoExternalUse; import org.kohsuke.stapler.StaplerRequest; +import org.kohsuke.stapler.StaplerResponse; +import org.kohsuke.stapler.verb.POST; +import javax.annotation.CheckForNull; +import javax.servlet.ServletException; import java.io.IOException; /** - * Adds the {@link Cloud} configuration to the system config page. + * Provides a configuration form for {@link Jenkins#clouds}. * - *

- * This object just acts as a proxy to configure {@link Jenkins#clouds} - * - * @author Kohsuke Kawaguchi + * Has been overhauled in Jenkins 2.XXX to no longer contribute to Configure System, but be a standalone form. */ -@Extension(ordinal=-100) @Symbol("cloud") // historically this was placed at the very end of the configuration page -public class GlobalCloudConfiguration extends GlobalConfiguration { +@Extension +@Symbol("cloud") +@Restricted(NoExternalUse.class) +@RestrictedSince("TODO") +public class GlobalCloudConfiguration implements RootAction { + + @CheckForNull + @Override + public String getIconFileName() { + return null; + } + + @CheckForNull @Override - public boolean configure(StaplerRequest req, JSONObject json) throws FormException { - try { - Jenkins.get().clouds.rebuildHetero(req,json, Cloud.all(), "cloud"); - return true; - } catch (IOException e) { - throw new FormException(e,"clouds"); - } + public String getDisplayName() { + return Messages.GlobalCloudConfiguration_DisplayName(); + } + + @Override + public String getUrlName() { + return "configureClouds"; + } + + @POST + public void doConfigure(StaplerRequest req, StaplerResponse rsp) throws Descriptor.FormException, IOException, ServletException { + Jenkins.get().checkPermission(Jenkins.ADMINISTER); + JSONObject json = req.getSubmittedForm(); + Jenkins.get().clouds.rebuildHetero(req,json, Cloud.all(), "cloud"); + FormApply.success(req.getContextPath() + "/manage").generateResponse(req, rsp, null); } } diff --git a/core/src/main/resources/hudson/model/ComputerSet/sidepanel.jelly b/core/src/main/resources/hudson/model/ComputerSet/sidepanel.jelly index 59973506f50f0f3f906dd2f9f610b9c82148dc57..1a9a25722591a7b4842fa5b95564c3a27de0cb99 100644 --- a/core/src/main/resources/hudson/model/ComputerSet/sidepanel.jelly +++ b/core/src/main/resources/hudson/model/ComputerSet/sidepanel.jelly @@ -34,7 +34,8 @@ THE SOFTWARE. - + + diff --git a/core/src/main/resources/jenkins/management/Messages.properties b/core/src/main/resources/jenkins/management/Messages.properties index ce99fecf142252d3cc77ce69fa8781d8abb546fc..8e5e595a830b76a7788f1b52feaa4e769ce7d978 100644 --- a/core/src/main/resources/jenkins/management/Messages.properties +++ b/core/src/main/resources/jenkins/management/Messages.properties @@ -50,7 +50,7 @@ CliLink.Description=Access/manage Jenkins from your shell, or from your script. ConsoleLink.DisplayName=Script Console ConsoleLink.Description=Executes arbitrary script for administration/trouble-shooting/diagnostics. -NodesLink.DisplayName=Manage Nodes +NodesLink.DisplayName=Manage Nodes and Clouds NodesLink.Description=Add, remove, control and monitor the various nodes that Jenkins runs jobs on. ShutdownLink.DisplayName_prepare=Prepare for Shutdown diff --git a/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config.groovy b/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config.groovy deleted file mode 100644 index ac31668d48b73b2d83e1c93e4bb8a204e0eb2ca5..0000000000000000000000000000000000000000 --- a/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config.groovy +++ /dev/null @@ -1,16 +0,0 @@ -package jenkins.model.GlobalCloudConfiguration - -import hudson.slaves.Cloud - -def f=namespace(lib.FormTagLib) - -def clouds = Cloud.all() - -if (!clouds.isEmpty()) { - f.section(title:_("Cloud")) { - f.block { - f.hetero_list(name:"cloud", hasHeader:true, descriptors:Cloud.all(), items:app.clouds, - addCaption:_("Add a new cloud"), deleteCaption:_("Delete cloud")) - } - } -} diff --git a/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index.groovy b/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index.groovy new file mode 100644 index 0000000000000000000000000000000000000000..0d0657763efa3c9601c4991345a862bcbefa0493 --- /dev/null +++ b/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index.groovy @@ -0,0 +1,51 @@ +package jenkins.model.GlobalCloudConfiguration + +import hudson.slaves.Cloud + + +def f = namespace(lib.FormTagLib) +def l = namespace(lib.LayoutTagLib) +def st = namespace("jelly:stapler") + +l.layout(norefresh:true, permission:app.ADMINISTER, title:my.displayName) { + l.side_panel { + l.tasks { + l.task(icon:"icon-up icon-md", href:rootURL+'/', title:_("Back to Dashboard")) + l.task(icon:"icon-gear2 icon-md", href:"${rootURL}/computer/", title:_("Manage Nodes")) + } + } + l.main_panel { + h1 { + l.icon(class: 'icon-health-40to59 icon-xlg') + // TODO more appropriate icon + text(my.displayName) + } + + def clouds = Cloud.all() + + if (!clouds.isEmpty()) { + p() + div(class:"behavior-loading", _("LOADING")) + + f.form(method:"post",name:"config",action:"configure") { + f.block { + f.hetero_list(name:"cloud", hasHeader:true, descriptors:Cloud.all(), items:app.clouds, + addCaption:_("Add a new cloud"), deleteCaption:_("Delete cloud")) + } + + f.bottomButtonBar { + f.submit(value:_("Save")) + f.apply(value:_("Apply")) + } + } + st.adjunct(includes: "lib.form.confirm") + } else { + p { + _("There are no cloud implementations for dynamically allocated agents installed.") + a(href: rootURL + "/pluginManager/available") { + _("Go to plugin manager.") + } + } + } + } +} diff --git a/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config_da.properties b/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index_da.properties similarity index 100% rename from core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config_da.properties rename to core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index_da.properties diff --git a/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config_de.properties b/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index_de.properties similarity index 100% rename from core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config_de.properties rename to core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index_de.properties diff --git a/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config_es.properties b/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index_es.properties similarity index 100% rename from core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config_es.properties rename to core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index_es.properties diff --git a/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config_fr.properties b/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index_fr.properties similarity index 100% rename from core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config_fr.properties rename to core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index_fr.properties diff --git a/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config_it.properties b/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index_it.properties similarity index 100% rename from core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config_it.properties rename to core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index_it.properties diff --git a/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config_ja.properties b/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index_ja.properties similarity index 100% rename from core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config_ja.properties rename to core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index_ja.properties diff --git a/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config_pt_BR.properties b/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index_pt_BR.properties similarity index 100% rename from core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config_pt_BR.properties rename to core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index_pt_BR.properties diff --git a/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config_sr.properties b/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index_sr.properties similarity index 100% rename from core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config_sr.properties rename to core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index_sr.properties diff --git a/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config_zh_TW.properties b/core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index_zh_TW.properties similarity index 100% rename from core/src/main/resources/jenkins/model/GlobalCloudConfiguration/config_zh_TW.properties rename to core/src/main/resources/jenkins/model/GlobalCloudConfiguration/index_zh_TW.properties diff --git a/core/src/main/resources/jenkins/model/Jenkins/_cloud-note.groovy b/core/src/main/resources/jenkins/model/Jenkins/_cloud-note.groovy new file mode 100644 index 0000000000000000000000000000000000000000..9b4a929d975dad0a1f7f7cb9da348c01ea49ef87 --- /dev/null +++ b/core/src/main/resources/jenkins/model/Jenkins/_cloud-note.groovy @@ -0,0 +1,19 @@ +package jenkins.model.Jenkins + +import hudson.slaves.Cloud + +// TODO remove this once it's been long enough that users got used to this. + +def f = namespace(lib.FormTagLib) + +def clouds = Cloud.all() + +if (!clouds.isEmpty()) { + f.section(title: _("Cloud")) { + f.block { + div(class: 'alert alert-info') { + raw(_("note", rootURL)) + } + } + } +} diff --git a/core/src/main/resources/jenkins/model/Jenkins/_cloud-note.properties b/core/src/main/resources/jenkins/model/Jenkins/_cloud-note.properties new file mode 100644 index 0000000000000000000000000000000000000000..d9cada5eb8e27a51d283068a85222afb9f68dde6 --- /dev/null +++ b/core/src/main/resources/jenkins/model/Jenkins/_cloud-note.properties @@ -0,0 +1 @@ +note=The cloud configuration has moved to a separate configuration page. diff --git a/core/src/main/resources/jenkins/model/Jenkins/configure.jelly b/core/src/main/resources/jenkins/model/Jenkins/configure.jelly index a6154bbc4e243b57d5826a082b64c503a854d0c2..a85ab58ade6291cf3fa32cb6c15fd551eca9afa3 100644 --- a/core/src/main/resources/jenkins/model/Jenkins/configure.jelly +++ b/core/src/main/resources/jenkins/model/Jenkins/configure.jelly @@ -52,6 +52,8 @@ THE SOFTWARE. + + diff --git a/core/src/main/resources/jenkins/model/Messages.properties b/core/src/main/resources/jenkins/model/Messages.properties index c07ec98272088da073fde9a2640dbb0bb235006b..eb5effcbfdc0e2e944d664f5a14e179fd47b71b8 100644 --- a/core/src/main/resources/jenkins/model/Messages.properties +++ b/core/src/main/resources/jenkins/model/Messages.properties @@ -74,3 +74,5 @@ BuildDiscarderProperty.displayName=Discard old builds EnforceSlaveAgentPortAdministrativeMonitor.displayName=Enforce TCP Agent Port CLI.disable-job.shortDescription=Disables a job. CLI.enable-job.shortDescription=Enables a job. + +GlobalCloudConfiguration.DisplayName=Configure Clouds