# BULK RESOURCE DELETION
#
#------------------------------------------------------------------------------
-bulk_deletion.resource.projects=Projects
-bulk_deletion.resource.views=Views
-bulk_deletion.resource.devs=Developers
bulk_deletion.no_resource_to_delete=No resource to delete
bulk_deletion.resource_name_filter_by_name=Filter resources by name
bulk_deletion.search=Search
# a mass deletion is happening or it has just finished with errors => display the message from the Resource Deletion Manager
@deletion_manager = deletion_manager
render :template => 'bulk_deletion/pending_deletions'
- else
- @selected_tab = params[:resource_type] || 'projects'
+ else
+ # the "Projects" tab is always displayed
+ @tabs = ['TRK']
+ Java::OrgSonarServerUi::JRubyFacade.getInstance().getQualifiersWithProperty('deletable').each do |qualifier|
+ if qualifier!='TRK' && Project.count(:all, :conditions => {:qualifier => qualifier}) > 0
+ @tabs << qualifier
+ end
+ end
- # search if there are VIEWS or DEVS to know if we should display the tabs or not
- @should_display_views_tab = Project.count(:all, :conditions => {:qualifier => 'VW'}) > 0
- @should_display_devs_tab = Project.count(:all, :conditions => {:qualifier => 'DEV'}) > 0
+ @selected_tab = params[:resource_type]
+ @selected_tab = 'TRK' unless @tabs.include?(@selected_tab)
- # Search for resources
- values = {}
+ # Search for resources
conditions = "qualifier=:qualifier"
- qualifier = 'TRK'
- if @selected_tab == 'views'
- qualifier = 'VW'
- elsif @selected_tab == 'devs'
- qualifier = 'DEV'
- end
- values[:qualifier] = qualifier
+ values = {:qualifier => @selected_tab}
if params[:name_filter]
conditions += " AND kee LIKE :kee"
values[:kee] = '%' + params[:name_filter].strip.downcase + '%'
resource_ids.each_with_index do |resource_id, index|
resource = Project.find(:first, :conditions => {:id => resource_id.to_i})
@message = Api::Utils.message('bulk_deletion.deletion_manager.currently_deleting_x_out_of_x', :params => [(index+1).to_s, resource_ids.size.to_s])
- if resource &&
- # next line add 'VW' and 'DEV' tests because those resource types don't have the 'deletable' property yet...
- (java_facade.getResourceTypeBooleanProperty(resource.qualifier, 'deletable') || resource.qualifier=='VW' || resource.qualifier=='DEV')
+ if resource && java_facade.getResourceTypeBooleanProperty(resource.qualifier, 'deletable')
begin
java_facade.deleteResourceTree(resource.id)
rescue Exception => e
<h1 class="marginbottom10"><%= message('bulk_deletion.page') -%></h1>
<ul class="tabs">
+<% @tabs.each do |tab| %>
<li>
- <a href="<%= url_for :action => 'index', :resource_type => 'projects' %>" <%= "class='selected'" if @selected_tab=='projects' -%>><%= message('bulk_deletion.resource.projects') -%></a>
+ <a href="<%= url_for :action => 'index', :resource_type => tab %>" <%= "class='selected'" if @selected_tab==tab -%>><%= message('qualifiers.' + tab) -%></a>
</li>
- <% if @should_display_views_tab %>
- <li>
- <a href="<%= url_for :action => 'index', :resource_type => 'views' -%>" <%= "class='selected'" if @selected_tab=='views' -%>><%= message('bulk_deletion.resource.views') -%></a>
- </li>
- <% end %>
- <% if @should_display_devs_tab %>
- <li>
- <a href="<%= url_for :action => 'index', :resource_type => 'devs' -%>" <%= "class='selected'" if @selected_tab=='devs' -%>><%= message('bulk_deletion.resource.devs') -%></a>
- </li>
- <% end %>
+<% end %>
</ul>
<div class="tabs-panel marginbottom10">