aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2015-01-07 17:34:55 +0100
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2015-01-07 18:18:06 +0100
commit8338c86d2fc5d50f2058d1fc00b536c821c263c8 (patch)
treea00e225b6cd96166a879e551ba2c1578ad8e06c8 /plugins
parentd0a17e3e9854fe01f46df9416b77eaad0b2623b7 (diff)
downloadsonarqube-8338c86d2fc5d50f2058d1fc00b536c821c263c8.tar.gz
sonarqube-8338c86d2fc5d50f2058d1fc00b536c821c263c8.zip
SONAR-5893 Add component tag cloud widget
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java2
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/IssueTagCloudWidget.java42
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issue_tag_cloud.html.erb44
3 files changed, 88 insertions, 0 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
index 9b996f16161..f15d9ba34e2 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
@@ -98,6 +98,7 @@ import org.sonar.plugins.core.widgets.WelcomeWidget;
import org.sonar.plugins.core.widgets.issues.ActionPlansWidget;
import org.sonar.plugins.core.widgets.issues.FalsePositiveIssuesWidget;
import org.sonar.plugins.core.widgets.issues.IssueFilterWidget;
+import org.sonar.plugins.core.widgets.issues.IssueTagCloudWidget;
import org.sonar.plugins.core.widgets.issues.IssuesWidget;
import org.sonar.plugins.core.widgets.issues.MyUnresolvedIssuesWidget;
import org.sonar.plugins.core.widgets.issues.UnresolvedIssuesPerAssigneeWidget;
@@ -343,6 +344,7 @@ public final class CorePlugin extends SonarPlugin {
UnresolvedIssuesPerAssigneeWidget.class,
UnresolvedIssuesStatusesWidget.class,
IssueFilterWidget.class,
+ IssueTagCloudWidget.class,
org.sonar.api.issue.NoSonarFilter.class,
// issue notifications
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/IssueTagCloudWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/IssueTagCloudWidget.java
new file mode 100644
index 00000000000..cba0aa3f835
--- /dev/null
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/IssueTagCloudWidget.java
@@ -0,0 +1,42 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2014 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.plugins.core.widgets.issues;
+
+import org.sonar.api.web.WidgetCategory;
+import org.sonar.api.web.WidgetProperties;
+import org.sonar.api.web.WidgetProperty;
+import org.sonar.api.web.WidgetPropertyType;
+import org.sonar.api.web.WidgetScope;
+import org.sonar.plugins.core.widgets.CoreWidget;
+
+import static org.sonar.api.web.WidgetScope.PROJECT;
+
+@WidgetCategory({"Issues"})
+@WidgetScope(PROJECT)
+@WidgetProperties({
+ @WidgetProperty(key = "maxItems", type = WidgetPropertyType.INTEGER, defaultValue = "100")
+})
+public class IssueTagCloudWidget extends CoreWidget {
+
+ public IssueTagCloudWidget() {
+ super("issue_tag_cloud", "Issue Tag Cloud", "/org/sonar/plugins/core/widgets/issues/issue_tag_cloud.html.erb");
+ }
+
+}
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issue_tag_cloud.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issue_tag_cloud.html.erb
new file mode 100644
index 00000000000..871b6b69db4
--- /dev/null
+++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issue_tag_cloud.html.erb
@@ -0,0 +1,44 @@
+<%
+ containerId = 'issue-tag-cloud' + widget.id.to_s
+ maxItems = widget_properties['maxItems'].to_i
+
+ if current_user && has_role?(:user, @project)
+ search_options = {}
+ if @project
+ search_options['componentUuids'] = @project.uuid
+ end
+ search_options['resolved'] = 'false'
+
+ title = message('widget.issue_tag_cloud.name')
+%>
+
+<div class="histogram-widget" id="<%= containerId %>">
+ <!--[if lte IE 8 ]> <h3><%= message('widget.unsupported_browser_warning') -%></h3> <![endif]-->
+</div>
+
+<!--[if (gte IE 9)|!(IE)]><!-->
+<script>
+ (function () {
+ var query = [
+ 'componentUuid=<%= @project.uuid() -%>',
+ 'ps=<%= maxItems -%>'
+ ].join('&'),
+ widget = new SonarWidgets.Widget();
+
+ widget
+ .type('TagCloud')
+ .source(baseUrl + '/api/issues/component_tags?' + query)
+ .options({
+ maxItemsReachedMessage: '<%= message("widget.measure_filter_histogram.max_items_reached", :params => [maxItems]) -%>',
+ baseUrl: baseUrl + '/issues/search/#componentUuids=<%= @project.uuid() -%>',
+ noData: '<%= message('no_data') -%>'
+ })
+ .render('#<%= containerId -%>');
+
+ autoResize(500, function() {
+ widget.update('#<%= containerId -%>');
+ });
+ })();
+</script>
+<!--<![endif]-->
+<% end %>