From 99be026f67711291551d178d13040f7417825c67 Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Thu, 12 Jul 2012 16:28:37 +0200 Subject: [PATCH] SONAR-2614 Use the resource types --- .../resources/org/sonar/l10n/core.properties | 3 --- .../controllers/bulk_deletion_controller.rb | 26 +++++++++---------- .../app/models/resource_deletion_manager.rb | 4 +-- .../app/views/bulk_deletion/index.html.erb | 14 +++------- 4 files changed, 16 insertions(+), 31 deletions(-) diff --git a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties index 12ce94eb15d..42fbb1b8df8 100644 --- a/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -1268,9 +1268,6 @@ my_profile.password.wrong_old=Wrong old password # 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 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/bulk_deletion_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/bulk_deletion_controller.rb index 010a4d31403..ad3869792e7 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/bulk_deletion_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/bulk_deletion_controller.rb @@ -32,23 +32,21 @@ class BulkDeletionController < ApplicationController # 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 + '%' diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/resource_deletion_manager.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/resource_deletion_manager.rb index 6ae5e129034..98c086de2f1 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/resource_deletion_manager.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/resource_deletion_manager.rb @@ -98,9 +98,7 @@ class ResourceDeletionManager 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 diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/bulk_deletion/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/bulk_deletion/index.html.erb index 164815d19f2..432284408f9 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/bulk_deletion/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/bulk_deletion/index.html.erb @@ -1,19 +1,11 @@

<%= message('bulk_deletion.page') -%>

-- 2.39.5