Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-42877] Reuse jelly and properties files for configuration in…
… jenkins root and folders.
  • Loading branch information
Evaristo Gutiérrez committed Apr 3, 2017
1 parent a22f855 commit afdeba4
Show file tree
Hide file tree
Showing 27 changed files with 51 additions and 364 deletions.
Expand Up @@ -91,6 +91,13 @@ public String getIconUrl(String rootUrl) {
return rootUrl + ICON_PATH;
}

/**
* used by configfiles.jelly to gather the class to be referenced when loading jelly files
*/
public Class getJellyFilesClass() {
return ConfigFilesUIContract.class;
}

/**
* @see hudson.model.ManagementLink#getUrlName()
*/
Expand Down Expand Up @@ -145,7 +152,7 @@ public void doShow(StaplerRequest req, StaplerResponse rsp, @QueryParameter("id"
Config config = store.getById(confgiId);
req.setAttribute("contentType", config.getProvider().getContentType());
req.setAttribute("config", config);
req.getView(this, "show.jelly").forward(req, rsp);
req.getView(ConfigFilesUIContract.class, "show.jelly").forward(req, rsp);

}

Expand All @@ -168,7 +175,7 @@ public void doEditConfig(StaplerRequest req, StaplerResponse rsp, @QueryParamete
req.setAttribute("contentType", config.getProvider().getContentType());
req.setAttribute("config", config);
req.setAttribute("provider", config.getProvider());
req.getView(this, "edit.jelly").forward(req, rsp);
req.getView(ConfigFilesUIContract.class, "edit.jelly").forward(req, rsp);
}

/**
Expand Down Expand Up @@ -198,7 +205,7 @@ public void doAddConfig(StaplerRequest req, StaplerResponse rsp, @QueryParameter
checkPermission(Hudson.ADMINISTER);
req.setAttribute("providers", ConfigProvider.all());
req.setAttribute("configId", configId);
req.getView(this, "selectprovider.jelly").forward(req, rsp);
req.getView(ConfigFilesUIContract.class, "selectprovider.jelly").forward(req, rsp);
return;
}

Expand All @@ -218,14 +225,14 @@ public void doAddConfig(StaplerRequest req, StaplerResponse rsp, @QueryParameter
config.setProviderId(provider.getProviderId());
req.setAttribute("config", config);

req.getView(this, "edit.jelly").forward(req, rsp);
req.getView(ConfigFilesUIContract.class, "edit.jelly").forward(req, rsp);
}

public void doSelectProvider(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
checkPermission(Hudson.ADMINISTER);
req.setAttribute("providers", ConfigProvider.all());
req.setAttribute("configId", UUID.randomUUID().toString());
req.getView(this, "selectprovider.jelly").forward(req, rsp);
req.getView(ConfigFilesUIContract.class, "selectprovider.jelly").forward(req, rsp);
}

private void checkPermission(Permission permission) {
Expand Down
Expand Up @@ -23,13 +23,7 @@ of this software and associated documentation files (the "Software"), to deal
*/
package org.jenkinsci.plugins.configfiles;

import hudson.Extension;
import hudson.Util;
import hudson.model.Hudson;
import hudson.model.ManagementLink;
import hudson.security.Permission;
import hudson.util.FormValidation;
import net.sf.json.JSONObject;
import org.jenkinsci.lib.configprovider.ConfigProvider;
import org.jenkinsci.lib.configprovider.model.Config;
import org.jenkinsci.lib.configprovider.model.ContentType;
Expand Down
Expand Up @@ -50,6 +50,13 @@ public String getIconUrl(String rootUrl) {
return rootUrl + ConfigFilesManagement.ICON_PATH;
}

/**
* used by configfiles.jelly to gather the class to be referenced when loading jelly files
*/
public Class getJellyFilesClass() {
return ConfigFilesUIContract.class;
}

@Override
public String getDisplayName() {
return "Config Files";
Expand Down Expand Up @@ -125,7 +132,7 @@ public void doShow(StaplerRequest req, StaplerResponse rsp, @QueryParameter("id"
Config config = getStore().getById(confgiId);
req.setAttribute("contentType", config.getProvider().getContentType());
req.setAttribute("config", config);
req.getView(this, "show.jelly").forward(req, rsp);
req.getView(ConfigFilesUIContract.class, "show.jelly").forward(req, rsp);
}

@Override
Expand All @@ -135,7 +142,7 @@ public void doEditConfig(StaplerRequest req, StaplerResponse rsp, @QueryParamete
req.setAttribute("contentType", config.getProvider().getContentType());
req.setAttribute("config", config);
req.setAttribute("provider", config.getProvider());
req.getView(this, "edit.jelly").forward(req, rsp);
req.getView(ConfigFilesUIContract.class, "edit.jelly").forward(req, rsp);
}


Expand All @@ -155,7 +162,7 @@ public void doAddConfig(StaplerRequest req, StaplerResponse rsp, @QueryParameter
checkPermission(Job.CONFIGURE);
req.setAttribute("providers", getProviders());
req.setAttribute("configId", configId);
req.getView(this, "selectprovider.jelly").forward(req, rsp);
req.getView(ConfigFilesUIContract.class, "selectprovider.jelly").forward(req, rsp);
return;
}

Expand All @@ -175,15 +182,15 @@ public void doAddConfig(StaplerRequest req, StaplerResponse rsp, @QueryParameter
config.setProviderId(provider.getProviderId());
req.setAttribute("config", config);

req.getView(this, "edit.jelly").forward(req, rsp);
req.getView(ConfigFilesUIContract.class, "edit.jelly").forward(req, rsp);
}

@Override
public void doSelectProvider(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {;
checkPermission(Job.CONFIGURE);
req.setAttribute("providers", getProviders());
req.setAttribute("configId", UUID.randomUUID().toString());
req.getView(this, "selectprovider.jelly").forward(req, rsp);
req.getView(ConfigFilesUIContract.class, "selectprovider.jelly").forward(req, rsp);
}

@Override
Expand Down
Expand Up @@ -26,20 +26,6 @@ THE SOFTWARE.
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:cf="/lib/configfiles">
<l:layout permission="${app.ADMINISTER}" norefresh="true">

<cf:sitepanel />

<l:main-panel>
<h1>
<img src="${it.getIconUrl(rootURL)}" alt="" />
<j:out value=" " />
${%Config File Management}
</h1>

<j:out value="${%intro}" />

<cf:configfiles groupedConfigs="${it.groupedConfigs}" />

</l:main-panel>
<st:include page="configfiles.jelly" class="${it.getJellyFilesClass()}" />
</l:layout>
</j:jelly>

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Expand Up @@ -22,23 +22,20 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->


<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:cf="/lib/configfiles">
<l:layout norefresh="true">

<cf:sitepanel />

<l:main-panel>
<h1>
<img width="48" height="48" src="${imagesURL}/16x16/document_edit.gif" />
<img width="16" height="16" src="${imagesURL}/16x16/empty.gif" />
<j:out value="${%filetype}" />
</h1>
<j:out value="${%selectprovider}" />

<cf:selectprovider providers="${providers}"/>

</l:main-panel>
</l:layout>
</j:jelly>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define"
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:cf="/lib/configfiles">
<cf:sitepanel />

<l:main-panel>
<h1>
<img src="${it.getIconUrl(rootURL)}" alt="" />
<j:out value=" " />
${%Config File Management}
</h1>

<j:out value="${%intro}" />

<cf:configfiles groupedConfigs="${it.groupedConfigs}" />
</l:main-panel>
</j:jelly>
@@ -1,4 +1,4 @@
# Copyright (c) 2011, Olivier Lamy
# Copyright (c) 2017, Dominik Bartholdi
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
Expand Down

0 comments on commit afdeba4

Please sign in to comment.