]> source.dussan.org Git - sonarqube.git/commitdiff
Fix administration section in webapp
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 3 Oct 2014 08:14:28 +0000 (10:14 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 3 Oct 2014 08:28:52 +0000 (10:28 +0200)
server/sonar-web/src/main/webapp/WEB-INF/app/controllers/application_controller.rb
sonar-plugin-api/src/main/java/org/sonar/api/config/Category.java
sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java
sonar-plugin-api/src/main/java/org/sonar/api/config/SubCategory.java
sonar-plugin-api/src/test/java/org/sonar/api/config/PropertyDefinitionsTest.java

index b01a0792d255036d3981551029b07e86d94b4abe..9ced766bb359417d66116756d02b3e1254fd1fc2 100644 (file)
@@ -324,10 +324,10 @@ class ApplicationController < ActionController::Base
 
     if params[:category].nil?
       # Select the 'general' category by default. If 'general' category is not found, then return the first one.
-      default_category = @categories.empty? ? nil : (@categories.find {|c| c == Java::OrgSonarApiConfigInternal::Category.new('general')} || @categories[0])
+      default_category = @categories.empty? ? nil : (@categories.find {|c| c && c.key == 'general'} || @categories[0])
       @category = default_category
     else
-      @category = @categories.find {|c| c == Java::OrgSonarApiConfigInternal::Category.new(params[:category])}
+      @category = @categories.find {|c| c && c.key == params[:category]}
       not_found('category') if @category.nil?
     end
 
@@ -341,7 +341,7 @@ class ApplicationController < ActionController::Base
                   ((@subcategories_per_categories[@category].include? @category) ? @category : @subcategories_per_categories[@category][0])
         @subcategory = default_subcategory
       else
-        @subcategory = @subcategories_per_categories[@category].find {|s| s == Java::OrgSonarApiConfigInternal::SubCategory.new(params[:subcategory])}
+        @subcategory = @subcategories_per_categories[@category].find {|s| s && s.key == params[:subcategory]}
         not_found('subcategory') if @subcategory.nil?
       end
 
index e4008f2eceaa86b3e35de48bcfcb1f2864838a13..114abe3fd27c630846a6e34bf5762170e3acd5f5 100644 (file)
@@ -26,7 +26,7 @@ import java.util.Locale;
 /**
  * @since 3.7
  */
-class Category {
+public class Category {
 
   private final String originalKey;
   private final boolean special;
@@ -40,15 +40,15 @@ class Category {
     this.special = special;
   }
 
-  String originalKey() {
+  public String originalKey() {
     return originalKey;
   }
 
-  String key() {
+  public String key() {
     return StringUtils.lowerCase(originalKey, Locale.ENGLISH);
   }
 
-  boolean isSpecial() {
+  public boolean isSpecial() {
     return special;
   }
 
index 5c20f786866163e09efb6afa56e3d9d0b7b733b1..6a63144abf2495a6b336eda64ffcd199633c9a46 100644 (file)
@@ -22,13 +22,20 @@ package org.sonar.api.config;
 import com.google.common.base.Strings;
 import com.google.common.collect.Maps;
 import org.apache.commons.lang.StringUtils;
-import org.sonar.api.*;
+import org.sonar.api.BatchComponent;
+import org.sonar.api.CoreProperties;
 import org.sonar.api.Properties;
+import org.sonar.api.Property;
+import org.sonar.api.ServerComponent;
 import org.sonar.api.utils.AnnotationUtils;
 
 import javax.annotation.Nullable;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Metadata of all the properties declared by plugins
index 05c96078eca2e28f131508e0984b9e1e33484073..4a1d884b3a742d3d91609dd05ddbd94d52891ec8 100644 (file)
@@ -22,7 +22,7 @@ package org.sonar.api.config;
 /**
  * @since 3.7
  */
-class SubCategory extends Category {
+public class SubCategory extends Category {
 
   SubCategory(String originalKey) {
     super(originalKey);
index 333b8e15c3eccf074daa6f90716c1d4f4bff820c..127e7ea2796c623165714b136721c2170e2e6d4b 100644 (file)
@@ -128,12 +128,6 @@ public class PropertyDefinitionsTest {
       PropertyDefinition.builder("view").name("View").category("catView").onlyOnQualifiers(Qualifiers.VIEW).build()
     );
 
-    assertThat(def.getPropertiesByCategory(null).keySet()).containsOnly("catGlobal1", "catGlobal2");
-    assertThat(def.getPropertiesByCategory(Qualifiers.PROJECT).keySet()).containsOnly("catProject");
-    assertThat(def.getPropertiesByCategory(Qualifiers.MODULE).keySet()).containsOnly("catModule");
-    assertThat(def.getPropertiesByCategory(Qualifiers.VIEW).keySet()).containsOnly("catView");
-    assertThat(def.getPropertiesByCategory("Unkown").keySet()).isEmpty();
-
     assertThat(def.propertiesByCategory(null).keySet()).contains(new Category("catGlobal1"), new Category("catGlobal2"));
     assertThat(def.propertiesByCategory(Qualifiers.PROJECT).keySet()).containsOnly(new Category("catProject"));
     assertThat(def.propertiesByCategory(Qualifiers.MODULE).keySet()).containsOnly(new Category("catModule"));
@@ -150,9 +144,6 @@ public class PropertyDefinitionsTest {
       PropertyDefinition.builder("global4").name("Global4").category("catGlobal2").build()
     );
 
-    assertThat(def.getPropertiesByCategory(null).get("catGlobal1").keySet()).containsOnly("catGlobal1", "sub1", "sub2");
-    assertThat(def.getPropertiesByCategory(null).get("catGlobal2").keySet()).containsOnly("catGlobal2");
-
     assertThat(def.propertiesByCategory(null).get(new Category("catGlobal1")).keySet()).containsOnly(new SubCategory("catGlobal1"), new SubCategory("sub1"),
       new SubCategory("sub2"));
     assertThat(def.propertiesByCategory(null).get(new Category("catGlobal2")).keySet()).containsOnly(new SubCategory("catGlobal2"));
@@ -162,10 +153,6 @@ public class PropertyDefinitionsTest {
   public void should_group_by_category_on_annotation_plugin() {
     PropertyDefinitions def = new PropertyDefinitions(ByCategory.class);
 
-    assertThat(def.getPropertiesByCategory().keySet()).containsOnly("catGlobal1", "catGlobal2");
-    assertThat(def.getPropertiesByCategory(Qualifiers.PROJECT).keySet()).containsOnly("catProject");
-    assertThat(def.getPropertiesByCategory(Qualifiers.MODULE).keySet()).containsOnly("catModule");
-
     assertThat(def.propertiesByCategory(null).keySet()).contains(new Category("catglobal1"), new Category("catglobal2"));
     assertThat(def.propertiesByCategory(Qualifiers.PROJECT).keySet()).containsOnly(new Category("catproject"));
     assertThat(def.propertiesByCategory(Qualifiers.MODULE).keySet()).containsOnly(new Category("catmodule"));