diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2010-11-01 18:25:45 +0000 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2010-11-01 18:25:45 +0000 |
commit | 51e6a276a3ab5b3538b469d75c8afea8bb4a581d (patch) | |
tree | 45437cb471a582332fc85f4e7e1410b01253d837 /sonar-server | |
parent | 4d5ed597d80f8e0a070b52e1c673d14e3597e9e8 (diff) | |
download | sonarqube-51e6a276a3ab5b3538b469d75c8afea8bb4a581d.tar.gz sonarqube-51e6a276a3ab5b3538b469d75c8afea8bb4a581d.zip |
improve layout of update center
Diffstat (limited to 'sonar-server')
15 files changed, 252 insertions, 218 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java index a268efc3766..9cec2e85564 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/Platform.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/Platform.java @@ -135,7 +135,7 @@ public final class Platform { coreContainer.as(Characteristics.CACHE).addComponent(ThreadLocalDatabaseSessionFactory.class); coreContainer.as(Characteristics.CACHE).addComponent(HttpDownloader.class); coreContainer.as(Characteristics.CACHE).addComponent(UpdateCenterClient.class); - coreContainer.as(Characteristics.CACHE).addComponent(UpdateFinderFactory.class); + coreContainer.as(Characteristics.CACHE).addComponent(UpdateCenterMatrixFactory.class); coreContainer.as(Characteristics.CACHE).addComponent(PluginDownloader.class); coreContainer.as(Characteristics.NO_CACHE).addComponent(FilterExecutor.class); coreContainer.as(Characteristics.NO_CACHE).addAdapter(new DatabaseSessionProvider()); diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java b/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java index 575ba0799c7..f46baa4f42c 100644 --- a/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java +++ b/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterClient.java @@ -30,11 +30,12 @@ import org.sonar.updatecenter.common.UpdateCenterDeserializer; import java.io.InputStream; import java.net.URI; +import java.util.Date; import java.util.Properties; /** * HTTP client to load data from the remote update center hosted at http://update.sonarsource.org. - * @since 2.2 + * @since 2.4 */ public class UpdateCenterClient implements ServerComponent { @@ -44,7 +45,7 @@ public class UpdateCenterClient implements ServerComponent { private String url; private UpdateCenter center = null; - private long downloadDate = 0; + private long lastRefreshDate = 0; private HttpDownloader downloader; /** @@ -67,13 +68,17 @@ public class UpdateCenterClient implements ServerComponent { public UpdateCenter getCenter(boolean forceRefresh) { if (center == null || forceRefresh || needsRefresh()) { center = download(); - downloadDate = System.currentTimeMillis(); + lastRefreshDate = System.currentTimeMillis(); } return center; } + public Date getLastRefreshDate() { + return lastRefreshDate >0 ? new Date(lastRefreshDate) : null; + } + private boolean needsRefresh() { - return downloadDate + PERIOD_IN_MILLISECONDS < System.currentTimeMillis(); + return lastRefreshDate + PERIOD_IN_MILLISECONDS < System.currentTimeMillis(); } private UpdateCenter download() { diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/UpdateFinder.java b/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrix.java index c18c94b5a32..a5c698539c3 100644 --- a/sonar-server/src/main/java/org/sonar/server/plugins/UpdateFinder.java +++ b/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrix.java @@ -19,23 +19,29 @@ */ package org.sonar.server.plugins; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import org.sonar.updatecenter.common.*; -import java.util.*; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.SortedSet; -public final class UpdateFinder { +public final class UpdateCenterMatrix { private UpdateCenter center; private Version installedSonarVersion; - private Map<Plugin, Version> installedPlugins = new HashMap<Plugin, Version>(); - private List<String> pendingPluginFilenames = new ArrayList<String>(); + private Map<Plugin, Version> installedPlugins = Maps.newHashMap(); + private List<String> pendingPluginFilenames = Lists.newArrayList(); + private Date date; - public UpdateFinder(UpdateCenter center, Version installedSonarVersion) { + public UpdateCenterMatrix(UpdateCenter center, Version installedSonarVersion) { this.center = center; this.installedSonarVersion = installedSonarVersion; } - public UpdateFinder(UpdateCenter center, String installedSonarVersion) { + public UpdateCenterMatrix(UpdateCenter center, String installedSonarVersion) { this(center, Version.create(installedSonarVersion)); } @@ -47,7 +53,7 @@ public final class UpdateFinder { return installedSonarVersion; } - public UpdateFinder registerInstalledPlugin(String pluginKey, Version pluginVersion) { + public UpdateCenterMatrix registerInstalledPlugin(String pluginKey, Version pluginVersion) { Plugin plugin = center.getPlugin(pluginKey); if (plugin != null) { installedPlugins.put(plugin, pluginVersion); @@ -55,15 +61,15 @@ public final class UpdateFinder { return this; } - public UpdateFinder registerPendingPluginsByFilename(String filename) { + public UpdateCenterMatrix registerPendingPluginsByFilename(String filename) { pendingPluginFilenames.add(filename); return this; } public List<PluginUpdate> findAvailablePlugins() { - List<PluginUpdate> availables = new ArrayList<PluginUpdate>(); + List<PluginUpdate> availables = Lists.newArrayList(); for (Plugin plugin : center.getPlugins()) { - if ( !installedPlugins.containsKey(plugin) && !isAlreadyDownloaded(plugin)) { + if (!installedPlugins.containsKey(plugin) && !isAlreadyDownloaded(plugin)) { Release release = plugin.getLastCompatibleRelease(installedSonarVersion); if (release != null) { availables.add(PluginUpdate.createWithStatus(release, PluginUpdate.Status.COMPATIBLE)); @@ -90,10 +96,10 @@ public final class UpdateFinder { } public List<PluginUpdate> findPluginUpdates() { - List<PluginUpdate> updates = new ArrayList<PluginUpdate>(); + List<PluginUpdate> updates = Lists.newArrayList(); for (Map.Entry<Plugin, Version> entry : installedPlugins.entrySet()) { Plugin plugin = entry.getKey(); - if ( !isAlreadyDownloaded(plugin)) { + if (!isAlreadyDownloaded(plugin)) { Version pluginVersion = entry.getValue(); for (Release release : plugin.getReleasesGreaterThan(pluginVersion)) { updates.add(PluginUpdate.createForPluginRelease(release, installedSonarVersion)); @@ -104,7 +110,7 @@ public final class UpdateFinder { } public List<SonarUpdate> findSonarUpdates() { - List<SonarUpdate> updates = new ArrayList<SonarUpdate>(); + List<SonarUpdate> updates = Lists.newArrayList(); SortedSet<Release> releases = center.getSonar().getReleasesGreaterThan(installedSonarVersion); for (Release release : releases) { updates.add(createSonarUpdate(release)); @@ -144,4 +150,13 @@ public final class UpdateFinder { } return update; } + + public Date getDate() { + return date; + } + + public UpdateCenterMatrix setDate(Date d) { + this.date = d; + return this; + } } diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/UpdateFinderFactory.java b/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrixFactory.java index 0963112fb25..6e33ace2d42 100644 --- a/sonar-server/src/main/java/org/sonar/server/plugins/UpdateFinderFactory.java +++ b/sonar-server/src/main/java/org/sonar/server/plugins/UpdateCenterMatrixFactory.java @@ -26,33 +26,38 @@ import org.sonar.api.platform.Server; import org.sonar.updatecenter.common.UpdateCenter; import org.sonar.updatecenter.common.Version; -public final class UpdateFinderFactory implements ServerComponent { +/** + * @since 2.4 + */ +public final class UpdateCenterMatrixFactory implements ServerComponent { private UpdateCenterClient centerClient; private JpaPluginDao dao; private Version sonarVersion; private PluginDownloader downloader; - public UpdateFinderFactory(UpdateCenterClient centerClient, JpaPluginDao dao, Server server, PluginDownloader downloader) { + public UpdateCenterMatrixFactory(UpdateCenterClient centerClient, JpaPluginDao dao, Server server, PluginDownloader downloader) { this.centerClient = centerClient; this.dao = dao; this.sonarVersion = Version.create(server.getVersion()); this.downloader = downloader; } - public UpdateFinder getFinder(boolean refresh) { + public UpdateCenterMatrix getMatrix(boolean refresh) { UpdateCenter center = centerClient.getCenter(refresh); - UpdateFinder finder = null; + UpdateCenterMatrix matrix = null; if (center != null) { - finder = new UpdateFinder(center, sonarVersion); + matrix = new UpdateCenterMatrix(center, sonarVersion); + matrix.setDate(centerClient.getLastRefreshDate()); + for (JpaPlugin plugin : dao.getPlugins()) { - finder.registerInstalledPlugin(plugin.getKey(), Version.create(plugin.getVersion())); + matrix.registerInstalledPlugin(plugin.getKey(), Version.create(plugin.getVersion())); } for (String filename : downloader.getDownloads()) { - finder.registerPendingPluginsByFilename(filename); + matrix.registerPendingPluginsByFilename(filename); } } - return finder; + return matrix; } } diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java index f5dc477cd43..883f5e34b63 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java @@ -47,11 +47,8 @@ import org.sonar.server.filters.Filter; import org.sonar.server.filters.FilterExecutor; import org.sonar.server.filters.FilterResult; import org.sonar.server.platform.Platform; -import org.sonar.server.plugins.PluginClassLoaders; -import org.sonar.server.plugins.PluginDeployer; -import org.sonar.server.plugins.PluginDownloader; -import org.sonar.server.plugins.UpdateFinder; -import org.sonar.server.plugins.UpdateFinderFactory; +import org.sonar.server.plugins.*; +import org.sonar.server.plugins.UpdateCenterMatrix; import org.sonar.server.rules.ProfilesConsole; import org.sonar.server.rules.RulesConsole; import org.sonar.updatecenter.common.Version; @@ -65,7 +62,8 @@ public final class JRubyFacade implements ServerComponent { return getContainer().getComponent(FilterExecutor.class).execute(filter); } - /* PLUGINS */ + /* UPDATE CENTER */ + public void downloadPlugin(String pluginKey, String pluginVersion) { getContainer().getComponent(PluginDownloader.class).download(pluginKey, Version.create(pluginVersion)); } @@ -90,10 +88,14 @@ public final class JRubyFacade implements ServerComponent { return getContainer().getComponent(PluginDeployer.class).getUninstalls(); } - public UpdateFinder getUpdateFinder(boolean forceReload) { - return getContainer().getComponent(UpdateFinderFactory.class).getFinder(forceReload); + public UpdateCenterMatrix getUpdateCenterMatrix(boolean forceReload) { + return getContainer().getComponent(UpdateCenterMatrixFactory.class).getMatrix(forceReload); } + + + + public String colorizeCode(String code, String language) { try { return getContainer().getComponent(CodeColorizers.class).toHtml(code, language); diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/updatecenter_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/updatecenter_controller.rb index 6a84b0fa634..429602cc5fb 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/updatecenter_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/updatecenter_controller.rb @@ -38,6 +38,7 @@ class UpdatecenterController < ApplicationController @downloads=java_facade.getPluginDownloads() @center=nil + @matrix=nil @sonar_updates=[] @updates_by_plugin={} @user_plugins={} @@ -47,12 +48,12 @@ class UpdatecenterController < ApplicationController @user_plugins[plugin.plugin_key]=plugin.version end - finder=load_update_finder() - if finder - @center=finder.getCenter() - @sonar_updates=finder.findSonarUpdates() + load_matrix() + if @matrix + @center=@matrix.getCenter() + @sonar_updates=@matrix.findSonarUpdates() - @finder.findPluginUpdates().each do |update| + @matrix.findPluginUpdates().each do |update| plugin=update.getPlugin() @updates_by_plugin[plugin]||=[] @updates_by_plugin[plugin]<<update @@ -70,10 +71,10 @@ class UpdatecenterController < ApplicationController @center=nil @updates_by_category={} - finder=load_update_finder() - if finder - @center=finder.getCenter() - finder.findAvailablePlugins().each do |update| + load_matrix() + if @matrix + @center=@matrix.getCenter() + @matrix.findAvailablePlugins().each do |update| category=update.getPlugin().getCategory()||'' @updates_by_category[category]||=[] @updates_by_category[category]<<update @@ -119,8 +120,8 @@ class UpdatecenterController < ApplicationController end private - def load_update_finder - @finder=java_facade.getUpdateFinder(params[:reload]=='true') + def load_matrix + @matrix=java_facade.getUpdateCenterMatrix(params[:reload]=='true') end def updatecenter_activated diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/updatecenter_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/updatecenter_helper.rb index 30e23f9c8e9..04139237bee 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/updatecenter_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/updatecenter_helper.rb @@ -20,7 +20,7 @@ module UpdatecenterHelper def release_date(date) - Time.at(date.getTime() / 1000).strftime('%B %e, %Y') + Time.at(date.getTime() / 1000).strftime('%b %e, %Y') end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb index e223270877a..cedafc0abcb 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb @@ -75,10 +75,10 @@ <li class="h2">System</li> <li class="<%= 'selected' if request.request_uri.include?('/settings') -%>"><a href="<%= ApplicationController.root_context -%>/settings/index">Settings</a></li> <li class="<%= 'selected' if controller.controller_path=='backup' -%>"><a href="<%= ApplicationController.root_context -%>/backup">Backup</a></li> - <li class="<%= 'selected' if controller.controller_path=='system' -%>"><a href="<%= ApplicationController.root_context -%>/system">System info</a></li> + <li class="<%= 'selected' if controller.controller_path=='system' -%>"><a href="<%= ApplicationController.root_context -%>/system">System Info</a></li> <% update_center_activated = controller.java_facade.getConfigurationValue('sonar.updatecenter.activate') || 'true'; if update_center_activated=='true' %> - <li class="<%= 'selected' if controller.controller_path=='updatecenter' -%>"><a href="<%= ApplicationController.root_context -%>/updatecenter">Upgrades (BETA)</a></li> + <li class="<%= 'selected' if controller.controller_path=='updatecenter' -%>"><a href="<%= ApplicationController.root_context -%>/updatecenter">Update Center</a></li> <% end %> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_list.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_list.html.erb index ec8a5b7efa2..e69de29bb2d 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_list.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_list.html.erb @@ -1,45 +0,0 @@ -<% updates.each do |update| - release=update.getRelease() -%> - <tr class="<%= cycle('even','odd', :name => 'system') if !plugin -%>"> - <td width="1%" nowrap><b><%= 'Sonar' if !plugin -%> <%= release.getVersion() -%></b></td> - <td width="1%" nowrap><%= release_date(release.getDate()) if release.getDate() -%></td> - <td><%= release.getDescription() -%></td> - <td> - <%= link_to 'Release Notes', release.getChangelogUrl(), :class => 'external' if release.getChangelogUrl() %> - <%= link_to 'Download', release.getDownloadUrl(), :class => 'external' if !plugin && release.getDownloadUrl() %> - </td> - <% if plugin %> - <td> - <% if update.isIncompatible() %> - not compatible - <% elsif update.requiresSonarUpgrade %> - not compatible, needs Sonar upgrade - <% end %> - </td> - <% else %> - <td> - <% if update.hasWarnings() %> - <% if update.isIncompatible() %> - Those plugins not compatible and must be uninstalled before Sonar upgrade: - <ul> - <% update.getIncompatiblePlugins().each do |plugin| %> - <li><%= plugin.getName() -%></li> - <% end %> - </ul> - <% end %> - <% if update.requiresPluginUpgrades() %> - Those plugins must be upgraded: - <ul> - <% update.getPluginsToUpgrade().each do |plugin| %> - <li><%= plugin.getArtifact().getName() -%> to <%= plugin.getVersion() -%></li> - <% end %> - </ul> - <% end %> - <% else %> - All installed plugins are compatible - <% end %> - </td> - <% end %> - </tr> -<% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_operations.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_operations.html.erb index 2a72d44f3f7..a46d5e60fa6 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_operations.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_operations.html.erb @@ -7,15 +7,6 @@ } return false; } - - function checkTermsConditions(key) { - var tc=$('tc-' + key) - if (tc!=null && !tc.checked) { - alert('Please accept the Terms and Conditions'); - return false; - } - return true; - } </script> <% if @uninstalls.size > 0 %> @@ -37,7 +28,7 @@ <li><%= download -%></li> <% end %> </ul> - <input type="submit" value="Cancel downloads"></input> + <input type="submit" value="Cancel pending installations"></input> </p> </form> <% end %> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_status.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_status.html.erb index a6defc2d88b..00f473ee3a1 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_status.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_status.html.erb @@ -1,7 +1,7 @@ -<p class="notes"> - <% if @center.nil? %> - <p>Not connected to update center. Please check your internet connection and logs.</p> - <% else %> - Updated on <%= @center.getDate() %>. <%= link_to 'Refresh', :action => action, :reload => true %> - <% end %> -</p> +<% if @center.nil? %> + <p class="error">Not connected to update center. Please check your internet connection and logs.</p> +<% else %> + <p class="notes"> + Updated on <%= @matrix.getDate() -%>. <%= link_to 'Refresh', :action => action, :reload => true %> + </p> +<% end %>
\ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb index 3b17d550e92..e4ccf1b0b5a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/available.html.erb @@ -1,3 +1,18 @@ +<script> +function installPlugin(key) { + /* check terms & conditions */ + var tc=$('tc-' + key) + if (tc!=null && !tc.checked) { + alert('Please accept the Terms and Conditions'); + return false; + } + var button=$('submit-' + key); + button.disable(); + button.writeAttribute('value', 'Installing'); + return true; +} +</script> + <ul class="tabs"> <li> <a href="<%= url_for :action => 'index' -%>">Installed</a> @@ -13,22 +28,22 @@ <%= render :partial => 'updatecenter/operations' -%> -<table class="data width100"> - <thead> - </thead> - <tbody> <% if @center %> <% @updates_by_category.keys.sort_by{|c| c.downcase }.each do |category| updates=@updates_by_category[category] %> - <tr> - <td colspan="2"><h2><%= category -%></h2></td> - </tr> + <table class="data width100"> + <thead> + <tr> + <th colspan="2"><h2><%= category -%></h2></th> + </tr> + </thead> + <tbody> <% updates.sort_by{|c| c.getPlugin().getName()}.each do |update| plugin=update.getPlugin() %> <tr class="<%= cycle('even','odd', :name => category) -%>"> - <td width="1%" nowrap> + <td width="150" nowrap> <b><a href="#plugin" onClick="showPlugin('<%= plugin.getKey() -%>');"><%= h(plugin.getName()) -%></a></b> </td> <td> @@ -64,8 +79,8 @@ <% if plugin.getTermsConditionsUrl() %> <input type="checkbox" id="tc-<%= plugin.getKey() -%>"></input> I accept the <%= link_to 'Terms and Conditions', plugin.getTermsConditionsUrl(), :class => 'external' %> <% end %> - <form method="post" action="<%= ApplicationController.root_context -%>/updatecenter/install?from=available&key=<%= plugin.getKey() -%>&version=<%= update.getRelease().getVersion() -%>" style="display: inline-block"> - <input type="submit" value="Install" onClick="return checkTermsConditions('<%= plugin.getKey() -%>')"></input> + <form method="post" action="<%= ApplicationController.root_context -%>/updatecenter/install?from=available&key=<%= plugin.getKey() -%>&version=<%= update.getRelease().getVersion() -%>" style="display: inline-block" id="install-<%= plugin.getKey() -%>"> + <input type="submit" value="Install" onClick="return installPlugin('<%= plugin.getKey() -%>')" id="submit-<%= plugin.getKey() -%>"></input> </form> </div> <% elsif update.requiresSonarUpgrade @@ -80,10 +95,11 @@ </td> </tr> <% end %> + </tbody> + </table> + <div class="break30"> </div> <% end %> <% end %> -</tbody> -</table><br/> <%= render :partial => 'updatecenter/status', :locals => {:action => 'available' } %> </div> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb index 71996d7453f..ff599694e49 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/index.html.erb @@ -15,7 +15,7 @@ <table class="data width100" id="user-plugins"> <thead> - <tr><th colspan="3"><h2>User-installed plugins</h2></th></tr> + <tr><th colspan="3"><h2>Plugins</h2></th></tr> <tr> <th>Plugin</th> <th>Version</th> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/updates.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/updates.html.erb index b9f9d636f51..58f7fca5504 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/updates.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/updates.html.erb @@ -1,72 +1,116 @@ -<ul class="tabs"> - <li> - <a href="<%= url_for :action => 'index' -%>">Installed</a> - </li> - <li> - <a href="<%= url_for :action => 'updates' -%>" class="selected">Updates</a> - </li> - <li> - <a href="<%= url_for :action => 'available' -%>">Available</a> - </li> -</ul> -<div class="tabs-panel"> + <ul class="tabs"> + <li> + <a href="<%= url_for :action => 'index' -%>">Installed</a> + </li> + <li> + <a href="<%= url_for :action => 'updates' -%>" class="selected">Updates</a> + </li> + <li> + <a href="<%= url_for :action => 'available' -%>">Available</a> + </li> + </ul> + <div class="tabs-panel"> -<%= render :partial => 'updatecenter/operations' -%> + <%= render :partial => 'updatecenter/operations' -%> -<% if @center %> - <table class="data width100" id="plugin-updates"> - <thead> - <tr><th colspan="2"><h2>User-installed plugins</h2></th></tr> - </thead> - <tbody> - <% if @updates_by_plugin.empty? %> - <tr class="even"> - <td colspan="2">No updates</td> - </tr> - <% end %> - <% @updates_by_plugin.keys.each do |plugin| - updates=@updates_by_plugin[plugin] - %> - <tr class="<%= cycle('even','odd', :name => 'user-plugins') -%>"> - <td width="1%" nowrap> - <b><a href="#plugin" onclick="showPlugin('<%= plugin.getKey() -%>')"><%= h(plugin.getName()) -%></a></b> - </td> - <td> - Current version: <b><%= @user_plugins[plugin.getKey()] -%></b>, - last compatible: <b><%= @last_compatible[plugin.getKey()] -%></b>, - latest: <b><%= updates.last.getRelease().getVersion() -%></b> - <div id="detail-<%= plugin.getKey() -%>" style="display:none"> - <table class="spaced"> - <tbody> - <%= render :partial => 'updatecenter/list', :locals => {:updates => updates, :plugin => true } %> - </tbody> - </table> - <form method="post" action="<%= ApplicationController.root_context -%>/updatecenter/install?from=updates&key=<%= plugin.getKey() -%>&version=<%= @last_compatible[plugin.getKey()] -%>" style="display: inline-block"> - <input type="submit" value="Update to <%= @last_compatible[plugin.getKey()] -%>"></input> - </form> - </div> - </td> - </tr> - <% end %> - </tbody> - </table> + <% if @center %> + <table class="data width100" id="plugin-updates"> + <thead> + <tr><th colspan="2"><h2>Plugins</h2></th></tr> + </thead> + <tbody> + <% if @updates_by_plugin.empty? %> + <tr class="even"> + <td colspan="2">No updates</td> + </tr> + <% end %> + <% @updates_by_plugin.keys.each do |plugin| + css=cycle('even','odd', :name => 'user-plugins') + updates=@updates_by_plugin[plugin] + updates.each_with_index do |update, index| + release=update.getRelease() + %> + <tr class="<%= css -%>"> + <td width="1%" nowrap><% if index==0 %><b><%= h(plugin.getName()) -%></b> <%= @user_plugins[plugin.getKey()] -%> -> <% end %></td> + <td width="1%" nowrap><b><%= release.getVersion() -%></b></td> + <td width="1%" nowrap><%= release_date(release.getDate()) if release.getDate() -%></td> + <td><%= release.getDescription() -%></td> + <td><%= link_to 'Release Notes', release.getChangelogUrl(), :class => 'external' if release.getChangelogUrl() %></td> + <td> + <% if update.isIncompatible() %> + <%= image_tag 'warning.png' -%> Not compatible + <% elsif update.requiresSonarUpgrade %> + <%= image_tag 'warning.png' -%> Not compatible, requires to upgrade system + <% end %> + </td> + </tr> + <% + end + %> + <tr class="<%= css -%>"> + <td> </td> + <td colspan="5"> + <form method="post" action="<%= ApplicationController.root_context -%>/updatecenter/install?from=updates&key=<%= plugin.getKey() -%>&version=<%= @last_compatible[plugin.getKey()] -%>" style="display: inline-block"> + <input type="submit" value="Upgrade to <%= @last_compatible[plugin.getKey()] -%>"></input> + </form> + </td> + </tr> + <% + end + %> + </tbody> + </table> - <div class="break30"> </div> + <div class="break30"> </div> - <table class="data width100" id="system-updates"> - <thead> - <tr><th colspan="4"><h2>System</h2></th></tr> - </thead> - <tbody> - <% if @sonar_updates.empty? %> - <tr class="even"> - <td colspan="4" >No updates</td> - </tr> - <% end %> - <%= render :partial => 'updatecenter/list', :locals => {:updates => @sonar_updates, :plugin => false } %> - </tbody> - </table> - <br/> -<% end %> -<%= render :partial => 'updatecenter/status', :locals => {:action => 'updates' } %> -</div> + <table class="data width100 marginbottom10" id="system-updates"> + <thead> + <tr><th colspan="4"><h2>System</h2></th></tr> + </thead> + <tbody> + <% if @sonar_updates.empty? %> + <tr class="even"> + <td colspan="4" >No updates</td> + </tr> + <% end %> + + + + <% @sonar_updates.each do |update| + css=cycle('even','odd', :name => 'system') + release=update.getRelease() + %> + <tr class="<%= css -%>"> + <td width="1%" nowrap><b>Sonar <%= release.getVersion() -%></b></td> + <td width="1%" nowrap><%= release_date(release.getDate()) if release.getDate() -%></td> + <td><%= release.getDescription() -%></td> + <td> + <%= link_to 'Release Notes', release.getChangelogUrl(), :class => 'external' if release.getChangelogUrl() %> + <%= link_to 'Download', release.getDownloadUrl(), :class => 'external' if release.getDownloadUrl() %> + </td> + </tr> + <% if update.hasWarnings() %> + <tr class="<%= css -%>"> + <td> </td> + <td colspan="3"> + <% if update.isIncompatible() %> + <%= image_tag 'warning.png' -%> Not compatible plugins must be uninstalled before upgrading system: + <%= update.getIncompatiblePlugins().map{|plugin| plugin.getName()}.sort.join(',') -%> + <% end %> + <% if update.requiresPluginUpgrades() %> + <%= image_tag 'warning.png' -%> Following plugins must be upgraded before upgrading system: + <ul> + <% update.getPluginsToUpgrade().each do |plugin| %> + <li><%= plugin.getArtifact().getName() -%> to <%= plugin.getVersion() -%></li> + <% end %> + </ul> + <% end %> + </td> + </tr> + <% end %> + <% end %> + </tbody> + </table> + <% end %> + <%= render :partial => 'updatecenter/status', :locals => {:action => 'updates' } %> + </div> diff --git a/sonar-server/src/test/java/org/sonar/server/plugins/UpdateFinderTest.java b/sonar-server/src/test/java/org/sonar/server/plugins/UpdateCenterMatrixTest.java index db453d1b515..b8c162acdc8 100644 --- a/sonar-server/src/test/java/org/sonar/server/plugins/UpdateFinderTest.java +++ b/sonar-server/src/test/java/org/sonar/server/plugins/UpdateCenterMatrixTest.java @@ -32,7 +32,7 @@ import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; -public class UpdateFinderTest { +public class UpdateCenterMatrixTest { private UpdateCenter center; private Plugin foo; @@ -66,9 +66,9 @@ public class UpdateFinderTest { @Test public void findPluginUpdates() { - UpdateFinder finder = new UpdateFinder(center, "2.1"); - finder.registerInstalledPlugin("foo", Version.create("1.0")); - List<PluginUpdate> updates = finder.findPluginUpdates(); + UpdateCenterMatrix matrix = new UpdateCenterMatrix(center, "2.1"); + matrix.registerInstalledPlugin("foo", Version.create("1.0")); + List<PluginUpdate> updates = matrix.findPluginUpdates(); assertThat(updates.size(), is(2)); assertThat(updates.get(0).getRelease(), is(foo11)); @@ -81,17 +81,17 @@ public class UpdateFinderTest { @Test public void noPluginUpdatesIfLastReleaseIsInstalled() { - UpdateFinder finder = new UpdateFinder(center, "2.3"); - finder.registerInstalledPlugin("foo", Version.create("1.2")); - assertTrue(finder.findPluginUpdates().isEmpty()); + UpdateCenterMatrix matrix = new UpdateCenterMatrix(center, "2.3"); + matrix.registerInstalledPlugin("foo", Version.create("1.2")); + assertTrue(matrix.findPluginUpdates().isEmpty()); } @Test public void availablePluginsAreOnlyTheBestReleases() { - UpdateFinder finder = new UpdateFinder(center, "2.2"); - finder.registerInstalledPlugin("foo", Version.create("1.0")); + UpdateCenterMatrix matrix = new UpdateCenterMatrix(center, "2.2"); + matrix.registerInstalledPlugin("foo", Version.create("1.0")); - List<PluginUpdate> availables = finder.findAvailablePlugins(); + List<PluginUpdate> availables = matrix.findAvailablePlugins(); // bar 1.0 is compatible with the installed sonar // bar 1.1 requires sonar to be upgraded to 2.2.2 or 2.3 @@ -103,10 +103,10 @@ public class UpdateFinderTest { @Test public void availablePluginsRequireSonarUpgrade() { - UpdateFinder finder = new UpdateFinder(center, "2.2.1"); - finder.registerInstalledPlugin("foo", Version.create("1.0")); + UpdateCenterMatrix matrix = new UpdateCenterMatrix(center, "2.2.1"); + matrix.registerInstalledPlugin("foo", Version.create("1.0")); - List<PluginUpdate> availables = finder.findAvailablePlugins(); + List<PluginUpdate> availables = matrix.findAvailablePlugins(); // bar 1.0 is not compatible with the installed sonar // bar 1.1 requires sonar to be upgraded to 2.2.2 or 2.3 @@ -121,8 +121,8 @@ public class UpdateFinderTest { center.getSonar().addRelease(Version.create("2.3")); center.getSonar().addRelease(Version.create("2.4")); - UpdateFinder finder = new UpdateFinder(center, "2.2"); - List<SonarUpdate> updates = finder.findSonarUpdates(); + UpdateCenterMatrix matrix = new UpdateCenterMatrix(center, "2.2"); + List<SonarUpdate> updates = matrix.findSonarUpdates(); // no plugins are installed, so both sonar versions are compatible assertThat(updates.size(), is(2)); @@ -135,10 +135,10 @@ public class UpdateFinderTest { center.getSonar().addRelease(Version.create("2.3")); center.getSonar().addRelease(Version.create("2.4")); - UpdateFinder finder = new UpdateFinder(center, "2.2"); - finder.registerInstalledPlugin("foo", Version.create("1.0")); - finder.registerInstalledPlugin("bar", Version.create("1.0")); - List<SonarUpdate> updates = finder.findSonarUpdates(); + UpdateCenterMatrix matrix = new UpdateCenterMatrix(center, "2.2"); + matrix.registerInstalledPlugin("foo", Version.create("1.0")); + matrix.registerInstalledPlugin("bar", Version.create("1.0")); + List<SonarUpdate> updates = matrix.findSonarUpdates(); assertThat(updates.size(), is(2)); @@ -156,19 +156,19 @@ public class UpdateFinderTest { @Test public void excludePendingDownloadsFromPluginUpdates() { - UpdateFinder finder = new UpdateFinder(center, "2.1"); - finder.registerInstalledPlugin("foo", Version.create("1.0")); - finder.registerPendingPluginsByFilename("foo-1.0.jar"); - List<PluginUpdate> updates = finder.findPluginUpdates(); + UpdateCenterMatrix matrix = new UpdateCenterMatrix(center, "2.1"); + matrix.registerInstalledPlugin("foo", Version.create("1.0")); + matrix.registerPendingPluginsByFilename("foo-1.0.jar"); + List<PluginUpdate> updates = matrix.findPluginUpdates(); assertThat(updates.size(), is(0)); } @Test public void excludePendingDownloadsFromAvailablePlugins() { - UpdateFinder finder = new UpdateFinder(center, "2.1"); - finder.registerPendingPluginsByFilename("foo-1.0.jar"); - finder.registerPendingPluginsByFilename("bar-1.1.jar"); - List<PluginUpdate> updates = finder.findAvailablePlugins(); + UpdateCenterMatrix matrix = new UpdateCenterMatrix(center, "2.1"); + matrix.registerPendingPluginsByFilename("foo-1.0.jar"); + matrix.registerPendingPluginsByFilename("bar-1.1.jar"); + List<PluginUpdate> updates = matrix.findAvailablePlugins(); assertThat(updates.size(), is(0)); } } |