diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-01-08 17:27:05 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2014-01-08 17:27:05 +0100 |
commit | b8f14b0c67995f3372af529772d91ee9c1af8874 (patch) | |
tree | bc174bd0b61338ed830dfd76795d1faef0f1a924 /sonar-server/src/main/webapp/WEB-INF | |
parent | f309fc178aae760aee263bf19f2afe2f2fd25967 (diff) | |
download | sonarqube-b8f14b0c67995f3372af529772d91ee9c1af8874.tar.gz sonarqube-b8f14b0c67995f3372af529772d91ee9c1af8874.zip |
SONAR-4923 List inheritance profiles now uses Java facade
Diffstat (limited to 'sonar-server/src/main/webapp/WEB-INF')
3 files changed, 19 insertions, 13 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb index b4bce6d2c83..cab5e63475a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb @@ -180,10 +180,15 @@ class ProfilesController < ApplicationController # GET /profiles/inheritance?id=<profile id> def inheritance require_parameters 'id' - @profile = Profile.find(params[:id]) - profiles=Profile.all(:conditions => ['language=? and id<>? and (parent_name is null or parent_name<>?)', @profile.language, @profile.id, @profile.name], :order => 'name') - @select_parent = [[message('none'), nil]] + profiles.collect { |profile| [profile.name, profile.name] } + call_backend do + @profile = Internal.quality_profiles.profile(params[:id].to_i) + @ancestors = Internal.quality_profiles.ancestors(@profile).to_a + @children = Internal.quality_profiles.children(@profile).to_a + profiles = Internal.quality_profiles.profilesByLanguage(@profile.language()).to_a.reject{|p| p.id == @profile.id() || p.parent() == @profile.name()} + profiles = Api::Utils.insensitive_sort(profiles) { |p| p.name()} + @select_parent = [[message('none'), nil]] + profiles.collect { |profile| [profile.name(), profile.name()] } + end set_profile_breadcrumbs end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb index eb019e18398..71df4bfae66 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/profiles_helper.rb @@ -23,10 +23,11 @@ module ProfilesHelper controller.java_facade.getLanguages() end - def label_for_rules_count(profile) - label="#{profile.count_active_rules} #{message('rules').downcase}" + def label_for_rules_count(qProfile) + profile_rules_count = profile_rules_count(qProfile) + label = "#{profile_rules_count} #{message('rules').downcase}" - count_overriding=profile.count_overriding_rules + count_overriding = Internal.quality_profiles.countOverridingProfileRules(qProfile).to_i if count_overriding>0 label += message('quality_profiles.including_x_overriding.suffix', :params => count_overriding) label += image_tag('overrides.png') diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb index 06cb2996288..806111b245c 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb @@ -7,19 +7,19 @@ <tr> <td align="center" valign="top"> <div> - <% @profile.ancestors.reverse.each do |parent| %> - <a href="<%= url_for :action => 'inheritance', :id => parent.id -%>"><%= parent.name -%></a> + <% @ancestors.reverse.each do |parent| %> + <a href="<%= url_for :action => 'inheritance', :id => parent.id() -%>"><%= parent.name() -%></a> <span class="note">(<%= label_for_rules_count(parent) -%>)</span><br/> <%= image_tag 'blue-up.png' -%><br/> <% end %> <b><%= @profile.name -%></b> <span class="note">(<%= label_for_rules_count(@profile) -%>)</span><br/> - <% if @profile.children.size>0 %> + <% if @children.size>0 %> <%= image_tag 'blue-up.png' -%><br/> - <% @profile.children.each_with_index do |child,index| %> + <% @children.each_with_index do |child,index| %> <%= ', ' if index>0 -%> - <a href="<%= url_for :action => 'inheritance', :id => child.id -%>"><%= child.name -%></a> + <a href="<%= url_for :action => 'inheritance', :id => child.id() -%>"><%= child.name() -%></a> <span class="note">(<%= label_for_rules_count(child) -%>)</span> <% end %> <br/><%= image_tag 'blue-up.png' -%><br/> @@ -33,8 +33,8 @@ <h3><%= message('quality_profiles.set_parent') -%>:</h3> <p><%= message('quality_profiles.inherit_rules_from_profile') -%>:</p> <% form_tag({:action => 'change_parent'}, {:method => 'post'}) do %> - <%= hidden_field_tag "id", @profile.id %> - <%= select_tag "parent_name", options_for_select(@select_parent, @profile.parent_name) %> + <%= hidden_field_tag "id", @profile.id() %> + <%= select_tag "parent_name", options_for_select(@select_parent, @profile.parent()) %> <%= submit_tag message('change_verb'), :id => 'submit_parent'%> <% end %> </div> |