]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4453 Added modal form to apply permission template to components
authorJean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com>
Fri, 12 Jul 2013 12:57:43 +0000 (14:57 +0200)
committerJean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com>
Fri, 12 Jul 2013 12:57:43 +0000 (14:57 +0200)
sonar-server/src/dev/h2/conf/logback.xml
sonar-server/src/main/webapp/WEB-INF/app/controllers/roles_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/index.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/roles/_apply_template_form.html.erb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/app/views/roles/projects.html.erb

index 1bde810d72836c32a014e9f0107876f252028df5..a5dca48870536760cc9d152129940be831c1c039 100644 (file)
@@ -9,22 +9,31 @@
     </encoder>
   </appender>
 
+  <logger name="rails">
+    <level value="DEBUG"/>
+  </logger>
+
   <logger name="org.hibernate.cache.ReadWriteCache">
     <!-- removing "An item was expired by the cache while it was locked (increase your cache timeout)" msg -->
     <level value="ERROR"/>
   </logger>
-
-  <logger name="org.sonar.INFO">
-    <level value="INFO"/>
+  <logger name="org.hibernate">
+    <level value="WARN"/>
   </logger>
 
-  <logger name="rails">
+  <!-- Display SQL requests and results by setting the following loggers to level DEBUG -->
+  <logger name="org.hibernate.SQL">
+    <level value="WARN"/>
+  </logger>
+  <logger name="org.apache.ibatis">
     <level value="DEBUG"/>
   </logger>
-
-  <logger name="org.sonar.MEASURE_FILTER">
+  <logger name="java.sql">
     <level value="DEBUG"/>
   </logger>
+  <logger name="java.sql.ResultSet">
+    <level value="WARN"/>
+  </logger>
 
   <root>
     <level value="INFO"/>
index 343a34a93184ea7a1b5c155fe7e70ba7b165ba24..893983837057a53eba7f2c83764e7617d1e9d2d2 100644 (file)
@@ -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)
index 9638d93f275f18a19ed357d16a07da8374a8be23..7d0360d83f3ab108558ffc2384c1eea4d0a17238 100644 (file)
@@ -5,13 +5,11 @@
   <p>
     This section allows you to configure the default permission templates that will be applied by SonarQube while analysing your projects.
   </p>
-  <br/>
   <% 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])) %>
-      <br/>
+      <%= select_tag("default_template_#{qualifier}", options_for_select(@permission_templates_options, @default_templates[qualifier])) %>&nbsp;&nbsp;
     <% end %>
     <br/>
     <br/>
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 (file)
index 0000000..7a91d65
--- /dev/null
@@ -0,0 +1,36 @@
+<form id="apply-template-form" method="post" action="<%= ApplicationController.root_context -%>/roles/apply_template">
+  <input type="hidden" name="components" id="apply-template-components" value="<%= components.join(',') %>"/>
+  <fieldset>
+    <div class="modal-head">
+      <h2><%= message('roles.apply_template.form.title', {:params => ''}) -%></h2>
+    </div>
+    <div class="modal-body">
+      <div class="apply-template errors error" style="display:none;"/>
+      <div class="modal-field">
+        <span><%= "Select the template to apply to #{components.size} #{message('qualifier.' + qualifier)}(s):" %></span><br/>
+        <%= select_tag('template_id', options_for_select(@permission_templates, -1)) %>
+      </div>
+    </div>
+    <div class="modal-foot">
+      <span id="apply-template-loading-image" class="hidden"><%= image_tag 'loading.gif' %></span>
+      <input type="submit" value="<%= message('apply') -%>" id="apply-template-submit" class="apply-template" onclick="return displayLoadingImage()" />
+      <a href="#" onclick="return closeModalWindow()" id="apply-template-cancel"><%= message('cancel') -%></a>
+    </div>
+  </fieldset>
+</form>
+<script>
+  $j("#apply-template-form").modalForm({
+    error: function (xhr, textStatus, errorThrown) {
+      $j('#apply-template-loading-image').addClass("hidden");
+      var htmlClass = 'apply-template';
+      $j('input[type=submit].' + htmlClass).removeAttr('disabled');
+      $j('.' + htmlClass + '.errors').show();
+      $j('.' + htmlClass + '.errors').html(xhr.responseText);
+    }
+  });
+
+  function displayLoadingImage() {
+    $j('#apply-template-loading-image').removeClass("hidden");
+  }
+
+</script>
index 7b32d9edfb0c96b36b7bfdf35f5947ca2c651f6b..4311b9721e78adf48cef4b815e58107f06b7e6c4 100644 (file)
@@ -16,8 +16,8 @@
 <div id="project-roles-operations" style="float: right;">
   <ul class="operations">
     <li class="last">
-      <a id="bulk-update" href="<%= url_for params.merge({:action => 'bulk_apply_form'}) -%>"
-         class="link-action open-modal"><%= message('projects_role.apply_template') -%></a>
+      <%= 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' %>
     </li>
   </ul>
 </div>