Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
- fix permission in job page
- don't show the button for built-in node
- improve jelly doc
  • Loading branch information
mawinter69 committed May 20, 2024
1 parent 83d5c7e commit 6a900a6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion core/src/main/resources/hudson/model/Job/index.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ THE SOFTWARE.
</h1>
</div>
<div class="jenkins-app-bar__controls">
<t:editDescriptionButton permission="${it.UPDATE}"/>
<t:editDescriptionButton permission="${it.CONFIGURE}"/>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:l="/lib/layout">
<st:documentation>
Renders a button to add/edit the description of an item. Typically used when the button should appear in the
app-bar instead of appearing below the description. To be used in combination with `editableDescription`.
<st:attribute name="permission" use="required">
If the current user doesn't have this permission, the description
is not editable.
Expand All @@ -15,7 +17,7 @@
<j:set var="actualDescription" value="${description}" defaultValue="${it.description}"/>
<l:hasPermission permission="${permission}">
<st:adjunct includes="lib.hudson.editable-description"/>
<a class="jenkins-button" id="description-link" href="editDescription" data-description="${actualDescription}" data-url="${submissionUrl}">
<a class="jenkins-button jenkins-hidden" id="description-link" href="editDescription" data-description="${actualDescription}" data-url="${submissionUrl}">
<l:icon src="symbol-edit" />
<j:choose>
<j:when test="${empty(actualDescription)}">
Expand Down
18 changes: 11 additions & 7 deletions core/src/main/resources/lib/hudson/editable-description.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
(function () {
document.addEventListener("DOMContentLoaded", function () {
let descriptionLink = document.querySelector("#description-link");
descriptionLink.addEventListener("click", function (e) {
e.preventDefault();
descriptionLink.classList.add("jenkins-hidden");
let url = descriptionLink.getAttribute("data-url");
let description = descriptionLink.getAttribute("data-description");
return replaceDescription(description, url);
});
let description = document.getElementById("description");
if (description != null) {
descriptionLink.classList.remove("jenkins-hidden");
descriptionLink.addEventListener("click", function (e) {
e.preventDefault();
descriptionLink.classList.add("jenkins-hidden");
let url = descriptionLink.getAttribute("data-url");
let description = descriptionLink.getAttribute("data-description");
return replaceDescription(description, url);
});
}
});
})();
3 changes: 2 additions & 1 deletion core/src/main/resources/lib/hudson/editableDescription.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ THE SOFTWARE.
Optional submission URL. If not specified, will use 'submitDescription'.
</st:attribute>
<st:attribute name="hideButton">
Hide the add/edit description button. To be used when the button is provided via the app bar.
Hide the add/edit description button. Set to true when the button is provided via the app bar.
See 'editDescriptionButton'
</st:attribute>
</st:documentation>

Expand Down

0 comments on commit 6a900a6

Please sign in to comment.