aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src
diff options
context:
space:
mode:
authorJean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com>2013-07-23 17:50:27 +0200
committerJean-Baptiste Vilain <jean-baptiste.vilain@sonarsource.com>2013-07-23 17:50:27 +0200
commitc2f09598513b1883198a9cda86495335f9dc4932 (patch)
treed46321dbec4eeee0b6e17e39e79034c667fe4727 /sonar-server/src
parent3eb59f11b07109392445d96ddd4e03ee2def12b9 (diff)
downloadsonarqube-c2f09598513b1883198a9cda86495335f9dc4932.tar.gz
sonarqube-c2f09598513b1883198a9cda86495335f9dc4932.zip
SONAR-4453 Notify user when the selection exceeds the max number of projects updatable in a row
Diffstat (limited to 'sonar-server/src')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/roles_controller.rb13
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/roles/_apply_template_form.html.erb15
2 files changed, 20 insertions, 8 deletions
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 4bc03f900c2..8c935f270ee 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
@@ -21,6 +21,7 @@ class RolesController < ApplicationController
helper RolesHelper
SECTION=Navigation::SECTION_CONFIGURATION
+ BULK_LIMIT=1
before_filter :admin_required
verify :method => :post, :only => [:set_users, :set_groups], :redirect_to => {:action => 'global'}
@@ -85,11 +86,17 @@ class RolesController < ApplicationController
params['qualifiers'] ||= 'TRK'
params['pageSize'] = 500
- @query_result = Internal.component_api.find(params).components().to_a
- @projects_ids = @query_result.collect{|component| component.getId()}
+ query_result = Internal.component_api.find(params)
+ components = query_result.components().to_a
+ total_results_count = query_result.paging.total.to_i
+
+ @projects_ids = components.collect{|component| component.getId()}
+ @qualifier = params[:qualifiers]
render :partial => 'apply_template_form',
- :locals => {:components => @projects_ids, :project_name => @query_result.size == 1 ? @query_result[0].name : nil, :qualifier => params[:qualifiers]}
+ :locals => {:project_name => components.size == 1 ? components[0].name : nil,
+ :empty => @projects_ids.nil? || @projects_ids.size == 0,
+ :overflow => total_results_count > BULK_LIMIT}
end
# POST /roles/apply_template?criteria
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
index 338e287b279..c8796ae10eb 100644
--- 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
@@ -1,6 +1,6 @@
<form id="apply-template-form" method="post" action="<%= ApplicationController.root_context -%>/roles/apply_template">
- <% unless components.nil? %>
- <input type="hidden" name="components" id="apply-template-components" value="<%= components.join(',') %>"/>
+ <% unless @projects_ids.nil? %>
+ <input type="hidden" name="components" id="apply-template-components" value="<%= @projects_ids.join(',') %>"/>
<% end %>
<fieldset>
<div class="modal-head">
@@ -12,23 +12,28 @@
</div>
<div class="modal-body">
<div class="modal-error"/>
- <% if components.nil? %>
+ <% if empty %>
<div class="info">
<img src="<%= ApplicationController.root_context -%>/images/information.png" style="vertical-align: text-bottom"/>
<%= message 'projects_role.no_projects' -%>
</div>
+ <% elsif overflow %>
+ <div class="info">
+ <img src="<%= ApplicationController.root_context -%>/images/information.png" style="vertical-align: text-bottom"/>
+ <%= message 'projects_role.exceeds_projects_limit_xxx', :params => RolesController::BULK_LIMIT -%>
+ </div>
<% else %>
<div class="modal-field">
<%= label_tag 'template_key', 'Permission Template' %>
<%= select_tag('template_key', options_for_select(@permission_templates, -1), :style => 'width: 250px;') %>
<% unless project_name %>
- <span style="float:right" class="note">(<%= "#{components.size} #{message('qualifier.' + qualifier)}s" %>)</span><br/>
+ <span style="float:right" class="note">(<%= "#{@projects_ids.size} #{message('qualifier.' + @qualifier)}s" %>)</span><br/>
<% end %>
</div>
<% end %>
</div>
<div class="modal-foot">
- <% unless components.nil? %>
+ <% unless empty || overflow %>
<span id="apply-template-loading-image" class="loading-image hidden"><%= image_tag 'loading.gif' %></span>
<input type="submit" value="<%= message('apply') -%>" id="apply-template-submit" class="apply-template" onclick="return displayLoadingImage()" />
<% end %>