diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-03-04 11:51:29 +0100 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-03-04 13:09:22 +0100 |
commit | 6c41cba0d29e744f90347ae98975f8e4e55c8bd7 (patch) | |
tree | 23c56afa5125b5fc4fac77ba094684e222038bc4 /plugins | |
parent | 29bc3c690a0d29d157042477ead84b5abeda3a1d (diff) | |
download | sonarqube-6c41cba0d29e744f90347ae98975f8e4e55c8bd7.tar.gz sonarqube-6c41cba0d29e744f90347ae98975f8e4e55c8bd7.zip |
SONAR-6234 add project issue filter widget
Diffstat (limited to 'plugins')
3 files changed, 96 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 5a4962b256f..e3f95633802 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 @@ -263,6 +263,7 @@ public final class CorePlugin extends SonarPlugin { UnresolvedIssuesPerAssigneeWidget.class, UnresolvedIssuesStatusesWidget.class, IssueFilterWidget.class, + ProjectIssueFilterWidget.class, IssueTagCloudWidget.class, // batch diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/ProjectIssueFilterWidget.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/ProjectIssueFilterWidget.java new file mode 100644 index 00000000000..3bfdc9b82f8 --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/issues/ProjectIssueFilterWidget.java @@ -0,0 +1,46 @@ +/* + * 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.*; +import org.sonar.plugins.core.widgets.CoreWidget; + +import static org.sonar.api.web.WidgetScope.PROJECT; + +@WidgetCategory({"Filters", "Issues"}) +@WidgetScope(PROJECT) +@WidgetProperties({ + @WidgetProperty(key = ProjectIssueFilterWidget.FILTER_PROPERTY, type = WidgetPropertyType.ISSUE_FILTER, optional = false), + @WidgetProperty(key = ProjectIssueFilterWidget.DISTRIBUTION_AXIS_PROPERTY, type = WidgetPropertyType.SINGLE_SELECT_LIST, defaultValue = "severities", + options = {"severities", "resolutions", "statuses", "rules", "tags", "assignees", "reporters", "authors", + "languages", "actionPlans", "createdAt"}), + @WidgetProperty(key = ProjectIssueFilterWidget.DISPLAY_FILTER_DESCRIPTION, type = WidgetPropertyType.BOOLEAN, defaultValue = "false") +}) +public class ProjectIssueFilterWidget extends CoreWidget { + + public static final String FILTER_PROPERTY = "filter"; + public static final String DISTRIBUTION_AXIS_PROPERTY = "distributionAxis"; + public static final String DISPLAY_FILTER_DESCRIPTION = "displayFilterDescription"; + public static final String ID = "project_issue_filter"; + + public ProjectIssueFilterWidget() { + super(ID, "Issue Filter", "/org/sonar/plugins/core/widgets/issues/project_issue_filter.html.erb"); + } +} diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/project_issue_filter.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/project_issue_filter.html.erb new file mode 100644 index 00000000000..c68f07565ce --- /dev/null +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/project_issue_filter.html.erb @@ -0,0 +1,49 @@ +<% + container_id = 'widget-issue-filter-' + widget.id.to_s + filter_id = widget_properties['filter'] + filter = Internal.issues.findIssueFilterById(filter_id.to_i) + distribution_axis = widget_properties['distributionAxis'] + + if @dashboard_configuration.selected_period? + period_date = @snapshot.period_datetime(@dashboard_configuration.period_index).strftime('%FT%T%z') + else + period_date = nil + end +%> + +<% if filter %> + <% if Internal.issues.isUserAuthorized(filter) %> + + <% @widget_title = "<a href=\"#{url_for({:controller => 'component_issues', :action => 'index'})}?id=#{u(@project.key)}##{filter.data}\">#{h(filter.name)}</a>" %> + <% if widget_properties['displayFilterDescription'] && !filter.description.blank? %> + <p class="note spacer-bottom"><%= h filter.description -%></p> + <% end %> + + <div id="<%= container_id -%>"></div> + <script> + require(['widgets/issue-filter'], function (IssueFilter) { + window.requestMessages().done(function () { + new IssueFilter({ + el: '#<%= container_id -%>', + query: '<%= filter.data -%>', + distributionAxis: '<%= distribution_axis -%>', + <% if period_date %> + periodDate: '<%= period_date -%>', + <% end %> + componentUuid: '<%= @project.uuid -%>', + componentKey: '<%= @project.key -%>' + }); + }); + }); + </script> + + <% else %> + + <p class="message-alert"><%= message 'widget.issue_filter.insufficient_privileges_warning' -%></p> + + <% end %> +<% else %> + + <p class="message-alert"><%= message 'widget.issue_filter.unknown_filter_warning' -%></p> + +<% end %> |