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

Improve presentation of plugin categories #4534

Merged
merged 2 commits into from
Mar 4, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions core/src/main/java/hudson/model/UpdateCenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,9 @@ public List<Plugin> getAvailables() {
/**
* Returns a list of plugins that should be shown in the "available" tab, grouped by category.
* A plugin with multiple categories will appear multiple times in the list.
* @deprecated
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @deprecated
* @deprecated No longer used for visualization in the Plugin Manager

*/
@Deprecated
public PluginEntry[] getCategorizedAvailables() {
TreeSet<PluginEntry> entries = new TreeSet<>();
for (Plugin p : getAvailables()) {
Expand All @@ -1002,7 +1004,8 @@ public PluginEntry[] getCategorizedAvailables() {
return entries.toArray(new PluginEntry[0]);
}

private static String getCategoryDisplayName(String category) {
@Restricted(NoExternalUse.class) // Jelly only
public static String getCategoryDisplayName(String category) {
if (category==null)
return Messages.UpdateCenter_PluginCategory_misc();
try {
Expand All @@ -1011,7 +1014,7 @@ private static String getCategoryDisplayName(String category) {
} catch (RuntimeException ex) {
throw ex;
} catch (Exception ex) {
return Messages.UpdateCenter_PluginCategory_unrecognized(category);
return category;
}
}

Expand Down Expand Up @@ -2454,6 +2457,7 @@ protected void replace(File dst, File src) throws IOException {
}
}

@Deprecated
Copy link
Member

Choose a reason for hiding this comment

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

Some Javadoc would with explanation be nice

public static final class PluginEntry implements Comparable<PluginEntry> {
public Plugin plugin;
public String category;
Expand Down
12 changes: 12 additions & 0 deletions core/src/main/resources/hudson/PluginManager/_table.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,15 @@
margin: 1em;
text-align: right;
}
.plugin-manager__categories {
margin-top: 0.5em;
}

.plugin-manager__category-label {
display: inline-block;
border: 1px solid #ccc;
background-color: #eee;
border-radius: 4px;
padding: 0.25rem;
margin: 0 0.25rem 0.25rem 0;
}
21 changes: 0 additions & 21 deletions core/src/main/resources/hudson/PluginManager/_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,6 @@ function checkPluginsWithoutWarnings() {
}
}
}
function showhideCategories(hdr,on) {
var table = hdr.parentNode.parentNode.parentNode,
newDisplay = on ? '' : 'none',
nameList = new Array(), id;
for (var i = 1; i < table.rows.length; i++) {
if (on || table.rows[i].cells.length == 1)
table.rows[i].style.display = newDisplay;
else {
// Hide duplicate rows for a plugin:version when not viewing by-category
id = table.rows[i].cells[1].getAttribute('data-id');
if (nameList[id] == 1) table.rows[i].style.display = 'none';
nameList[id] = 1;
}
}
}
function showhideCategory(col) {
var row = col.parentNode.nextSibling;
var newDisplay = row && row.style.display == 'none' ? '' : 'none';
for (; row && row.cells.length > 1; row = row.nextSibling)
row.style.display = newDisplay;
}

Behaviour.specify("#filter-box", '_table', 0, function(e) {
function applyFilter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ 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">
<local:table page="available" list="${app.updateCenter.categorizedAvailables}" xmlns:local="/hudson/PluginManager" />
<local:table page="available" list="${app.updateCenter.availables}" xmlns:local="/hudson/PluginManager" />
</j:jelly>
47 changes: 15 additions & 32 deletions core/src/main/resources/hudson/PluginManager/table.jelly
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,6 @@ 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">
<l:layout title="${%Update Center}" permission="${app.ADMINISTER}">
<l:header>
<script type="text/javascript">
<![CDATA[
function flip(item) {
var nodes = document.getElementsByName(item.name);
for (var i = 0; i < nodes.length; ++i) {
if(nodes[i].nodeName == "INPUT") {
nodes[i].checked = item.checked;
}
}
}
]]>
</script>
</l:header>
<st:include page="sidepanel.jelly"/>
<l:main-panel>
<st:adjunct includes="hudson.PluginManager._table"/>
Expand All @@ -62,42 +48,39 @@ THE SOFTWARE.
<table id="plugins" class="sortable pane bigtable stripped-odd">
<tr>
<th initialSortDir="${isUpdates?null:'down'}"
tooltip="${%Check to install the plugin}${isUpdates?'':'&lt;br/&gt;'+'%Click this heading to sort by category'}"
width="32" onclick="showhideCategories(this,1)">${%Install}</th>
<th initialSortDir="${isUpdates?'down':null}"
onclick="showhideCategories(this,0)">${%Name}</th>
<th onclick="showhideCategories(this,0)">${%Version}</th>
tooltip="${%Check to install the plugin}"
width="32">${%Install}</th>
<th initialSortDir="${isUpdates?'down':null}">${%Name}</th>
<th>${%Version}</th>
<j:if test="${isUpdates}"><th>${%Installed}</th></j:if>
</tr>
<j:choose>
<j:when test="${!empty(list)}">
<j:set var="lastCat" value="" />
<j:set var="cache" value="${it.createCache()}"/>
<j:forEach var="p" items="${list}">
<j:if test="${!isUpdates}">
<j:set var="thisCat" value="${p.category}" />
<j:set var="p" value="${p.plugin}" />
<j:if test="${thisCat != lastCat}">
<tr class="plugin-category" name="${thisCat}">
<td class="pane" colspan="4" onclick="showhideCategory(this)">${thisCat}</td>
</tr>
</j:if>
<j:set var="lastCat" value="${thisCat}" />
</j:if>
<j:set var="installJob" value="${isUpdates ? app.updateCenter.getJob(p) : null}" />
<j:set var="installedOk"
value="${installJob.status.success and installJob.plugin.version==p.version}" />
<tr class="${installJob!=null ? 'already-upgraded' : ''} plugin" name="${p.displayName}">
<td class="pane" align="center" data="${thisCat}_">
<td class="pane" align="center">
<input type="checkbox" name="plugin.${p.name}.${p.sourceId}"
checked="${installedOk ? 'checked' : null}"
disabled="${installedOk ? 'disabled' : null}" onClick="flip(this);"
disabled="${installedOk ? 'disabled' : null}"
data-compat-warning="${!p.isCompatible(cache)}" />
</td>
<td class="pane" data="${h.xmlEscape(p.displayName)}" data-id="${h.xmlEscape(p.name+':'+p.version)}">
<div>
<a href="${p.wiki}" target="_blank"><st:out value="${p.displayName}"/></a>
</div>
<j:if test="${!p.categories.isEmpty()}">
<div class="plugin-manager__categories">
<j:forEach var="label" items="${p.categories}">
<span class="plugin-manager__category-label">
${app.updateCenter.getCategoryDisplayName(label)}
</span>
</j:forEach>
</div>
</j:if>
<j:if test="${p.excerpt!=null}">
<div class="excerpt"><j:out value="${p.excerpt}" /></div>
</j:if>
Expand Down