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

Disable dependents toggle in plugin manager with system read #9463

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
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) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor fix I noticed while checking this again, tests were logging a giant stacktrace, this button is only on the updates page and not the installed page so its event listener shouldn't be active

// 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
Loading