Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JENKINS-45399 fix link to view referenced config file
- Loading branch information
Showing
5 changed files
with
81 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/org/jenkinsci/plugins/configfiles/utils/ConfigFileDetailLinkDescription.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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>"; | ||
|
||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/org/jenkinsci/plugins/configfiles/utils/DescriptionResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.