]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5893 Add component tag cloud widget
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Wed, 7 Jan 2015 16:34:55 +0000 (17:34 +0100)
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Wed, 7 Jan 2015 17:18:06 +0000 (18:18 +0100)
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/IssueTagCloudWidget.java [new file with mode: 0644]
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issue_tag_cloud.html.erb [new file with mode: 0644]
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 9b996f161617cedc5c9ec2276e02e4bef683f44e..f15d9ba34e23779f8dfbb6b05f333ff6920171dc 100644 (file)
@@ -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 (file)
index 0000000..cba0aa3
--- /dev/null
@@ -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 (file)
index 0000000..871b6b6
--- /dev/null
@@ -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 %>
index 764a0571b117fb85f0094d3b0994c6165e57ada3..23eef2e3bd0bbbfbd10b4d40a27f72af99ef092d 100644 (file)
@@ -1296,6 +1296,11 @@ widget.issue_filter.property.numberOfLines.name=Page size
 widget.issue_filter.property.displayFilterDescription.name=Display Filter Description
 widget.issue_filter.unknown_filter_warning=This widget is configured to display an issue filter that doesn't exist anymore.
 
+widget.issue_tag_cloud.name=Issue Tag Cloud
+widget.issue_tag_cloud.description=Displays the cloud of tags associated to unresolved issues.
+widget.issue_tag_cloud.property.maxItems.name=Max Tags
+widget.issue_tag_cloud.property.maxItems.desc=Maximum number of tags to show
+
 widget.treemap-widget.name=Treemap of Components
 widget.treemap-widget.description=Displays a treemap of all direct components of the selected resource.
 widget.treemap-widget.property.sizeMetric.name=Size Metric