]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2614 Use the resource types
authorFabrice Bellingard <bellingard@gmail.com>
Thu, 12 Jul 2012 14:28:37 +0000 (16:28 +0200)
committerFabrice Bellingard <bellingard@gmail.com>
Thu, 12 Jul 2012 14:29:26 +0000 (16:29 +0200)
plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/webapp/WEB-INF/app/controllers/bulk_deletion_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/resource_deletion_manager.rb
sonar-server/src/main/webapp/WEB-INF/app/views/bulk_deletion/index.html.erb

index 12ce94eb15d1d39fb92f3361484aec226229e615..42fbb1b8df8b11d63e36b060428b3ce4f2c00115 100644 (file)
@@ -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
index 010a4d31403d991e161313a58f17ad7df5c2952f..ad3869792e7889bcd76eae9b36bdf7f15da5e1fb 100644 (file)
@@ -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 + '%'
index 6ae5e1290346594a0bc566c888467daeeccac73d..98c086de2f1c8e4577f603887871f6d9322f7416 100644 (file)
@@ -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
index 164815d19f2aa4d5af926cfbcef645636675acb7..432284408f9b0a678f45c11419f62e087daa7d09 100644 (file)
@@ -1,19 +1,11 @@
 <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">