未验证 提交 3ea9dc6b 编写于 作者: D Daniel Beck 提交者: GitHub

Do not block rendering of Manage Jenkins while waiting for UC data (#4881)

Co-authored-by: NDaniel Beck <daniel-beck@users.noreply.github.com>
上级 d9aab689
......@@ -1306,10 +1306,16 @@ public class PluginWrapper implements Comparable<PluginWrapper>, ModelObject {
public List<UpdateSite.Deprecation> getDeprecations() {
/* Would be much nicer to go through getInfoFromAllSites but that only works for currently published plugins */
List<UpdateSite.Deprecation> deprecations = new ArrayList<>();
for (UpdateSite site : Jenkins.get().getUpdateCenter().getSites()) {
for (Map.Entry<String, UpdateSite.Deprecation> entry : site.getData().getDeprecations().entrySet()) {
if (entry.getKey().equals(this.shortName)) {
deprecations.add(entry.getValue());
final UpdateCenter updateCenter = Jenkins.get().getUpdateCenter();
if (updateCenter.isSiteDataReady()) {
for (UpdateSite site : updateCenter.getSites()) {
final UpdateSite.Data data = site.getData();
if (data != null) {
for (Map.Entry<String, UpdateSite.Deprecation> entry : data.getDeprecations().entrySet()) {
if (entry.getKey().equals(this.shortName)) {
deprecations.add(entry.getValue());
}
}
}
}
}
......
......@@ -336,6 +336,7 @@ public class UpdateSite {
*
* @return null if no data is available.
*/
@CheckForNull
public Data getData() {
if (data == null) {
JSONObject o = getJSONObject();
......
......@@ -26,11 +26,14 @@ package jenkins.management;
import hudson.Extension;
import hudson.model.ManagementLink;
import hudson.model.UpdateCenter;
import hudson.security.Permission;
import jenkins.model.Jenkins;
import org.jenkinsci.Symbol;
import edu.umd.cs.findbugs.annotations.NonNull;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
/**
* @author <a href="mailto:nicolas.deloof@gmail.com">Nicolas De Loof</a>
......@@ -68,4 +71,14 @@ public class PluginsLink extends ManagementLink {
public Category getCategory() {
return Category.CONFIGURATION;
}
@Restricted(NoExternalUse.class)
public boolean hasUpdates() {
final UpdateCenter updateCenter = Jenkins.get().getUpdateCenter();
if (!updateCenter.isSiteDataReady()) {
// Do not display message during this page load, but possibly later.
return false;
}
return !updateCenter.getUpdates().isEmpty();
}
}
......@@ -24,7 +24,7 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler">
<j:if test="${!empty app.updateCenter.updates}">
<j:if test="${it.hasUpdates()}">
<i class="fa fa-bell" aria-hidden="true" style="color: red"></i> ${%updates available}
</j:if>
</j:jelly>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册