Skip to content
Permalink
Browse files
[JENKINS-31162] @gusreiber's comments were addresed
  • Loading branch information
recena committed Mar 13, 2016
1 parent e0946ee commit 25f9c99d8376667b2efaabe8cb6f5b4be6024618
Showing 4 changed files with 30 additions and 4 deletions.
@@ -350,6 +350,7 @@ public static Categories getCategories(Authentication a, ItemGroup c) {
metadata.put("class", descriptor.clazz.getName());
metadata.put("iconClassName", "item-icon-" + descriptor.clazz.getName().substring(descriptor.clazz.getName().lastIndexOf(".") + 1).toLowerCase());
metadata.put("weight", ItemCategoryConfigurator.getWeight(descriptor));
metadata.put("name", descriptor.getDisplayName());

Category category = categories.getItem(ic.getId());
if (category != null) {
@@ -358,7 +359,7 @@ public static Categories getCategories(Authentication a, ItemGroup c) {
List<Map<String, Object>> temp = new ArrayList<Map<String, Object>>();
temp.add(metadata);
category = new Category(ic.getId(), ic.getDisplayName(), ic.getDescription(), ic.getIconClassName(),
ic.getWeight(), temp);
ic.getWeight(), ic.getMinToShow(), temp);
categories.getItems().add(category);
}
}
@@ -24,14 +24,18 @@ public class Category implements Serializable {

private int weight;

private int minToShow;

private List<Map<String, Object>> items;

public Category(String id, String name, String description, String iconClassName, int weight, List<Map<String, Object>> items) {
public Category(String id, String name, String description, String iconClassName, int weight, int minToShow,
List<Map<String, Object>> items) {
this.id= id;
this.name = name;
this.description = description;
this.iconClassName = iconClassName;
this.weight = weight;
this.minToShow = minToShow;
this.items = items;
}

@@ -60,6 +64,11 @@ public int getWeight() {
return weight;
}

@Exported
public int getMinToShow() {
return minToShow;
}

@Exported
public List<Map<String, Object>> getItems() {
return items;
@@ -10,6 +10,10 @@
*/
public abstract class ItemCategory implements ModelObject, ExtensionPoint {

public static int MIN_WEIGHT = Integer.MIN_VALUE;

public static int MIN_TOSHOW = 1;

/**
* Identifier, e.g. "category-id-default", etc.
*
@@ -38,6 +42,13 @@ public abstract class ItemCategory implements ModelObject, ExtensionPoint {
*/
public abstract int getWeight();

/**
* Minimum number required to show the category.
*
* @return the minimum items required
*/
public abstract int getMinToShow();

/**
* The default category, if an item doesn't belong anywhere else, this is where it goes by default.
*/
@@ -69,6 +80,11 @@ public int getWeight() {
return Integer.MIN_VALUE;
}

@Override
public int getMinToShow() {
return 1;
}

}

}
@@ -40,7 +40,7 @@ public static ItemCategory getCategory(@Nonnull TopLevelItemDescriptor descripto
return category;
}
}
throw new IllegalStateException();
throw new IllegalStateException("At least, must exist the category: " + ItemCategory.Default.class);
}

/**
@@ -69,7 +69,7 @@ public static Integer getWeight(@Nonnull TopLevelItemDescriptor descriptor) {
return weight;
}
}
throw new IllegalStateException();
throw new IllegalStateException("At least, must exist the category: " + ItemCategory.Default.class);
}

public static Collection<ItemCategoryConfigurator> all() {

0 comments on commit 25f9c99

Please sign in to comment.