aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2013-07-11 18:25:43 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2013-07-11 18:27:13 +0200
commitf09e68315cb2c97f6944ad07237902981d97add3 (patch)
tree8b5ae5b68f0f424ba1e4136c029bc7df7d3577bc
parent6335b59fcfed11479e64ecc57a5109500432a4e9 (diff)
downloadsonarqube-f09e68315cb2c97f6944ad07237902981d97add3.tar.gz
sonarqube-f09e68315cb2c97f6944ad07237902981d97add3.zip
SONAR-4351 Centralize the management of licenses in the Global Settings
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties6
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb23
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/server_id_configuration/index.html.erb3
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/settings/_properties.html.erb122
4 files changed, 85 insertions, 69 deletions
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
index cf14f39fac1..009676d622d 100644
--- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
+++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
@@ -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.
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb
index d0cf36f13d1..ed05613c90d 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/settings_controller.rb
@@ -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
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/server_id_configuration/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/server_id_configuration/index.html.erb
index ee7269441b7..d3b5bb3b055 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/server_id_configuration/index.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/server_id_configuration/index.html.erb
@@ -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">
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_properties.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_properties.html.erb
index 7f202101897..6687598bd4f 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_properties.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/settings/_properties.html.erb
@@ -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},
@@ -14,70 +14,74 @@
</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 -%>