]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3517 Ability to update profile in project configuration section
authorFabrice Bellingard <bellingard@gmail.com>
Mon, 2 Jul 2012 10:24:04 +0000 (12:24 +0200)
committerFabrice Bellingard <bellingard@gmail.com>
Mon, 2 Jul 2012 10:26:45 +0000 (12:26 +0200)
plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/project/quality_profile.html.erb [new file with mode: 0644]

index 755f6f02243375bf85b9f102e548882cf2093360..73c224d5077c64142269d125f44f4e5cf1ee4125 100644 (file)
@@ -330,6 +330,7 @@ lcom4_viewer.page=LCOM4
 dependencies.page=Dependencies
 resource_deletion.page={0} Deletion
 update_key.page=Update Key
+project_quality_profile.page=Quality Profile
 
 
 # GWT pages
@@ -972,6 +973,17 @@ update_key.current_key_for_project_x_is_x=The key of the "{0}" project is curren
 update_key.are_you_sure_to_rename_x=Are you sure you want to rename "{0}", as well as all its modules and resources ?
 update_key.are_you_sure_to_bulk_rename_x_into_x=Are you sure you want to rename "<b>{0}</b>{1}" into "<b>{2}</b>{1}", as well as all its modules and resources ?
 
+
+#------------------------------------------------------------------------------
+#
+# PROJECT QUALITY PROFILE PAGE
+#
+#------------------------------------------------------------------------------
+project_quality_profile.current_profile_for_x=Current quality profile for "{0}":
+project_quality_profile.project_cannot_be_update_with_profile_x=The current project can not be updated with the following profile: "{0}".
+project_quality_profile.profile_successfully_updated=Quality profile successfully updated.
+
+
 #------------------------------------------------------------------------------
 #
 # PROJECT (RESOURCE) DELETION PAGE
index dbe65bc7a5f74692f46be39bf38c497359973be8..9a91912b8156cd8d8131f795e5b3726d63601dc6 100644 (file)
@@ -18,7 +18,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
 #
 class ProjectController < ApplicationController
-  verify :method => :post, :only => [:set_links, :set_exclusions, :delete_exclusions, :update_key, :perform_key_bulk_update], 
+  verify :method => :post, :only => [:set_links, :set_exclusions, :delete_exclusions, :update_key, :perform_key_bulk_update, :update_quality_profile], 
          :redirect_to => {:action => :index}
   verify :method => :delete, :only => [:delete], :redirect_to => {:action => :index}
 
@@ -48,6 +48,27 @@ class ProjectController < ApplicationController
     redirect_to_default
   end
   
+  def quality_profile
+    @project = get_current_project(params[:id])
+    @profiles = Profile.find(:all, :conditions => {:language => @project.language, :enabled => true})
+  end
+  
+  def update_quality_profile
+    project = get_current_project(params[:id])
+    
+    selected_profile = Profile.find(:first, :conditions => {:id => params[:quality_profile]})
+    if selected_profile && selected_profile.language == project.language 
+      project.profile = selected_profile
+      project.save!
+      flash[:notice] = message('project_quality_profile.profile_successfully_updated')
+    else
+      selected_profile_name = selected_profile ? selected_profile.name + "(" + selected_profile.language + ")" : "Unknown profile"
+      flash[:error] = message('project_quality_profile.project_cannot_be_update_with_profile_x', :params => selected_profile_name)
+    end
+    
+    redirect_to :action => 'quality_profile', :id => project.id
+  end
+  
   def key
     @project = get_current_project(params[:id])
       
index 67cb894ef68f1f9263c9148c6218fdf3af9cddae..37a9379ace6288b158c9879c4c37218ed4183b82 100644 (file)
             <% end %>
             <% if has_role?(:admin, @project) %>
               <li class="h2"><%= message('sidebar.project_settings') -%></li>
+              <% if (@project.project?) %>
+                <li class="<%= 'selected' if request.request_uri.include?('/project/quality_profile') -%>">
+                  <a href="<%= ApplicationController.root_context -%>/project/quality_profile/<%= @project.id -%>"><%= message('project_quality_profile.page') -%></a></li>
+              <% end %>
               <li class="<%= 'selected' if request.request_uri.include?('/manual_measures') -%>">
                 <a href="<%= ApplicationController.root_context -%>/manual_measures/index/<%= @project.id -%>"><%= message('manual_measures.page') -%></a></li>
               <% if (@project.project?) %>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/quality_profile.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/quality_profile.html.erb
new file mode 100644 (file)
index 0000000..078956f
--- /dev/null
@@ -0,0 +1,19 @@
+<h1><%= message('project_quality_profile.page') -%></h1>
+<br/>
+<% 
+   form_tag( {:action => 'update_quality_profile', :id => @project.id }) do
+     project_profile = @project.profile 
+%>
+
+  <span style= "padding-right: 10px"><%= message('project_quality_profile.current_profile_for_x', :params => @project.name) -%></span>
+
+  <select name="quality_profile" id="quality_profile">
+    <% @profiles.each do |profile| %>
+      <option <%= 'selected' if (project_profile && project_profile==profile) || (!project_profile && profile.default_profile) -%> 
+              value="<%= profile.id -%>"><%= profile.name -%></option>
+    <% end %>
+  </select>
+  
+  <%= submit_tag message('update_verb'), :id => 'update_profile' %>
+  
+<% end %>