Skip to content

Commit

Permalink
Merge pull request #80 from yaroslavafenkin/JENKINS-74100
Browse files Browse the repository at this point in the history
[JENKINS-74100] Extract inline JavaScript from `GitlabLogoProperty/global.jelly`
  • Loading branch information
sue445 authored Nov 19, 2024
2 parents 01cb43f + dd3da7d commit 9d2696e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
window.addEventListener("DOMContentLoaded", () => {
document.querySelector(".gll-clear-cache-button").addEventListener("click", (event) => {
event.preventDefault();
const { rootUrl } = event.target.dataset;

fetch(`${rootURL}/descriptor/org.jenkinsci.plugins.gitlablogo.GitlabLogoProperty/clearCache`, {
method: "post",
headers: crumb.wrap({}),
}).then((rsp) => {
if (rsp.ok) {
notificationBar.show("Clear cache done", notificationBar.SUCCESS);
}
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
tags they use. Views are always organized according to its owner class,
so it should be straightforward to find them.
-->
<st:adjunct includes="org.jenkinsci.plugins.gitlablogo.GitlabLogoProperty.clear-cache"/>
<f:section title="GitLab Account Setting">
<f:entry title="Endpoint URL" field="endpointUrl">
<f:textbox />
Expand All @@ -20,21 +21,7 @@
<f:password />
</f:entry>
<f:entry title="Clear cache" field="clearCache">
<input type="button" value="clear" onclick="GitlabLogoProperty.clearCache();"/>
<button data-root-url="${rootURL}" class="jenkins-button gll-clear-cache-button">Clear</button>
</f:entry>
<script>
var GitlabLogoProperty = {
clearCache: function(){
fetch("${rootURL}/descriptor/org.jenkinsci.plugins.gitlablogo.GitlabLogoProperty/clearCache", {
method: "post",
headers: crumb.wrap({}),
}).then((rsp) => {
if (rsp.ok) {
alert("Clear cache done");
}
});
}
};
</script>
</f:section>
</j:jelly>

0 comments on commit 9d2696e

Please sign in to comment.