From dd8e6540a7e1cab420488489c326b5c5d02016d4 Mon Sep 17 00:00:00 2001
From: Julien Lancelot <julien.lancelot@gmail.com>
Date: Wed, 20 Feb 2013 17:22:31 +0100
Subject: Update to latest update center API

---
 .../app/controllers/updatecenter_controller.rb       |  2 +-
 .../app/views/updatecenter/_children.html.erb        | 12 ------------
 .../app/views/updatecenter/available.html.erb        | 19 ++++++++++++++++---
 .../WEB-INF/app/views/updatecenter/index.html.erb    | 20 +++++++++++++++++---
 4 files changed, 34 insertions(+), 19 deletions(-)
 delete mode 100644 sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_children.html.erb

(limited to 'sonar-server')

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 aa8098209a4..37c62052a35 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
@@ -148,6 +148,6 @@ class UpdatecenterController < ApplicationController
   end
 
   def installed_plugins
-    @installed_plugin_referential.plugins
+    @installed_plugin_referential.lastMasterReleasePlugins
   end
 end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_children.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_children.html.erb
deleted file mode 100644
index 6b8cadcba13..00000000000
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/updatecenter/_children.html.erb
+++ /dev/null
@@ -1,12 +0,0 @@
-<% index = 0 %>
-<% children.each do |child| %>
-  <tr>
-    <% if index == 0 %>
-      <td class="thin nowrap"><b>Includes:</b></td>
-    <% else %>
-      <td>&nbsp;</td>
-    <% end %>
-    <td><span><%= child.name -%></span> : <span><%= child.description -%></span></td>
-  </tr>
-  <% index = index + 1 %>
-<% 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 cd2a1abeb7c..000736a63d7 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
@@ -32,8 +32,7 @@ function installPlugin(key) {
       </thead>
       <tbody>
     <% updates.sort_by{|update| update.plugin.key}.each do |update|
-      children = update.plugin.children
-      plugin = update.plugin
+        plugin = update.plugin
     %>
       <tr class="<%= cycle('even','odd', :name => category) -%>">
         <td width="150" nowrap>
@@ -43,7 +42,21 @@ function installPlugin(key) {
           <%= plugin.getDescription() %>
           <div id="detail-<%= plugin.getKey() -%>" style="display:none">
           <table class="spaced width100">
-            <%= render :partial => 'updatecenter/children', :locals => {:children => children}  %>
+            <% index = 0 %>
+            <% plugin.lastRelease.children.each do |child|
+              child_plugin = @update_center_referential.findPlugin(child.key)
+            %>
+              <tr>
+                <% if index == 0 %>
+                  <td class="thin nowrap"><b>Includes:</b></td>
+                <% else %>
+                  <td>&nbsp;</td>
+                <% end %>
+                <td><span><%= child_plugin.name -%></span> : <span><%= child_plugin.description -%></span></td>
+              </tr>
+              <% index = index + 1 %>
+            <% end %>
+
             <% release = @update_plugin_center.findLatestCompatibleRelease(plugin.key) %>
             <% release_dep_names = release.outgoingDependencies.collect { |dep| dep.artifact.name } %>
               <% unless release_dep_names.empty? %>
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 d553ae5e15d..5bfeff9301f 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
@@ -20,18 +20,32 @@
        <tr class="even"><td colspan="5">No plugins</td></tr>
      <% else
           @plugins.each do |plugin|
+            release = plugin.lastRelease
      %>
        <tr class="select <%= cycle('even', 'odd', :name => 'user') -%>" id="select_<%= plugin.getKey() -%>">
          <td width="1%" nowrap><b><a href="#plugin" onclick="showPlugin('<%= plugin.getKey() -%>')"><%= h(plugin.getName()) -%></a></b> <span class="note">[<%= h plugin.getKey() -%>]</span></td>
-         <td><%= plugin.lastRelease.getVersion() || '-' -%></td>
+         <td><%= release.getVersion() || '-' -%></td>
          <td>
          <%= plugin.getDescription() -%>
          <div id="detail-<%= plugin.getKey() -%>" style="display:none">
 
          <table class="spaced width100">
-           <%= render :partial => 'updatecenter/children', :locals => {:children => plugin.children}  %>
 
-           <% release = @installed_plugin_referential.findLatestRelease(plugin.key) %>
+           <% index = 0 %>
+           <% plugin.lastRelease.children.each do |child|
+             child_plugin = @installed_plugin_referential.findPlugin(child.key)
+           %>
+             <tr>
+               <% if index == 0 %>
+                 <td class="thin nowrap"><b>Includes:</b></td>
+               <% else %>
+                 <td>&nbsp;</td>
+               <% end %>
+               <td><span><%= child_plugin.name -%></span> : <span><%= child_plugin.description -%></span></td>
+             </tr>
+             <% index = index + 1 %>
+           <% end %>
+
            <% release_dep_names = release.outgoingDependencies.collect { |dep| dep.artifact.name } %>
            <% unless release_dep_names.empty? %>
              <tr>
-- 
cgit v1.2.3