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-71578] allow making sidepanel sticky #8269

Merged
merged 9 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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 @@ -27,7 +27,7 @@ THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<l:side-panel>
<l:side-panel sticky="true">
<l:tasks>
<l:task href="${rootURL}/manage/pluginManager/" icon="symbol-download" title="${%Updates}" badge="${app.updateCenter.badge}"/>
<l:task href="${rootURL}/manage/pluginManager/available" icon="symbol-shopping-bag" title="${%Available plugins}"/>
Expand Down
8 changes: 8 additions & 0 deletions core/src/main/resources/lib/layout/side-panel.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,17 @@ THE SOFTWARE.
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define">
<st:documentation>
Generates a left side content as part of a Jenkins page. Typically known as two-column or left-side + main-content layouts
<st:attribute name="sticky">
Make the side panel sticky. Should not be used on pages that include widgets in the sidepanel and when plugins can
add their own tasks, so the number of tasks is not fixed.
</st:attribute>

</st:documentation>

<j:if test="${mode=='side-panel'}">
<j:if test="${attrs.sticky == 'true'}">
<script src="${resURL}/jsbundles/sticky-sidepanel.js" type="text/javascript" defer="true" />
</j:if>
<d:invokeBody />
</j:if>

Expand Down
4 changes: 4 additions & 0 deletions war/src/main/js/sticky-sidepanel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
window.addEventListener("load", function () {
const sidebar = document.querySelector("#side-panel");
sidebar.classList.add("app-page-body__sidebar--sticky");
});
3 changes: 3 additions & 0 deletions war/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ module.exports = (env, argv) => ({
],
"simple-page": [path.join(__dirname, "src/main/scss/simple-page.scss")],
styles: [path.join(__dirname, "src/main/scss/styles.scss")],
"sticky-sidepanel": [
path.join(__dirname, "src/main/js/sticky-sidepanel.js"),
],
},
output: {
path: path.join(__dirname, "src/main/webapp/jsbundles"),
Expand Down