aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-03-27 15:01:13 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2012-03-27 15:02:57 +0200
commit874a3fa1f98419e84a75737b4815e0d6c1898239 (patch)
treedd1728a2ff4efcb80b6eadc369435a6ea6cc0941 /sonar-server/src
parent7e454cf3255351b1a80cff7a00168a0bc6abf547 (diff)
downloadsonarqube-874a3fa1f98419e84a75737b4815e0d6c1898239.tar.gz
sonarqube-874a3fa1f98419e84a75737b4815e0d6c1898239.zip
SONAR-3106 Error trying to configure group privileges for a project
Diffstat (limited to 'sonar-server/src')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/roles_controller.rb3
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/roles_helper.rb15
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/roles/edit_groups.html.erb10
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/roles/edit_users.html.erb12
4 files changed, 21 insertions, 19 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 aeda3799152..fdb1a8d902e 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
@@ -31,7 +31,8 @@ class RolesController < ApplicationController
def projects
@projects=Project.find(:all,
:conditions => {:enabled=>true, :scope => Project::SCOPE_SET, :qualifier => [Project::QUALIFIER_VIEW, Project::QUALIFIER_SUBVIEW, Project::QUALIFIER_PROJECT]},
- :include => ['user_roles', 'group_roles']).sort{|a,b| a.name.downcase<=>b.name.downcase}
+ :include => ['user_roles', 'group_roles'])
+ Api::Utils.insensitive_sort!(@projects){|project| project.name}
end
def edit_users
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/roles_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/roles_helper.rb
index 55936a07bfe..77501833196 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/roles_helper.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/roles_helper.rb
@@ -21,24 +21,25 @@ module RolesHelper
def users(role, resource_id=nil)
resource_id=(resource_id.blank? ? nil : resource_id.to_i)
- user_roles=UserRole.find(:all, :conditions => {:role => role, :resource_id => resource_id})
- user_roles.map {|ur| ur.user}.sort
+ user_roles=UserRole.find(:all, :include => 'user', :conditions => {:role => role, :resource_id => resource_id})
+ users = user_roles.map { |ur| ur.user }
+ Api::Utils.insensitive_sort(users) {|user| user.name}
end
def all_users
- User.find(:all, :conditions => ["active=?", true], :order => 'name')
+ users = User.find(:all, :conditions => ["active=?", true])
+ Api::Utils.insensitive_sort(users) {|user| user.name}
end
def groups(role, resource_id=nil)
resource_id=(resource_id.blank? ? nil : resource_id.to_i)
group_roles=GroupRole.find(:all, :conditions => {:role => role, :resource_id => resource_id})
- group_roles.map{|ur| ur.group}.sort do |x,y|
- x ? x<=>y : -1
- end
+ groups = group_roles.map{|ur| ur.group}
+ Api::Utils.insensitive_sort(groups) {|group| group ? group.name : ''}
end
def all_groups
- [nil].concat(Group.find(:all, :order => 'name'))
+ [nil].concat(Api::Utils.insensitive_sort(Group.all) {|group| group.name})
end
def group_name(group)
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/roles/edit_groups.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/roles/edit_groups.html.erb
index 33a568e23b2..fec44e938a9 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/roles/edit_groups.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/roles/edit_groups.html.erb
@@ -20,15 +20,15 @@
<table>
<tbody>
<tr>
- <td style="padding: 5px 0pt;" valign="top">
+ <td style="padding: 5px 0;" valign="top">
<h2>Ungranted groups</h2>
- <select name="from" id="from" size="20" style="margin: 5px 0pt; width: 300px;" multiple="multiple">
- <% ungranted_groups.sort.each do |group| %>
+ <select name="from" id="from" size="20" style="margin: 5px 0; width: 300px;" multiple="multiple">
+ <% ungranted_groups.each do |group| %>
<option value="<%= group ? group.id : '' -%>"><%= group_name(group) -%></option>
<% end %>
</select>
</td>
- <td style="padding: 0pt 10px;" align="center">
+ <td style="padding: 0 10px;" align="center">
<button id="select_right" onclick="SelectBox.move('from', 'to');SelectBox.sort('to');SelectBox.redisplay('to');return false;">select >></button><br>
<button id="select_right_all" onclick="SelectBox.move_all('from', 'to');return false;">select all >></button><br><br>
<button id="select_left" onclick="SelectBox.move('to', 'from');return false;"><< unselect</button><br>
@@ -38,7 +38,7 @@
<h2>Role: <%= role_name(@role) -%></h2>
<select name="groups[]" id="to" size="20" multiple="multiple" style="margin: 5px 0pt; width: 300px;">
- <% granted_groups.sort.each do |group| %>
+ <% granted_groups.each do |group| %>
<option value="<%= group ? group.id : '' -%>"><%= group_name(group) -%></option>
<% end %>
</select><br>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/roles/edit_users.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/roles/edit_users.html.erb
index b0be2583ba5..7c724973203 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/roles/edit_users.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/roles/edit_users.html.erb
@@ -20,15 +20,15 @@
<table>
<tbody>
<tr>
- <td style="padding: 5px 0pt;" valign="top">
+ <td style="padding: 5px 0;" valign="top">
<h2>Ungranted users</h2>
- <select name="from" id="from" size="30" style="margin: 5px 0pt; width: 300px;" multiple="multiple">
- <% ungranted_users.sort.each do |user| %>
+ <select name="from" id="from" size="30" style="margin: 5px 0; width: 300px;" multiple="multiple">
+ <% ungranted_users.each do |user| %>
<option value="<%= user.id -%>"><%= user.name -%></option>
<% end %>
</select>
</td>
- <td style="padding: 0pt 10px;" align="center">
+ <td style="padding: 0 10px;" align="center">
<button id="select_right" onclick="SelectBox.move('from', 'to');SelectBox.sort('to');SelectBox.redisplay('to');return false;">select >></button><br>
<button id="select_right_all" onclick="SelectBox.move_all('from', 'to');return false;">select all >></button><br><br>
<button id="select_left" onclick="SelectBox.move('to', 'from');return false;"><< unselect</button><br>
@@ -37,11 +37,11 @@
<td class="box" style="padding: 5px 10px;" valign="top">
<h2>Role: <%= role_name(@role) -%></h2>
- <select name="users[]" id="to" size="30" multiple="multiple" style="margin: 5px 0pt; width: 300px;">
+ <select name="users[]" id="to" size="30" multiple="multiple" style="margin: 5px 0; width: 300px;">
<%= options_from_collection_for_select(granted_users, "id", "name") %>
</select><br>
- <div style="padding: 5px 0pt;">
+ <div style="padding: 5px 0;">
<input id="save" value="Save" onclick="SelectBox.select_all('to');submit();return false;" type="submit">
</div>
</td>