Support 'foreach' in a project dashboard config

Change-Id: I8ede9ec3d4c0efa16a88bad55cc59b2b039f0cdc
This commit is contained in:
Martin Fick
2012-11-19 21:58:20 -07:00
parent 4accc9e658
commit cb8fe2f51b
3 changed files with 20 additions and 0 deletions

View File

@@ -97,6 +97,20 @@ dashboard.description::
+ +
The description of the dashboard. The description of the dashboard.
dashboard.foreach::
+
The value of the foreach parameter gets appended to every query in the
dashboard.
+
Example dashboard config section to constrain the entire dashboard to
the project to which it is applied:
+
----
[dashboard]
foreach = project:${project}
----
Section section Section section
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~

View File

@@ -22,6 +22,7 @@ public class DashboardInfo extends JavaScriptObject {
public final native String ref() /*-{ return this.ref; }-*/; public final native String ref() /*-{ return this.ref; }-*/;
public final native String path() /*-{ return this.path; }-*/; public final native String path() /*-{ return this.path; }-*/;
public final native String description() /*-{ return this.description; }-*/; public final native String description() /*-{ return this.description; }-*/;
public final native String foreach() /*-{ return this.foreach; }-*/;
public final native String url() /*-{ return this.url; }-*/; public final native String url() /*-{ return this.url; }-*/;
public final native boolean isDefault() /*-{ return this['default'] ? true : false; }-*/; public final native boolean isDefault() /*-{ return this['default'] ? true : false; }-*/;

View File

@@ -144,9 +144,13 @@ class DashboardsCollection implements
info.title = config.getString("dashboard", null, "title"); info.title = config.getString("dashboard", null, "title");
info.description = config.getString("dashboard", null, "description"); info.description = config.getString("dashboard", null, "description");
info.isDefault = setDefault ? (info.id.equals(defaultOf(project)) ? true : null) : null; info.isDefault = setDefault ? (info.id.equals(defaultOf(project)) ? true : null) : null;
info.foreach = config.getString("dashboard", null, "foreach");
UrlEncoded u = new UrlEncoded("/dashboard/"); UrlEncoded u = new UrlEncoded("/dashboard/");
u.put("title", Objects.firstNonNull(info.title, info.path)); u.put("title", Objects.firstNonNull(info.title, info.path));
if (info.foreach != null) {
u.put("foreach", replace(project.getName(), info.foreach));
}
for (String name : config.getSubsections("section")) { for (String name : config.getSubsections("section")) {
Section s = new Section(); Section s = new Section();
s.name = name; s.name = name;
@@ -181,6 +185,7 @@ class DashboardsCollection implements
String ref; String ref;
String path; String path;
String description; String description;
String foreach;
String url; String url;
@SerializedName("default") @SerializedName("default")