Permalink
Please sign in to comment.
Showing
with
81 additions
and 57 deletions.
- +20 −4 src/main/java/org/jenkinsci/plugins/configfiles/buildwrapper/ManagedFile.java
- +30 −0 src/main/java/org/jenkinsci/plugins/configfiles/utils/ConfigFileDetailLinkDescription.java
- +31 −0 src/main/java/org/jenkinsci/plugins/configfiles/utils/DescriptionResponse.java
- +0 −31 src/main/resources/org/jenkinsci/plugins/configfiles/buildwrapper/ManagedFile/config.jelly
- +0 −22 src/main/webapp/js/fileprovider.js
@@ -0,0 +1,30 @@ | |||
package org.jenkinsci.plugins.configfiles.utils; | |||
|
|||
import hudson.model.Item; | |||
import jenkins.model.Jenkins; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.kohsuke.stapler.StaplerRequest; | |||
|
|||
public class ConfigFileDetailLinkDescription extends DescriptionResponse { | |||
private ConfigFileDetailLinkDescription(String linkHtml) { | |||
super(linkHtml); | |||
} | |||
|
|||
public static ConfigFileDetailLinkDescription getDescription(StaplerRequest req, Item context, String fileId) { | |||
return new ConfigFileDetailLinkDescription(getDetailsLink(req, context, fileId)); | |||
} | |||
|
|||
private static String getDetailsLink(StaplerRequest req, Item context, String fileId) { | |||
String link = req.getContextPath(); | |||
link = StringUtils.isNotBlank(context.getUrl()) ? link + "/" + context.getUrl() : link; | |||
link = link + "configfiles/show?id=" + fileId; | |||
String linkHtml = "<a target=\"_blank\" href=\"" + link + "\">view selected file</a>"; | |||
|
|||
// 1x16 spacer needed for IE since it doesn't support min-height | |||
return "<div class='ok'><img src='" + | |||
req.getContextPath() + Jenkins.RESOURCE_PATH + "/images/none.gif' height=16 width=1>" + | |||
linkHtml + "</div>"; | |||
|
|||
} | |||
|
|||
} |
@@ -0,0 +1,31 @@ | |||
package org.jenkinsci.plugins.configfiles.utils; | |||
|
|||
import hudson.util.FormValidation; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.kohsuke.stapler.HttpResponse; | |||
import org.kohsuke.stapler.StaplerRequest; | |||
import org.kohsuke.stapler.StaplerResponse; | |||
|
|||
import javax.servlet.ServletException; | |||
import java.io.IOException; | |||
|
|||
/** | |||
* Can be used instead of a {@link FormValidation#ok(String)} to give the user some information about | |||
* the item to checked (e.g. a selection in a dropdown) | |||
*/ | |||
public class DescriptionResponse implements HttpResponse { | |||
|
|||
private String html = "div/>"; | |||
|
|||
public DescriptionResponse(String html) { | |||
if (StringUtils.isNotBlank(html)) { | |||
this.html = html; | |||
} | |||
} | |||
|
|||
@Override | |||
public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException { | |||
rsp.setContentType("text/html;charset=UTF-8"); | |||
rsp.getWriter().print(html); | |||
} | |||
} |
0 comments on commit
e76f2e5