]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4495 Fallback to select first category for project settings too
authorJulien HENRY <julien.henry@sonarsource.com>
Mon, 15 Jul 2013 13:37:31 +0000 (15:37 +0200)
committerJulien HENRY <julien.henry@sonarsource.com>
Mon, 15 Jul 2013 13:37:31 +0000 (15:37 +0200)
sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb

index 9323122e01f5271d1faf10d41ab1df812fa6b187..e7fef2f9573bbb0c92b6e20ef72f3f871153e287 100644 (file)
@@ -253,9 +253,14 @@ class ProjectController < ApplicationController
 
     not_found('category') unless @categories.include? @category
 
-    @subcategory = params[:subcategory] || @category
     @subcategories_per_categories = {}
     definitions_per_category.each {|category, definitions_per_subcategories| @subcategories_per_categories.store(category, by_subcategory_name(category, definitions_per_subcategories.keys)) }
+
+    default_subcategory =
+      @subcategories_per_categories[@category].nil? ? nil :
+        ((@subcategories_per_categories[@category].include? @category) ? @category : @subcategories_per_categories[@category][0])
+    @subcategory = params[:subcategory] || default_subcategory
+
     @definitions = definitions_per_category[@category] || {}
     @definitions = @definitions[@subcategory] || []
   end