Skip to content

Commit

Permalink
Merge branch 'master' into new-plugin-manager-1
Browse files Browse the repository at this point in the history
  • Loading branch information
janfaracik committed Jul 18, 2022
2 parents 4d640b4 + 38d4e86 commit 0b808b0
Show file tree
Hide file tree
Showing 43 changed files with 469 additions and 289 deletions.
2 changes: 1 addition & 1 deletion bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>5.3.21</version>
<version>5.3.22</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down
12 changes: 0 additions & 12 deletions cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,6 @@
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
12 changes: 0 additions & 12 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -521,18 +521,6 @@ THE SOFTWARE.
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/hudson/model/ParametersAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public String getDisplayName() {

@Override
public String getIconFileName() {
return "document-properties.png";
return "symbol-parameters";
}

@Override
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/java/hudson/model/UpdateCenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,12 @@ public List<Plugin> getUpdates() {
return new ArrayList<>(pluginMap.values());
}

// for Jelly
@Restricted(NoExternalUse.class)
public boolean hasIncompatibleUpdates(PluginManager.MetadataCache cache) {
return getUpdates().stream().anyMatch(plugin -> !plugin.isCompatible(cache));
}

@Restricted(NoExternalUse.class)
public List<Plugin> getPluginsWithUnavailableUpdates() {
Map<String, Plugin> pluginMap = new LinkedHashMap<>();
Expand Down
67 changes: 0 additions & 67 deletions core/src/main/java/jenkins/model/NewViewLink.java

This file was deleted.

84 changes: 44 additions & 40 deletions core/src/main/resources/hudson/PluginManager/_table.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
function checkPluginsWithoutWarnings() {
var inputs = document.getElementsByTagName('input');
for(var i = 0; i < inputs.length; i++) {
var candidate = inputs[i];
if(candidate.type === "checkbox" && !candidate.disabled) {
candidate.checked = candidate.dataset.compatWarning === 'false';
}
}
}

Behaviour.specify("#filter-box", '_table', 0, function(e) {
function applyFilter() {
var filter = e.value.toLowerCase().trim();
Expand Down Expand Up @@ -80,11 +70,11 @@ Behaviour.specify("#filter-box", '_table', 0, function(e) {

/**
* Wait for document onload.
*/
Element.observe(window, "load", function() {
*/
Element.observe(window, "load", function() {
var pluginsTable = select('#plugins');
var pluginTRs = selectAll('.plugin', pluginsTable);

if (!pluginTRs) {
return;
}
Expand All @@ -93,16 +83,16 @@ Behaviour.specify("#filter-box", '_table', 0, function(e) {
function i18n(messageId) {
return pluginI18n.getAttribute('data-' + messageId);
}

// Create a map of the plugin rows, making it easy to index them.
var plugins = {};
for (var i = 0; i < pluginTRs.length; i++) {
var pluginTR = pluginTRs[i];
var pluginId = pluginTR.getAttribute('data-plugin-id');

plugins[pluginId] = pluginTR;
}

function getPluginTR(pluginId) {
return plugins[pluginId];
}
Expand All @@ -114,24 +104,24 @@ Behaviour.specify("#filter-box", '_table', 0, function(e) {
return pluginId;
}
}

function processSpanSet(spans) {
var ids = [];
for (var i = 0; i < spans.length; i++) {
var span = spans[i];
var pluginId = span.getAttribute('data-plugin-id');
var pluginName = getPluginName(pluginId);

span.update(pluginName);
ids.push(pluginId);
}
return ids;
}

function markAllDependentsDisabled(pluginTR) {
var jenkinsPluginMetadata = pluginTR.jenkinsPluginMetadata;
var dependentIds = jenkinsPluginMetadata.dependentIds;

if (dependentIds) {
// If the only dependent is jenkins-core (it's a bundle plugin), then lets
// treat it like all its dependents are disabled. We're really only interested in
Expand All @@ -151,7 +141,7 @@ Behaviour.specify("#filter-box", '_table', 0, function(e) {
pluginTR.removeClassName('all-dependents-disabled');
return;
}

// The dependent is a plugin....
var dependentPluginTr = getPluginTR(dependentId);
if (dependentPluginTr && dependentPluginTr.jenkinsPluginMetadata.enableInput.checked) {
Expand All @@ -161,14 +151,14 @@ Behaviour.specify("#filter-box", '_table', 0, function(e) {
}
}
}

pluginTR.addClassName('all-dependents-disabled');
}

function markHasDisabledDependencies(pluginTR) {
var jenkinsPluginMetadata = pluginTR.jenkinsPluginMetadata;
var dependencyIds = jenkinsPluginMetadata.dependencyIds;

if (dependencyIds) {
for (var i = 0; i < dependencyIds.length; i++) {
var dependencyPluginTr = getPluginTR(dependencyIds[i]);
Expand All @@ -179,10 +169,10 @@ Behaviour.specify("#filter-box", '_table', 0, function(e) {
}
}
}

pluginTR.removeClassName('has-disabled-dependency');
}

function setEnableWidgetStates() {
for (var i = 0; i < pluginTRs.length; i++) {
var pluginMetadata = pluginTRs[i].jenkinsPluginMetadata;
Expand All @@ -195,7 +185,7 @@ Behaviour.specify("#filter-box", '_table', 0, function(e) {
markHasDisabledDependencies(pluginTRs[i]);
}
}

function addDependencyInfoRow(pluginTR, infoTR) {
infoTR.addClassName('plugin-dependency-info');
pluginTR.insert({
Expand All @@ -212,7 +202,7 @@ Behaviour.specify("#filter-box", '_table', 0, function(e) {
}
}

function populateEnableDisableInfo(pluginTR, infoContainer) {
function populateEnableDisableInfo(pluginTR, infoContainer) {
var pluginMetadata = pluginTR.jenkinsPluginMetadata;

// Remove all existing class info
Expand All @@ -224,9 +214,9 @@ Behaviour.specify("#filter-box", '_table', 0, function(e) {
var dependencySpans = pluginMetadata.dependencies;

infoContainer.update('<div class="title">' + i18n('cannot-enable') + '</div><div class="subtitle">' + i18n('disabled-dependencies') + '.</div>');

// Go through each dependency <span> element. Show the spans where the dependency is
// disabled. Hide the others.
// disabled. Hide the others.
for (var i = 0; i < dependencySpans.length; i++) {
var dependencySpan = dependencySpans[i];
var pluginId = dependencySpan.getAttribute('data-plugin-id');
Expand All @@ -244,15 +234,15 @@ Behaviour.specify("#filter-box", '_table', 0, function(e) {
dependencySpan.setStyle({display: 'inline-block'});
}
}

dependenciesDiv.setStyle({display: 'inherit'});
infoContainer.appendChild(dependenciesDiv);

return true;
} if (pluginTR.hasClassName('has-dependents')) {
if (!pluginTR.hasClassName('all-dependents-disabled')) {
var dependentIds = pluginMetadata.dependentIds;

// If the only dependent is jenkins-core (it's a bundle plugin), then lets
// treat it like all its dependents are disabled. We're really only interested in
// dependent plugins in this case.
Expand All @@ -273,7 +263,7 @@ Behaviour.specify("#filter-box", '_table', 0, function(e) {
infoContainer.appendChild(getDependentsDiv(pluginTR, true));
return true;
}

return false;
}

Expand Down Expand Up @@ -333,7 +323,7 @@ Behaviour.specify("#filter-box", '_table', 0, function(e) {
var dependentsDiv = select('.dependent-list', pluginTR);
var enableTD = select('td.enable', pluginTR);
var uninstallTD = select('td.uninstall', pluginTR);

pluginTR.jenkinsPluginMetadata = {
enableInput: enableInput,
dependenciesDiv: dependenciesDiv,
Expand All @@ -348,7 +338,7 @@ Behaviour.specify("#filter-box", '_table', 0, function(e) {
pluginTR.jenkinsPluginMetadata.dependents = selectAll('span', dependentsDiv);
pluginTR.jenkinsPluginMetadata.dependentIds = processSpanSet(pluginTR.jenkinsPluginMetadata.dependents);
}

// Setup event handlers...
if (enableInput) {
// Toggling of the enable/disable checkbox requires a check and possible
Expand All @@ -357,8 +347,8 @@ Behaviour.specify("#filter-box", '_table', 0, function(e) {
setEnableWidgetStates();
});
}
//

//
var infoTR = document.createElement("tr");
var infoTD = document.createElement("td");
var infoDiv = document.createElement("div");
Expand All @@ -377,7 +367,7 @@ Behaviour.specify("#filter-box", '_table', 0, function(e) {
}
showInfoTimeout = undefined;
}

// Handle mouse in/out of the enable/disable cell (left most cell).
if (enableTD) {
Element.observe(enableTD, 'mouseenter', function() {
Expand Down Expand Up @@ -416,11 +406,25 @@ Behaviour.specify("#filter-box", '_table', 0, function(e) {
for (var i = 0; i < pluginTRs.length; i++) {
initPluginRowHandling(pluginTRs[i]);
}

setEnableWidgetStates();
});
}());

Element.observe(window, "load", function() {
document.getElementById('filter-box').focus();
});

const compatibleCheckbox = document.querySelector("[data-select='compatible']");
if (compatibleCheckbox) {
compatibleCheckbox.addEventListener("click", () => {
const inputs = document.getElementsByTagName('input');
for (let i = 0; i < inputs.length; i++) {
const candidate = inputs[i];
if (candidate.type === "checkbox" && !candidate.disabled) {
candidate.checked = candidate.dataset.compatWarning === 'false';
}
}
window.updateTableHeaderCheckbox();
})
}
});
6 changes: 0 additions & 6 deletions core/src/main/resources/hudson/PluginManager/index.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ THE SOFTWARE.
<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">
<local:table page="updates" list="${app.updateCenter.updates}" xmlns:local="/hudson/PluginManager">
<div style="margin-top:1em">
<l:isAdmin>
${%Select}: <a href="javascript:toggleCheckboxes(true);">${%All}</a>,
<a href="javascript:checkPluginsWithoutWarnings();">${%Compatible}</a>,
<a href="javascript:toggleCheckboxes(false);">${%None}</a><br/>
</l:isAdmin>
${%UpdatePageDescription}
<j:if test="${!empty(app.updateCenter.jobs)}">
<br/> ${%UpdatePageLegend(rootURL+'/updateCenter/')}
</j:if>
Expand Down
Loading

0 comments on commit 0b808b0

Please sign in to comment.