Skip to content

Commit

Permalink
Disable dependents toggle in plugin manager with system read (#9463)
Browse files Browse the repository at this point in the history
  • Loading branch information
timja authored Sep 7, 2024
1 parent 6e7335e commit 525a8be
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 68 deletions.
33 changes: 18 additions & 15 deletions core/src/main/resources/hudson/PluginManager/_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,24 +504,27 @@ window.addEventListener("load", function () {
});
});

// Enable/disable the 'Update' button depending on if any updates are checked
const anyCheckboxesSelected = () => {
return (
document.querySelectorAll("input[type='checkbox']:checked:not(:disabled)")
.length > 0
);
};
const updateButton = document.querySelector("#button-update");
const checkboxes = document.querySelectorAll(
"input[type='checkbox'], [data-select], .jenkins-table__checkbox",
);
checkboxes.forEach((checkbox) => {
checkbox.addEventListener("click", () => {
setTimeout(() => {
updateButton.disabled = !anyCheckboxesSelected();
if (updateButton) {
// Enable/disable the 'Update' button depending on if any updates are checked
const anyCheckboxesSelected = () => {
return (
document.querySelectorAll(
"input[type='checkbox']:checked:not(:disabled)",
).length > 0
);
};
const checkboxes = document.querySelectorAll(
"input[type='checkbox'], [data-select], .jenkins-table__checkbox",
);
checkboxes.forEach((checkbox) => {
checkbox.addEventListener("click", () => {
setTimeout(() => {
updateButton.disabled = !anyCheckboxesSelected();
});
});
});
});
}

// Show update center error if element exists
const updateCenterError = document.querySelector("#update-center-error");
Expand Down
109 changes: 56 additions & 53 deletions core/src/main/resources/hudson/PluginManager/installed.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ THE SOFTWARE.
</span>
</a>
</div>
<j:if test="${p.hasMandatoryDependencies()}">
<div class="dependency-list">
<j:forEach var="dependency" items="${p.mandatoryDependencies}">
<span data-plugin-id="${dependency.shortName}" />
</j:forEach>
</div>
</j:if>
<div class="jenkins-!-margin-top-1">
<j:set var="indexPage" value="${p.indexPage.toString()}"/>
<j:set var="excerpt"
Expand Down Expand Up @@ -170,56 +177,52 @@ THE SOFTWARE.
<l:isAdmin>
<td class="jenkins-table__cell--tight">
<div class="jenkins-table__cell__button-wrapper">
<j:if test="${p.downgradable}">
<form method="post"
class="jenkins-buttons-row"
action="${rootURL}/updateCenter/plugin/${p.shortName}/downgrade">
<button class="jenkins-button jenkins-button--tertiary jenkins-!-color-orange"
style="padding: 0.5rem"
tooltip="${%downgradeTo(p.backupVersion)}">
<l:icon src="symbol-downgrade-circle"/>
<span style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60px;">
${p.backupVersion}
</span>
</button>
</form>
</j:if>
<j:if test="${p.downgradable}">
<form method="post"
class="jenkins-buttons-row"
action="${rootURL}/updateCenter/plugin/${p.shortName}/downgrade">
<button class="jenkins-button jenkins-button--tertiary jenkins-!-color-orange"
style="padding: 0.5rem"
tooltip="${%downgradeTo(p.backupVersion)}">
<l:icon src="symbol-downgrade-circle"/>
<span
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60px;">
${p.backupVersion}
</span>
</button>
</form>
</j:if>
</div>
</td>
<td class="jenkins-table__cell--tight uninstall">
<div class="jenkins-table__cell__button-wrapper">
<j:choose>
<j:when test="${p.isDeleted()}">
<p>${%Uninstallation pending}</p>
</j:when>
<j:otherwise>
<j:if test="${p.hasMandatoryDependents() or p.hasImpliedDependents()}">
<div class="dependent-list">
<j:forEach var="dependent" items="${p.mandatoryDependents}">
<span data-plugin-id="${dependent}"></span>
</j:forEach>
<j:set var="impliedDependents" value="${p.impliedDependents}"/>
<j:choose>
<j:when test="${impliedDependents.size() lt 15}">
<j:forEach var="dependent" items="${impliedDependents}">
<span data-plugin-id="${dependent}"></span>
</j:forEach>
</j:when>
<j:otherwise>
<p>
${%detached-many-dependents(impliedDependents.size())}
</p>
</j:otherwise>
</j:choose>
</div>
</j:if>
<j:if test="${p.hasMandatoryDependencies()}">
<div class="dependency-list">
<j:forEach var="dependency" items="${p.mandatoryDependencies}">
<span data-plugin-id="${dependency.shortName}"></span>
</j:forEach>
</div>
</j:if>
</l:isAdmin>
<td class="jenkins-table__cell--tight uninstall ${readOnlyMode and !p.isDeleted() ? 'jenkins-hidden' : ''}">
<div class="jenkins-table__cell__button-wrapper">
<j:choose>
<j:when test="${p.isDeleted()}">
<p>${%Uninstallation pending}</p>
</j:when>
<j:otherwise>
<j:if test="${p.hasMandatoryDependents() or p.hasImpliedDependents()}">
<div class="dependent-list">
<j:forEach var="dependent" items="${p.mandatoryDependents}">
<span data-plugin-id="${dependent}" />
</j:forEach>
<j:set var="impliedDependents" value="${p.impliedDependents}"/>
<j:choose>
<j:when test="${impliedDependents.size() lt 15}">
<j:forEach var="dependent" items="${impliedDependents}">
<span data-plugin-id="${dependent}" />
</j:forEach>
</j:when>
<j:otherwise>
<p>
${%detached-many-dependents(impliedDependents.size())}
</p>
</j:otherwise>
</j:choose>
</div>
</j:if>
<l:isAdmin>
<button data-action="uninstall"
type="button"
class="jenkins-button jenkins-button--tertiary jenkins-!-destructive-color"
Expand All @@ -228,11 +231,11 @@ THE SOFTWARE.
data-message="${%uninstall-title(p.updateInfo.displayName ?: p.displayName)}">
<l:icon src="symbol-close-circle"/>
</button>
</j:otherwise>
</j:choose>
</div>
</td>
</l:isAdmin>
</l:isAdmin>
</j:otherwise>
</j:choose>
</div>
</td>
</tr>
</j:forEach>
<!-- failed ones -->
Expand Down

0 comments on commit 525a8be

Please sign in to comment.