diff options
author | Godin <mandrikov@gmail.com> | 2010-10-27 20:40:24 +0000 |
---|---|---|
committer | Godin <mandrikov@gmail.com> | 2010-10-27 20:40:24 +0000 |
commit | 0b86ed2749b5f39f655255327f8af28de0b1889b (patch) | |
tree | bd6b395b1fbb7bdaef73f9905f7e8da14057c80f | |
parent | 6e0bd0e0c8a4bfb145131a266d6bb4d1c3be2b52 (diff) | |
download | sonarqube-0b86ed2749b5f39f655255327f8af28de0b1889b.tar.gz sonarqube-0b86ed2749b5f39f655255327f8af28de0b1889b.zip |
SONAR-1887: Display available plugin updates
SONAR-1888: Add a button to install the last compatible version
6 files changed, 92 insertions, 61 deletions
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 a3014ae14ff..ecb22671e69 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,13 +38,27 @@ class UpdatecenterController < ApplicationController @center=nil @sonar_updates=[] - @plugin_updates=[] + @updates_by_plugin={} + @user_plugins={} + @last_compatible={} + + Plugin.user_plugins.each do |plugin| + @user_plugins[plugin.plugin_key]=plugin.version + end finder=load_update_finder() if finder @center=finder.getCenter() @sonar_updates=finder.findSonarUpdates() - @plugin_updates=finder.findPluginUpdates() + + @finder.findPluginUpdates().each do |update| + plugin=update.getPlugin() + @updates_by_plugin[plugin]||=[] + @updates_by_plugin[plugin]<<update + if update.isCompatible + @last_compatible[plugin.getKey()]=update.getRelease().getVersion() + end + end end end 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 new file mode 100644 index 00000000000..30e23f9c8e9 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/updatecenter_helper.rb @@ -0,0 +1,26 @@ +# +# Sonar, entreprise quality control tool. +# Copyright (C) 2009 SonarSource SA +# mailto:contact AT sonarsource DOT com +# +# Sonar is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# Sonar is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with Sonar; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 +# +module UpdatecenterHelper + + def release_date(date) + Time.at(date.getTime() / 1000).strftime('%B %e, %Y') + 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 new file mode 100644 index 00000000000..5fc452e1171 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_list.html.erb @@ -0,0 +1,22 @@ +<% 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> + <% end %> + </tr> +<% end %> 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 126e83db43d..3b17d550e92 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 @@ -22,13 +22,13 @@ updates=@updates_by_category[category] %> <tr> - <td colspan="2"><h2><%= category -%></td> + <td colspan="2"><h2><%= category -%></h2></td> </tr> <% updates.sort_by{|c| c.getPlugin().getName()}.each do |update| plugin=update.getPlugin() %> <tr class="<%= cycle('even','odd', :name => category) -%>"> - <td width="10%" nowrap> + <td width="1%" nowrap> <b><a href="#plugin" onClick="showPlugin('<%= plugin.getKey() -%>');"><%= h(plugin.getName()) -%></a></b> </td> <td> 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 b5d8ffab38d..71996d7453f 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 @@ -9,7 +9,6 @@ <a href="<%= url_for :action => 'available' -%>">Available</a> </li> </ul> - <div class="tabs-panel"> <%= render :partial => 'updatecenter/operations' -%> @@ -30,7 +29,7 @@ @user_plugins.each do |plugin| %> <tr class="select <%= cycle('even', 'odd', :name => 'user') -%>" id="select_<%= plugin.plugin_key -%>"> - <td><b><a href="#plugin" onclick="showPlugin('<%= plugin.plugin_key -%>')"><%= h(plugin.name) -%></a></b></td> + <td width="1%" nowrap><b><a href="#plugin" onclick="showPlugin('<%= plugin.plugin_key -%>')"><%= h(plugin.name) -%></a></b></td> <td><%= plugin.version || '-' -%></td> <td> <%= plugin.description -%> @@ -70,7 +69,7 @@ <% @core_plugins.each do |plugin| %> - <tr class="<%= cycle('even','odd', :name => 'core') -%>" id="<%= u plugin.plugin_key -%>"> + <tr class="<%= cycle('even','odd', :name => 'core') -%>" id="<%= u plugin.plugin_key -%>"> <td width="1%" nowrap><b><%= plugin.name -%></b></td> <td><%= plugin.description %></td> </tr> 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 32deda6e50b..b9f9d636f51 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 @@ -16,45 +16,34 @@ <% if @center %> <table class="data width100" id="plugin-updates"> <thead> - <tr> - <th colspan="2"><h2>User-installed plugins</h2></th> - </tr> + <tr><th colspan="2"><h2>User-installed plugins</h2></th></tr> </thead> <tbody> - <% if @plugin_updates.empty? %> + <% if @updates_by_plugin.empty? %> <tr class="even"> <td colspan="2">No updates</td> </tr> <% end %> - <% @plugin_updates.each do |update| + <% @updates_by_plugin.keys.each do |plugin| + updates=@updates_by_plugin[plugin] %> <tr class="<%= cycle('even','odd', :name => 'user-plugins') -%>"> - <td><b><a href="#plugin" onclick="showPlugin('<%= update.getPlugin().getKey() + update.getRelease().getVersion().toString() -%>')"><%= h(update.getPlugin().getName()) -%></a></b></td> + <td width="1%" nowrap> + <b><a href="#plugin" onclick="showPlugin('<%= plugin.getKey() -%>')"><%= h(plugin.getName()) -%></a></b> + </td> <td> - <%= update.getRelease().getVersion() -%> - <% if update.isIncompatible() %> - not compatible - <% elsif update.requiresSonarUpgrade %> - not compatible, needs Sonar upgrade - <% end %> - - <div id="detail-<%= update.getPlugin().getKey() + update.getRelease().getVersion().toString() -%>" style="display:none"> - <p> - <%= update.getRelease().getDescription() -%><br/> - <% if update.getRelease().getDate() %> - Released <%= update.getRelease().getDate() -%><br/> - <% end %> - - <% if update.getRelease().getChangelogUrl() %> - <%= link_to 'Changelog', update.getRelease().getChangelogUrl(), :class => 'external' -%><br/> - <% end %> - </p> - - <% if update.isCompatible() %> - <form method="post" action="<%= ApplicationController.root_context -%>/updatecenter/install?from=updates&key=<%= update.getPlugin().getKey() -%>&version=<%= update.getRelease().getVersion() -%>" style="display: inline-block"> - <input type="submit" value="Update"></input> - </form> - <% end %> + 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> @@ -62,38 +51,19 @@ </tbody> </table> - <br/> + <div class="break30"> </div> <table class="data width100" id="system-updates"> <thead> - <tr> - <th colspan="2"><h2>System</h2></th> - </tr> + <tr><th colspan="4"><h2>System</h2></th></tr> </thead> <tbody> - <% - if @sonar_updates.empty? %> + <% if @sonar_updates.empty? %> <tr class="even"> - <td colspan="3" >No updates</td> - </tr> - <% end %> - <% @sonar_updates.each do |update| - sonar_release=update.getRelease() - %> - <tr class="<%= cycle('even','odd', :name => 'system') -%>"> - <td><b>Sonar <%= sonar_release.getVersion() -%></b></td> - <td> - <%= sonar_release.getDescription() -%> - <% if update.getRelease().getDate() %> - Released <%= update.getRelease().getDate() -%><br/> - <% end %> - </td> - <td> - <%= link_to 'Release Notes', sonar_release.getChangelogUrl(), :class => 'external' if sonar_release.getChangelogUrl() %> - <%= link_to 'Download', sonar_release.getDownloadUrl(), :class => 'external' if sonar_release.getDownloadUrl() %> - </td> + <td colspan="4" >No updates</td> </tr> <% end %> + <%= render :partial => 'updatecenter/list', :locals => {:updates => @sonar_updates, :plugin => false } %> </tbody> </table> <br/> |