]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4351 Centralize the management of licenses in the Global Settings
authorJulien HENRY <julien.henry@sonarsource.com>
Thu, 11 Jul 2013 16:25:43 +0000 (18:25 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Thu, 11 Jul 2013 16:27:13 +0000 (18:27 +0200)
plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/views/server_id_configuration/index.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/settings/_properties.html.erb

index cf14f39fac15c3c568989dc7412b43d17d9cba6c..009676d622d90e05870b6da0814b72137c1567e4 100644 (file)
@@ -1547,10 +1547,12 @@ email_configuration.test.email_was_sent_to_x=Email was sent to {0}
 
 #------------------------------------------------------------------------------
 #
-# SERVER KEY CONFIGURATION
+# LICENSES & SERVER KEY CONFIGURATION
 #
 #------------------------------------------------------------------------------
-server_id_configuration.page=Server ID
+property.category.Licenses=Licenses
+property.category.Licenses.description=In case of any issue or question about licenses, please send an email to contact@sonarsource.com.
+property.category.Licenses.server_id=Server ID
 server_id_configuration.generate_button=Generate ID
 server_id_configuration.generating_button=Generating ID...
 server_id_configuration.bad_key=The ID is not valid anymore. Please check the organisation and the IP address.
index d0cf36f13d145f5e0654240cf0d694f2c1082a4e..ed05613c90db3dd9b4227e5ea9947be2a4ff8cfc 100644 (file)
@@ -21,7 +21,10 @@ class SettingsController < ApplicationController
 
   SECTION=Navigation::SECTION_CONFIGURATION
 
-  SPECIAL_CATEGORIES=%w(email encryption server_id)
+  LICENSES_CATEGORY='Licenses'
+  SERVER_ID_SUBCATEGORY='server_id'
+  SPECIAL_CATEGORIES=%w(email encryption) + [LICENSES_CATEGORY]
+
 
   verify :method => :post, :only => %w(update), :redirect_to => {:action => :index}
   before_filter :admin_required, :only => %w(index)
@@ -102,17 +105,27 @@ class SettingsController < ApplicationController
   def load_properties
     definitions_per_category = java_facade.propertyDefinitions.getPropertiesByCategory(@resource ? @resource.qualifier : nil)
     @categories = definitions_per_category.keys + SPECIAL_CATEGORIES
-    @categories = by_category_name(@categories)
+    @categories = by_category_name(@categories.uniq)
 
-    default_category = nil
-    default_category = @categories[0] if !@categories.empty?
+    default_category = @categories.empty? ? nil : @categories[0]
     @category = params[:category] || default_category
 
     not_found('category') unless @categories.include? @category
 
-    @subcategory = params[:subcategory] || @category
     @subcategories_per_categories = {}
     definitions_per_category.each {|category, definitions_per_subcategories| @subcategories_per_categories.store(category, by_subcategory_name(category, definitions_per_subcategories.keys)) }
+
+    if (@subcategories_per_categories[LICENSES_CATEGORY].nil?)
+      @subcategories_per_categories.store(LICENSES_CATEGORY, [SERVER_ID_SUBCATEGORY])
+    else
+      @subcategories_per_categories[LICENSES_CATEGORY].push(SERVER_ID_SUBCATEGORY)
+    end
+
+    default_subcategory =
+      @subcategories_per_categories[@category].nil? ? nil :
+        ((@subcategories_per_categories[@category].include? @category) ? @category : @subcategories_per_categories[@category][0])
+    @subcategory = params[:subcategory] || default_subcategory
+
     @definitions = definitions_per_category[@category] || {}
     @definitions = @definitions[@subcategory] || []
   end
index ee7269441b7ea1b5b3d2eed4682359304a986bc3..d3b5bb3b0555cc6e3d0b8e3d467bcb8c6f2b24c5 100644 (file)
@@ -7,9 +7,6 @@
 <% form_tag :action => 'generate' do %>
   <table class="data marginbottom10">
     <thead>
-    <tr>
-      <th><%= message('server_id_configuration.page') -%></th>
-    </tr>
     </thead>
     <tbody>
     <tr class="even">
index 7f20210189745ed094df63604da6280e4305ef2e..6687598bd4f65a2a71db872af8ed60b33f2472da 100644 (file)
@@ -1,4 +1,4 @@
-<% if SettingsController::SPECIAL_CATEGORIES.include?(@category) -%>
+<% if SettingsController::SPECIAL_CATEGORIES.include?(@category) && @category != SettingsController::LICENSES_CATEGORY -%>
   <%= render 'special', :url => url_for(:controller => "#{@category}_configuration") -%>
 <% else -%>
   <% form_remote_tag :url => {:controller => 'settings', :action => 'update', :category => @category, :subcategory => @subcategory, :resource_id => @resource ? @resource.id : nil},
         </li>
       <% end -%>
     </ul>
-    <table class="data marginbottom10">
-      <thead>
-      <% if @subcategory == @category && !category_desc(@category).blank? -%>
-        <tr>
-          <td class="categoryDescription"><%= category_desc(@category) -%> </td>
-        </tr>
-      <% end -%>
-      <% if @subcategory != @category && !subcategory_desc(@category, @subcategory).blank? -%>
-        <tr>
-          <td><%= subcategory_desc(@category, @subcategory) -%> </td>
-        </tr>
-      <% end -%>
-      </thead>
-      <tbody>
-      <% by_property_index_or_name(@definitions).each do |property| -%>
-        <tr class="property <%= cycle('even', 'odd', :name => 'properties') -%>">
-          <td style="padding: 10px" id="block_<%= property.key -%>">
-            <h3>
-              <div><%= property_name(property) -%></div>
-              <div class="note"><%= property.key -%></div>
-            </h3>
-            <% desc=property_description(property) -%>
-            <% unless desc.blank? %>
-              <p class="marginbottom10"><%= desc -%></p>
-            <% end -%>
+    <% if @category == SettingsController::LICENSES_CATEGORY && @subcategory == SettingsController::SERVER_ID_SUBCATEGORY %>
+      <%= render 'special', :url => url_for(:controller => "#{SettingsController::SERVER_ID_SUBCATEGORY}_configuration") -%>
+    <% else %>
+      <table class="data marginbottom10">
+        <thead>
+        <% if @subcategory == @category && !category_desc(@category).blank? -%>
+          <tr>
+            <td class="categoryDescription"><%= category_desc(@category) -%> </td>
+          </tr>
+        <% end -%>
+        <% if @subcategory != @category && !subcategory_desc(@category, @subcategory).blank? -%>
+          <tr>
+            <td><%= subcategory_desc(@category, @subcategory) -%> </td>
+          </tr>
+        <% end -%>
+        </thead>
+        <tbody>
+        <% by_property_index_or_name(@definitions).each do |property| -%>
+          <tr class="property <%= cycle('even', 'odd', :name => 'properties') -%>">
+            <td style="padding: 10px" id="block_<%= property.key -%>">
+              <h3>
+                <div><%= property_name(property) -%></div>
+                <div class="note"><%= property.key -%></div>
+              </h3>
+              <% desc=property_description(property) -%>
+              <% unless desc.blank? %>
+                <p class="marginbottom10"><%= desc -%></p>
+              <% end -%>
 
-            <% value = property_value(property) -%>
-            <% if property.multi_values -%>
-              <% value.each_with_index do |sub_value, index| -%>
-                <%= render "settings/multi_value", :property => property, :value => sub_value, :hide_delete => index == 0 -%>
+              <% value = property_value(property) -%>
+              <% if property.multi_values -%>
+                <% value.each_with_index do |sub_value, index| -%>
+                  <%= render "settings/multi_value", :property => property, :value => sub_value, :hide_delete => index == 0 -%>
+                <% end -%>
+                <div class="template" style="display:none;">
+                  <%= render "settings/multi_value", :property => property, :value => nil, :hide_delete => false -%>
+                </div>
+                <button class="add_value"><%= message('settings.add') -%></button>
+                <br/>
+              <% else -%>
+                <%= render "settings/single_value", :property => property, :value => value -%>
               <% end -%>
-              <div class="template" style="display:none;">
-                <%= render "settings/multi_value", :property => property, :value => nil, :hide_delete => false -%>
-              </div>
-              <button class="add_value"><%= message('settings.add') -%></button>
-              <br/>
-            <% else -%>
-              <%= render "settings/single_value", :property => property, :value => value -%>
-            <% end -%>
 
-            <%= render "settings/error", :key => property.key -%>
+              <%= render "settings/error", :key => property.key -%>
 
-            <% default_prop_value = (@resource ? Property.value(property.key, nil, property.defaultValue) : property.defaultValue) -%>
-            <% unless default_prop_value.blank? -%>
-              <div class="note"><%= message('default') %>: <%= property.type.to_s=='PASSWORD' ? '********' : h(default_prop_value) -%></div>
-            <% end -%>
-          </td>
-        </tr>
-      <% end -%>
+              <% default_prop_value = (@resource ? Property.value(property.key, nil, property.defaultValue) : property.defaultValue) -%>
+              <% unless default_prop_value.blank? -%>
+                <div class="note"><%= message('default') %>: <%= property.type.to_s=='PASSWORD' ? '********' : h(default_prop_value) -%></div>
+              <% end -%>
+            </td>
+          </tr>
+        <% end -%>
 
-      <% unless @subcategory != @category || category_help(@category).blank? -%>
-        <tr class="property <%= cycle('even', 'odd', :name => 'properties') -%>">
-          <td class="help"><%= category_help(@category) -%> </td>
-        </tr>
-      <% end -%>
+        <% unless @subcategory != @category || category_help(@category).blank? -%>
+          <tr class="property <%= cycle('even', 'odd', :name => 'properties') -%>">
+            <td class="help"><%= category_help(@category) -%> </td>
+          </tr>
+        <% end -%>
 
-      </tbody>
-    </table>
-    <% unless @definitions.empty? %>
-    <div style="padding-left: 16px;">
-      <%= hidden_field_tag('page_version', (params[:page_version] || 0).to_i + 1) -%>
-      <%= submit_tag(message('settings.save_category', :params => [subcategory_name(@category, @subcategory)]), :id => 'submit_settings') -%>
-      <img src="<%= ApplicationController.root_context -%>/images/loading.gif" id="loading_settings" style="display:none;">
-    </div>
+        </tbody>
+      </table>
+      <% unless @definitions.empty? %>
+      <div style="padding-left: 16px;">
+        <%= hidden_field_tag('page_version', (params[:page_version] || 0).to_i + 1) -%>
+        <%= submit_tag(message('settings.save_category', :params => [subcategory_name(@category, @subcategory)]), :id => 'submit_settings') -%>
+        <img src="<%= ApplicationController.root_context -%>/images/loading.gif" id="loading_settings" style="display:none;">
+      </div>
+      <% end %>
     <% end %>
   <% end -%>
 <% end -%>