From 1103e34e0b7bd96ac258dd4ccdb6c308f738f281 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Vilain Date: Fri, 12 Jul 2013 14:57:43 +0200 Subject: [PATCH] SONAR-4453 Added modal form to apply permission template to components --- sonar-server/src/dev/h2/conf/logback.xml | 21 +++++++---- .../app/controllers/roles_controller.rb | 8 +++-- .../views/permission_templates/index.html.erb | 4 +-- .../views/roles/_apply_template_form.html.erb | 36 +++++++++++++++++++ .../WEB-INF/app/views/roles/projects.html.erb | 4 +-- 5 files changed, 59 insertions(+), 14 deletions(-) create mode 100644 sonar-server/src/main/webapp/WEB-INF/app/views/roles/_apply_template_form.html.erb diff --git a/sonar-server/src/dev/h2/conf/logback.xml b/sonar-server/src/dev/h2/conf/logback.xml index 1bde810d728..a5dca488705 100644 --- a/sonar-server/src/dev/h2/conf/logback.xml +++ b/sonar-server/src/dev/h2/conf/logback.xml @@ -9,22 +9,31 @@ + + + + - - - + + - + + + + + - - + + + + diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/roles_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/roles_controller.rb index 343a34a9318..89398383705 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/roles_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/roles_controller.rb @@ -86,8 +86,10 @@ class RolesController < ApplicationController bad_request('Missing qualifier') if params[:qualifier].blank? end - def bulk_apply_form - + def apply_template_form + bad_request('There are currently no results to apply the permission template to') if params[:projects].blank? + @permission_templates = Internal.permission_templates.selectAllPermissionTemplates().collect {|pt| [pt.name, pt.id]} + render :partial => 'apply_template_form', :locals => {:components => params[:projects], :qualifier => params[:qualifier] || 'TRK'} end # POST REQUESTS @@ -120,7 +122,7 @@ class RolesController < ApplicationController redirect end - def bulk_apply_template + def apply_template verify_post_request require_parameters :template_id Internal.permissions.applyPermissionTemplate(params) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/index.html.erb index 9638d93f275..7d0360d83f3 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/index.html.erb @@ -5,13 +5,11 @@

This section allows you to configure the default permission templates that will be applied by SonarQube while analysing your projects.

-
<% form_tag(:controller => 'permission_templates', :action => 'set_default_template') do %> <% @root_qualifiers.each do |qualifier| %> <%= label_tag("default_template_#{qualifier}", "Default permission template for #{message('qualifier.' + qualifier)}:") %> - <%= select_tag("default_template_#{qualifier}", options_for_select(@permission_templates_options, @default_templates[qualifier])) %> -
+ <%= select_tag("default_template_#{qualifier}", options_for_select(@permission_templates_options, @default_templates[qualifier])) %>   <% end %>

diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/roles/_apply_template_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/roles/_apply_template_form.html.erb new file mode 100644 index 00000000000..7a91d6590df --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/roles/_apply_template_form.html.erb @@ -0,0 +1,36 @@ +
+ +
+ +
+
+ diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/roles/projects.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/roles/projects.html.erb index 7b32d9edfb0..4311b9721e7 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/roles/projects.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/roles/projects.html.erb @@ -16,8 +16,8 @@
  • - <%= message('projects_role.apply_template') -%> + <%= link_to message('projects_role.apply_template'), {:action => :apply_template_form, :projects => @projects.collect {|proj| proj.id}, :qualifier => @qualifier}, + :id => 'apply-template-modal', :class => 'open-modal link-action' %>
-- 2.39.5