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-73969] [JENKINS-73970] Remove inline JavaScript to become CSP compliant #72

Merged
merged 8 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 7 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
Expand Up @@ -6,7 +6,10 @@
<j:invokeStatic className="hudson.views.ViewGraph" method="toName" var="thisViewName">
<j:arg value="${it}" type="hudson.model.View"/>
</j:invokeStatic>
<f:select checkUrl="'${rootURL}/descriptorByName/hudson.views.OtherViewsFilter/checkOtherViewName?otherViewName=' + encodeURIComponent((this.options.length == 0) ? '' : this.options[this.selectedIndex].value) + '&amp;viewName=' + encodeURIComponent('${h.jsStringEscape(thisViewName)}')"/>
<f:invisibleEntry>
<f:textbox name="viewName" value="${thisViewName}"/>
</f:invisibleEntry>
<f:select checkUrl="${rootURL}/descriptorByName/hudson.views.OtherViewsFilter/checkOtherViewName" checkDependsOn="viewName otherViewName"/>
</f:entry>
<st:include page="config.jelly" class="hudson.views.AbstractIncludeExcludeJobFilter" optional="false"/>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
xmlns:i="jelly:fmt" xmlns:p="/lib/hudson/project">
<f:entry title="${%Regular Expression}:">
<f:textbox name="regex" field="regex" checkUrl="'${rootURL}/descriptorByName/hudson.views.RegExJobFilter/checkRegex?value='+encodeURIComponent(this.value)"/>
<f:textbox name="regex" field="regex" checkUrl="${rootURL}/descriptorByName/hudson.views.RegExJobFilter/checkRegex" checkDependsOn=""/>
mawinter69 marked this conversation as resolved.
Show resolved Hide resolved
</f:entry>
<f:entry title="${%Match Value}:">
<div class="valueType">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
<j:invokeStatic className="hudson.views.ViewGraph" method="toName" var="thisViewName">
<j:arg value="${it}" type="hudson.model.View"/>
</j:invokeStatic>
<f:invisibleEntry>
<f:textbox name="viewName" value="${thisViewName}"/>
</f:invisibleEntry>
<f:entry>
<div style="display:none">
<f:textbox name="dummy" checkUrl="'${rootURL}/descriptorByName/hudson.views.UnclassifiedJobsFilter/check?viewName=' + encodeURIComponent('${h.jsStringEscape(thisViewName)}')"/>
<f:textbox name="dummy" checkUrl="${rootURL}/descriptorByName/hudson.views.UnclassifiedJobsFilter/check" checkDependsOn="viewName"/>
</div>
</f:entry>
<st:include page="config.jelly" class="hudson.views.AbstractIncludeExcludeJobFilter" optional="false"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,11 @@
</div>
<div>
<f:checkbox title="${%Match jobs with builds 'started by' user}" name="matchBuilder" field="matchBuilder" default="true"
onclick="showOrHideBuildOptions(this)"/>
class="showOrHideBuildOptions"/>
</div>
<div>
<f:checkbox title="${%Match jobs with builds where user is source code committer}" name="matchScmChanges" field="matchScmChanges"
default="true" onclick="showOrHideBuildOptions(this)"/>
</div>
<div class="showOrHideBuildOptions">
<script>
function showOrHideBuildOptions(elem) {
var jobFilter = elem.closest('[name="jobFilters"]');
var matchBuilder = jobFilter.querySelector('[name="matchBuilder"]');
var matchScmChanges = jobFilter.querySelector('[name="matchScmChanges"]');

var tr2 = jobFilter.querySelector('[name="buildCountTypeString"]').parentElement.parentElement.parentElement;
var tr3 = jobFilter.querySelector('[name="amountTypeString"]').parentElement.parentElement.parentElement;

if (matchBuilder.checked || matchScmChanges.checked) {
tr2.classList.remove('jenkins-hidden');
tr3.classList.remove('jenkins-hidden');
} else {
tr2.classList.add('jenkins-hidden');
tr3.classList.add('jenkins-hidden');
}
}
</script>
class="showOrHideBuildOptions"/>
</div>
</f:entry>
<f:entry title="${%Build trend type}:">
Expand All @@ -66,7 +46,5 @@
</div>
</f:entry>
<st:include page="config.jelly" class="hudson.views.AbstractBuildTrendFilter" optional="false"/>
<script>
Array.prototype.forEach.call(document.querySelectorAll('.showOrHideBuildOptions'), showOrHideBuildOptions);
</script>
<st:adjunct includes="hudson.views.UserRelevanceFilter.showOptions"/>
</j:jelly>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function showOrHideBuildOptions(elem) {
var jobFilter = elem.closest('[name="jobFilters"]');
var matchBuilder = jobFilter.querySelector('[name="matchBuilder"]');
var matchScmChanges = jobFilter.querySelector('[name="matchScmChanges"]');

var tr2 = jobFilter.querySelector('[name="buildCountTypeString"]').parentElement.parentElement.parentElement;
var tr3 = jobFilter.querySelector('[name="amountTypeString"]').parentElement.parentElement.parentElement;

if (matchBuilder.checked || matchScmChanges.checked) {
tr2.classList.remove("jenkins-hidden");
tr3.classList.remove("jenkins-hidden");
} else {
tr2.classList.add("jenkins-hidden");
tr3.classList.add("jenkins-hidden");
}
}

Behaviour.specify(".showOrHideBuildOptions", "showOrHideBuildOptions", 0, function (element) {
element.addEventListener("click", function () {
showOrHideBuildOptions(element);
};
showOrHideBuildOptions(element);
});