diff options
author | Julien Lancelot <julien.lancelot@gmail.com> | 2013-07-18 16:59:10 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@gmail.com> | 2013-07-18 17:03:19 +0200 |
commit | fffe0ffa7c391fdd0ddefade1a01c9dab95fcbec (patch) | |
tree | b00ca4cff1ec17d24f4a2e7151c193d6393a2b5c | |
parent | 9f013dffb0bac6016739cd87b6ff16f232cb29e3 (diff) | |
download | sonarqube-fffe0ffa7c391fdd0ddefade1a01c9dab95fcbec.tar.gz sonarqube-fffe0ffa7c391fdd0ddefade1a01c9dab95fcbec.zip |
Add a common way to generate edit permission link
9 files changed, 49 insertions, 93 deletions
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 869e4d616f8..a774e513a01 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 @@ -86,4 +86,14 @@ module RolesHelper message("global_permissions.#{role}", :default => role) end + def link_to_edit_roles_permission_form(label, role, resource_id, html_id) + link_to message(label), {:controller => :roles, :action => :edit_users, :role => role, :resource => resource_id}, + :id => html_id, :class => 'open-modal link-action', 'modal-width' => '780px' + end + + def link_to_edit_groups_permission_form(label, role, resource_id, html_id) + link_to message(label), {:controller => :roles, :action => :edit_groups, :role => role, :resource => resource_id}, + :id => html_id, :class => 'open-modal link-action', 'modal-width' => '780px' + end + end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/_edit_groups.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/_edit_groups.html.erb index fce1c839136..eb9e147f375 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/_edit_groups.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/_edit_groups.html.erb @@ -20,7 +20,7 @@ <% end %> </select> </td> - <td style="padding: 0 10px;" align="center"> + <td style="padding: 0 10px;" align="center" nowrap="nowrap"> <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> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/_edit_users.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/_edit_users.html.erb index 9125985ed90..e4cd1477aec 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/_edit_users.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/_edit_users.html.erb @@ -20,7 +20,7 @@ <% end %> </select> </td> - <td style="padding: 0 10px;" align="center"> + <td style="padding: 0 10px;" align="center" nowrap="nowrap"> <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> 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 ebf45b3f708..4a3c0d0499c 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 @@ -35,42 +35,20 @@ <td valign="top"><b><%= h permission_template.name %></b><br/> <span class="small gray"><%= h permission_template.description -%></span> </td> - <td valign="top"> - <% - users=Api::Utils.insensitive_sort(permission_template.getUsersForPermission('admin').collect {|u| u.userName}) - groups=Api::Utils.insensitive_sort(permission_template.getGroupsForPermission('admin').collect {|g| g.groupName.blank? ? 'Anyone' : g.groupName}) - %> - <span id="u-admin-<%= u permission_template.name -%>"><%= users.join(', ') %></span> - (<%= link_to message('select users'), {:action => :edit_users, :name => permission_template.name, :permission => 'admin'}, - :id => "selectu-admin-#{u permission_template.name}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/> - <span id="g-admin-<%= u permission_template.name -%>"><%= groups.join(', ') %></span> - (<%= link_to message('select groups'), {:action => :edit_groups, :name => permission_template.name, :permission => 'admin'}, - :id => "selectg-admin-#{u permission_template.name}", :class => 'open-modal link-action', 'modal-width' => '760px' %>) - </td> - <td valign="top"> - <% - users=Api::Utils.insensitive_sort(permission_template.getUsersForPermission('user').collect {|u| u.userName}) - groups=Api::Utils.insensitive_sort(permission_template.getGroupsForPermission('user').collect {|g| g.groupName.blank? ? 'Anyone' : g.groupName}) - %> - <span id="u-user-<%= u permission_template.name -%>"><%= users.join(', ') %></span> - (<%= link_to message('select users'), {:action => :edit_users, :name => permission_template.name, :permission => 'user'}, - :id => "selectu-user-#{u permission_template.name}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/> - <span id="g-user-<%= u permission_template.name -%>"><%= groups.join(', ') %></span> - (<%= link_to message('select groups'), {:action => :edit_groups, :name => permission_template.name, :permission => 'user'}, - :id => "selectg-user-#{u permission_template.name}", :class => 'open-modal link-action', 'modal-width' => '760px' %>) - </td> - <td valign="top"> - <% - users=Api::Utils.insensitive_sort(permission_template.getUsersForPermission('codeviewer').collect {|u| u.userName}) - groups=Api::Utils.insensitive_sort(permission_template.getGroupsForPermission('codeviewer').collect {|g| g.groupName.blank? ? 'Anyone' : g.groupName}) - %> - <span id="u-codeviewer-<%= u permission_template.name -%>"><%= users.join(', ') %></span> - (<%= link_to message('select users'), {:action => :edit_users, :name => permission_template.name, :permission => 'codeviewer'}, - :id => "selectu-codeviewer-#{u permission_template.name}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/> - <span id="g-codeviewer-<%= u permission_template.name -%>"><%= groups.join(', ') %></span> - (<%= link_to message('select groups'), {:action => :edit_groups, :name => permission_template.name, :permission => 'codeviewer'}, - :id => "selectg-codeviewer-#{u permission_template.name}", :class => 'open-modal link-action', 'modal-width' => '760px' %>) - </td> + <% ['admin', 'user', 'codeviewer'].each do |permission| -%> + <td valign="top"> + <% + users=Api::Utils.insensitive_sort(permission_template.getUsersForPermission(permission).collect {|u| u.userName}) + groups=Api::Utils.insensitive_sort(permission_template.getGroupsForPermission(permission).collect {|g| g.groupName.blank? ? 'Anyone' : g.groupName}) + %> + <span id="u-<%= permission -%>-<%= u permission_template.name -%>"><%= users.join(', ') %></span> + (<%= link_to message('select users'), {:action => :edit_users, :name => permission_template.name, :permission => permission}, + :id => "selectu-#{permission}-#{u permission_template.name}", :class => 'open-modal link-action', 'modal-width' => '780px' %>)<br/> + <span id="g-<%= permission -%>-<%= u permission_template.name -%>"><%= groups.join(', ') %></span> + (<%= link_to message('select groups'), {:action => :edit_groups, :name => permission_template.name, :permission => permission}, + :id => "selectg-#{permission}-#{u permission_template.name}", :class => 'open-modal link-action', 'modal-width' => '780px' %>)<br/> + </td> + <% end %> <td> <% qualifiers = [] @default_templates.each_pair do |q, t| diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project_roles/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project_roles/index.html.erb index f4f9ade6a51..874e7cdbac5 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project_roles/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project_roles/index.html.erb @@ -12,40 +12,34 @@ <td valign="top"><b>Administrators</b><br/><span class="small gray">Ability to perform administration functions for a project by accessing its settings.</span></td> <td valign="top" style="word-break:break-all;width:35%;"> <span id="admin-role-users"><%= users('admin', @project.id).map(&:name).join(', ') %></span> - (<%= link_to message('select'), {:controller => :roles, :action => :edit_users, :role => 'admin', :resource => @project.id}, - :id => 'select-admin-edit-users', :class => 'open-modal link-action', 'modal-width' => '760px' %>) + (<%= link_to_edit_roles_permission_form(message('select'), 'admin', @project.id, 'select-admin-edit-users') %>)<br/> </td> <td valign="top" style="word-break:break-all;width:35%;"> <span id="admin-role-groups"><%= groups('admin', @project.id).map{|g| group_name(g)}.join(', ') %></span> - (<%= link_to message('select'), {:controller => :roles, :action => :edit_groups, :role => 'admin', :resource => @project.id}, - :id => 'select-admin-edit-groups', :class => 'open-modal link-action', 'modal-width' => '760px' %>) + (<%= link_to_edit_groups_permission_form(message('select'), 'admin', @project.id, 'select-admin-edit-groups') %>)<br/> </td> </tr> <tr class="odd"> <td valign="top"><b>Users</b><br/><span class="small gray">Ability to navigate through every service of a project, except viewing source code and settings.</span></td> <td valign="top" style="word-break:break-all;width:35%;"> <span id="user-role-users"><%= users('user', @project.id).map(&:name).join(', ') %></span> - (<%= link_to message('select'), {:controller => :roles, :action => :edit_users, :role => 'user', :resource => @project.id}, - :id => 'select-user-edit-users', :class => 'open-modal link-action', 'modal-width' => '760px' %>) + (<%= link_to_edit_roles_permission_form(message('select'), 'user', @project.id, 'select-user-edit-users') %>)<br/> </td> <td valign="top" style="word-break:break-all;width:35%;"> <span id="user-role-groups"><%= groups('user', @project.id).map{|g| group_name(g)}.join(', ') %></span> - (<%= link_to message('select'), {:controller => :roles, :action => :edit_groups, :role => 'user', :resource => @project.id}, - :id => 'select-user-edit-groups', :class => 'open-modal link-action', 'modal-width' => '760px' %>) + (<%= link_to_edit_groups_permission_form(message('select'), 'user', @project.id, 'select-user-edit-groups') %>)<br/> </td> </tr> <tr class="even" > <td valign="top"><b>Code viewers</b><br/><span class="small gray">Ability to view source code of a project.</span></td> <td valign="top" style="word-break:break-all;width:35%;"> <span id="codeviewer-role-users"><%= users('codeviewer', @project.id).map(&:name).join(', ') %></span> - (<%= link_to message('select'), {:controller => :roles, :action => :edit_users, :role => 'codeviewer', :resource => @project.id}, - :id => 'select-codeviewer-edit-users', :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/> + (<%= link_to_edit_roles_permission_form(message('select'), 'codeviewer', @project.id, 'select-codeviewer-edit-users') %>)<br/> </td> <td valign="top" style="word-break:break-all;width:35%;"> <span id="codeviewer-role-groups"><%= groups('codeviewer', @project.id).map{|g| group_name(g)}.join(', ') %></span> - (<%= link_to message('select'), {:controller => :roles, :action => :edit_groups, :role => 'codeviewer', :resource => @project.id}, - :id => 'select-codeviewer-edit-groups', :class => 'open-modal link-action', 'modal-width' => '760px' %>) - + (<%= link_to_edit_groups_permission_form(message('select'), 'codeviewer', @project.id, 'select-codeviewer-edit-groups') %>)<br/> + </td> </tr> </tbody> </table>
\ No newline at end of file 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 603ec1b5613..64dc2d6d354 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 @@ -24,7 +24,7 @@ <% end %> </select> </td> - <td style="padding: 0 10px;" align="center"> + <td style="padding: 0 10px;" align="center" nowrap="nowrap"> <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> 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 bb44aadefc1..4e1f7a95060 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 @@ -23,7 +23,7 @@ <% end %> </select> </td> - <td style="padding: 0 10px;" align="center"> + <td style="padding: 0 10px;" align="center" nowrap="nowrap"> <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> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/roles/global.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/roles/global.html.erb index de6f010ae2f..b9d130f0530 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/roles/global.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/roles/global.html.erb @@ -16,13 +16,11 @@ <span class="small gray"><%= message('global_permissions.' + global_permission_key + '.desc') -%></span></td> <td valign="top" style="word-break:break-all;width:30%;"> <span><%= users(global_permission_key).map(&:name).join(', ') -%></span> - (<%= link_to message('select'), {:action => :edit_users, :role => global_permission_key}, - :id => "select-users-#{global_permission_key}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/> + (<%= link_to_edit_roles_permission_form(message('select'), global_permission_key, nil, "select-users-#{global_permission_key}") %>)<br/> </td> <td valign="top" style="word-break:break-all;width:30%;"> <span><%= groups(global_permission_key).map{|g| group_name(g)}.join(', ') %></span> - (<%= link_to message('select'), {:action => :edit_groups, :role => global_permission_key}, - :id => "select-groups-#{global_permission_key}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/> + (<%= link_to_edit_groups_permission_form(message('select'), global_permission_key, nil, "select-groups-#{global_permission_key}") %>)<br/> </td> </tr> <% end %> 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 ecc74d213df..c7d5f586037 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 @@ -66,42 +66,18 @@ <td valign="top"><b><%= h project.name %></b><br/> <span class="small gray"><%= h project.key -%></span> </td> - <td valign="top"> - <% - users=Api::Utils.insensitive_sort(project.user_roles.select { |ur| ur.role=='admin' }.map { |ur| ur.user.name }) - groups=Api::Utils.insensitive_sort(project.group_roles.select { |gr| gr.role=='admin' }.map { |gr| group_name(gr.group) }) - %> - <span id="u-admin-<%= u project.kee -%>"><%= users.join(', ') %></span> - (<%= link_to message('select users'), {:action => :edit_users, :role => 'admin', :resource => project.id}, - :id => "selectu-admin-#{u project.kee}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/> - <span id="g-admin-<%= u project.kee -%>"><%= groups.join(', ') %></span> - (<%= link_to message('select groups'), {:action => :edit_groups, :role => 'admin', :resource => project.id}, - :id => "selectg-admin-#{u project.kee}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/> - </td> - <td valign="top"> - <% - users=Api::Utils.insensitive_sort(project.user_roles.select { |ur| ur.role=='user' }.map { |ur| ur.user.name }) - groups=Api::Utils.insensitive_sort(project.group_roles.select { |gr| gr.role=='user' }.map { |gr| group_name(gr.group) }) - %> - <span id="u-user-<%= u project.kee -%>"><%= users.join(', ') %></span> - (<%= link_to message('select users'), {:action => :edit_users, :role => 'user', :resource => project.id}, - :id => "selectu-user-#{u project.kee}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/> - <span id="g-user-<%= u project.kee -%>"><%= groups.join(', ') %></span> - (<%= link_to message('select groups'), {:action => :edit_groups, :role => 'user', :resource => project.id}, - :id => "selectg-user-#{u project.kee}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/> - </td> - <td valign="top"> - <% - users=Api::Utils.insensitive_sort(project.user_roles.select { |ur| ur.role=='codeviewer' }.map { |ur| ur.user.name }) - groups=Api::Utils.insensitive_sort(project.group_roles.select { |gr| gr.role=='codeviewer' }.map { |gr| group_name(gr.group) }) - %> - <span id="u-codeviewer-<%= u project.kee -%>"><%= users.join(', ') %></span> - (<%= link_to message('select users'), {:action => :edit_users, :role => 'codeviewer', :resource => project.id}, - :id => "selectu-codeviewer-#{u project.kee}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/> - <span id="g-codeviewer-<%= u project.kee -%>"><%= groups.join(', ') %></span> - (<%= link_to message('select groups'), {:action => :edit_groups, :role => 'codeviewer', :resource => project.id}, - :id => "selectg-codeviewer-#{u project.kee}", :class => 'open-modal link-action', 'modal-width' => '760px' %>)<br/> - </td> + <% ['admin', 'user', 'codeviewer'].each do |permission| -%> + <td valign="top"> + <% + users=Api::Utils.insensitive_sort(project.user_roles.select { |ur| ur.role==permission }.map { |ur| ur.user.name }) + groups=Api::Utils.insensitive_sort(project.group_roles.select { |gr| gr.role==permission }.map { |gr| group_name(gr.group) }) + %> + <span id="u-<%= permission -%>-<%= u project.kee -%>"><%= users.join(', ') %></span> + (<%= link_to_edit_roles_permission_form(message('select users'), permission, project.id, "selectu-#{permission}-#{u project.kee}") %>)<br/> + <span id="g-<%= permission -%>-<%= u project.kee -%>"><%= groups.join(', ') %></span> + (<%= link_to_edit_groups_permission_form(message('select groups'), permission, project.id, "selectg-#{permission}-#{u project.kee}") %>)<br/> + </td> + <% end %> <td align="right"> <%= link_to message('projects_role.apply_template'), {:action => :apply_template_form, :projects => [project.id], :project_name => project.name, :qualifier => @qualifier}, :id => "apply-template-modal-#{project.id}", :class => 'open-modal link-action' %> |