Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-73955] CSP support for DockerManagementServer #1107

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.nirima.jenkins.plugins.docker;

import com.github.dockerjava.api.DockerClient;
import com.nirima.jenkins.plugins.docker.utils.Consts;
import com.nirima.jenkins.plugins.docker.utils.JenkinsUtils;
import hudson.Extension;
import hudson.model.Describable;
Expand Down Expand Up @@ -72,10 +71,6 @@ public String asTime(Long time) {
return dt.toString();
}

public String getJsUrl(String jsName) {
return Consts.PLUGIN_JS_URL + jsName;
}

Comment on lines -75 to -78
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead code, as this is now served through a Stapler adjunct.

@SuppressWarnings("unused")
@RequirePOST
public void doControlSubmit(@QueryParameter("stopId") String stopId, StaplerRequest req, StaplerResponse rsp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,4 @@ public final class Consts {
* The base URL of the plugin images.
*/
public static final String PLUGIN_IMAGES_URL = PLUGIN_URL + "images/";

/**
* The base URL of the plugin javascripts.
*/
public static final String PLUGIN_JS_URL = PLUGIN_URL + "js/";
Comment on lines -13 to -17
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dead code, as this is now served through a Stapler adjunct.

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function stop(theId) {
var input = document.getElementById('stopId');
if (input != null) {
input.value = theId;
}

var form = document.getElementById('control');
form.submit();
}
Comment on lines +1 to +9
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code previously lived in src/main/webapp/js/docker-manage.js and has been moved without alteration. It has been moved here so it can be consumed through a Stapler adjunct.


document.addEventListener('DOMContentLoaded', () => {
const stopContainerButtons = document.querySelectorAll('#control .stop-container');
stopContainerButtons.forEach((button) =>
button.addEventListener('click', () => {
stop(button.dataset.id);
}),
);
});
Comment on lines +11 to +18
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout" xmlns:f="/lib/form"
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:l="/lib/layout" xmlns:f="/lib/form"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that the <st:> namespace can be used on line 6 below.

>
<l:layout title="${%Docker hosts}" norefresh="true" permission="${it.requiredPermission}">
<l:header>
<script src="${rootURL}${it.getJsUrl('docker-manage.js')}" type="text/javascript"></script>
<st:adjunct includes="com.nirima.jenkins.plugins.docker.DockerManagementServer.docker-manage"/>
<style type="text/css">
tr.disablehover:hover {
background-color: white;
Expand Down Expand Up @@ -52,7 +52,7 @@
</j:forEach>
</td>
<td>
<input type="button" value="stop" onclick="stop('${res.id}')"></input>
<input type="button" class="stop-container" value="stop" data-id="${res.id}"></input>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

</td>
</tr>
</j:forEach>
Expand Down
10 changes: 0 additions & 10 deletions src/main/webapp/js/docker-manage.js

This file was deleted.