public class ComponentDto implements Component {
+ private Long id;
private String key;
private String name;
private String longName;
private String qualifier;
+ public Long getId() {
+ return id;
+ }
+
+ public ComponentDto setId(Long id) {
+ this.id = id;
+ return this;
+ }
+
@Override
public String key() {
return key;
if(usersPermissions != null) {
for (PermissionTemplateUserDto userPermission : usersPermissions) {
addUserPermission(resourceId, userPermission.getUserLogin(), userPermission.getPermission(), session);
-
}
}
List<PermissionTemplateGroupDto> groupsPermissions = permissionTemplate.getGroupsPermissions();
public static ComponentDto toComponent(ResourceDto resourceDto){
return new ComponentDto()
+ .setId(resourceDto.getId())
.setKey(resourceDto.getKey())
.setLongName(resourceDto.getLongName())
.setName(resourceDto.getName())
import org.sonar.api.component.Component;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Scopes;
+import org.sonar.core.component.ComponentDto;
import org.sonar.core.persistence.AbstractDaoTestCase;
import java.util.Collection;
List<Component> components = dao.selectComponentsByQualifiers(newArrayList("TRK"));
assertThat(components).hasSize(1);
assertThat(components.get(0).key()).isEqualTo("org.struts:struts");
+ assertThat(((ComponentDto)components.get(0)).getId()).isEqualTo(1L);
assertThat(dao.selectComponentsByQualifiers(newArrayList("unknown"))).isEmpty();
assertThat(dao.selectComponentsByQualifiers(Collections.<String>emptyList())).isEmpty();
private
def get_root_qualifiers
- Java::OrgSonarServerUi::JRubyFacade.getInstance().getResourceRootTypes().map {|type| type.getQualifier()}
+ Java::OrgSonarServerUi::JRubyFacade.getInstance().getResourceRootTypes().map {|type| type.getQualifier()}.sort
end
def get_default_templates_per_qualifier(root_qualifiers)
# Even if components are already sorted, we must sort them again as this SQL query will not keep order
:order => 'name'
)
+ @components_names = params[:names]
+ @components_keys = params[:keys]
+ @components_qualifiers = params[:qualifiers]
end
# GET /roles/edit_users[?resource=<resource>]
render :text => '', :status => 200
end
- # GET /roles/apply_template_form?projects=<projects>&qualifier=<qualifier>
+ # GET /roles/apply_template_form?criteria
def apply_template_form
@permission_templates = Internal.permission_templates.selectAllPermissionTemplates().sort_by {|t| t.name.downcase}.collect {|pt| [pt.name, pt.key]}
- render :partial => 'apply_template_form', :locals => {:components => params[:projects], :project_name => params[:project_name], :qualifier => params[:qualifier] || 'TRK'}
+
+ params['qualifiers'] ||= 'TRK'
+ @query_result = Internal.component_api.find(params).components().to_a
+ @projects_ids = @query_result.collect{|component| component.getId()}
+
+ render :partial => 'apply_template_form',
+ :locals => {:components => @projects_ids, :project_name => @query_result.size == 1 ? @query_result[0].name : nil, :qualifier => params[:qualifiers]}
end
# POST /roles/apply_template?criteria
<table class="data width100">
<thead>
<tr>
- <th>Permission</th>
- <th width="35%">Users</th>
- <th width="35%">Groups</th>
+ <th> </th>
+ <th><%= message('projects_role.admin') -%></th>
+ <th><%= message('projects_role.user') -%></th>
+ <th><%= message('projects_role.codeviewer') -%></th>
</tr>
</thead>
<tbody>
- <tr class="even" >
- <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_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_edit_groups_permission_form(message('select'), 'admin', @project.id, 'select-admin-edit-groups') %>)<br/>
- </td>
+ <tr class="even">
+ <td valign="top"><b>Users</b></td>
+
+ <% ['admin', 'user', 'codeviewer'].each do |permission| -%>
+ <td valign="top">
+ <span class="nowrap" id="<%= permission -%>-role-users"><%= users(permission, @project.id).map(&:name).join(', ') %></span>
+ (<%= link_to_edit_roles_permission_form(message('select'), permission, @project.id, "select-#{permission}-edit-users") %>)<br/>
+ </td>
+ <% end %>
</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_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_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_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_edit_groups_permission_form(message('select'), 'codeviewer', @project.id, 'select-codeviewer-edit-groups') %>)<br/>
- </td>
+ <td valign="top"><b>Groups</b></td>
+ <% ['admin', 'user', 'codeviewer'].each do |permission| -%>
+ <td valign="top">
+ <span class="nowrap" id="<%= permission -%>-role-groups"><%= groups(permission, @project.id).map{|g| group_name(g)}.join(', ') %></span>
+ (<%= link_to_edit_groups_permission_form(message('select'), permission, @project.id, "select-#{permission}-edit-groups") %>)<br/>
+ </td>
+ <% end %>
</tr>
</tbody>
</table>
\ No newline at end of file
<% end %>
<fieldset>
<div class="modal-head">
- <% if params[:project_name] %>
- <h2><%= message('projects_role.apply_template_to_xxx', :params => params[:project_name]) -%></h2>
+ <% if project_name %>
+ <h2><%= message('projects_role.apply_template_to_xxx', :params => project_name) -%></h2>
<% else %>
<h2><%= message('projects_role.apply_template') -%></h2>
<% end %>
<div class="modal-field">
<%= label_tag 'template_key', 'Permission Template' %>
<%= select_tag('template_key', options_for_select(@permission_templates, -1), :style => 'width: 250px;') %>
- <% unless params[:project_name] %>
+ <% unless project_name %>
<span style="float:right" class="note">(<%= "#{components.size} #{message('qualifier.' + qualifier)}s" %>)</span><br/>
<% end %>
</div>
<div id="project-roles-operations" style="float: right;">
<ul class="operations">
<li class="last">
- <%= link_to message('projects_role.bulk_change'), {:action => :apply_template_form, :projects => @projects.collect {|proj| proj.id}, :qualifier => @qualifier},
+ <%= link_to message('projects_role.bulk_change'), {:action => :apply_template_form, :names => @components_names,
+ :keys => @components_keys, :qualifiers => @components_qualifiers},
:id => 'apply-template-modal', :class => 'open-modal link-action' %>
</li>
</ul>
</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},
+ <%= link_to message('projects_role.apply_template'), {:action => :apply_template_form, :names => project.name},
:id => "apply-template-#{u project.kee}", :class => 'open-modal link-action' %>
</td>
</tr>