aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2015-03-20 11:39:04 +0100
committerStas Vilchik <vilchiks@gmail.com>2015-03-20 11:39:18 +0100
commit5b16186c846141eb9a968e38c861dd3652029884 (patch)
tree36c6df526e479cb1ee5436bb03208c6700444ec3
parent27a74b7027f06676d632ac7db3a9bae332042a3c (diff)
downloadsonarqube-5b16186c846141eb9a968e38c861dd3652029884.tar.gz
sonarqube-5b16186c846141eb9a968e38c861dd3652029884.zip
SONAR-6234 apply feedback
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issue_filter.html.erb10
-rw-r--r--plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/project_issue_filter.html.erb44
2 files changed, 42 insertions, 12 deletions
diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issue_filter.html.erb b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issue_filter.html.erb
index 6e5203df6c1..10a2f1ae5e5 100644
--- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issue_filter.html.erb
+++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/issue_filter.html.erb
@@ -3,10 +3,13 @@
filter_id = widget_properties['filter']
filter = Internal.issues.findIssueFilterById(filter_id.to_i)
distribution_axis = widget_properties['distributionAxis']
+ is_enough_permissions = filter.shared || (current_user && filter.userLogin == current_user.login)
%>
<% if filter %>
+ <% if is_enough_permissions %>
+
<% @widget_title = "<a href=\"#{url_for({:controller => 'issues', :action => 'index'})}#id=#{filter.id}\">#{h(filter.name)}</a>" %>
<% if widget_properties['displayFilterDescription'] && !filter.description.blank? %>
<p class="note spacer-bottom"><%= h filter.description -%></p>
@@ -16,6 +19,7 @@
<script>
(function () {
var query = '<%= filter.data -%>';
+
// do not show widget if the filter contains "my" criterion,
// and a user is not authenticated
if (query && query.indexOf('__me__') !== -1 && !window.SS.user) {
@@ -35,6 +39,12 @@
})();
</script>
+ <% else %>
+
+ <p class="alert alert-warning"><%= message 'widget.issue_filter.insufficient_privileges_warning' -%></p>
+
+ <% end %>
+
<% else %>
<p class="alert alert-warning"><%= message 'widget.issue_filter.unknown_filter_warning' -%></p>
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
index e901d6f0cfa..46a1e088d7d 100644
--- 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
@@ -3,6 +3,7 @@
filter_id = widget_properties['filter']
filter = Internal.issues.findIssueFilterById(filter_id.to_i)
distribution_axis = widget_properties['distributionAxis']
+ is_enough_permissions = filter.shared || (current_user && filter.userLogin == current_user.login)
if @dashboard_configuration.selected_period?
period_date = @snapshot.period_datetime(@dashboard_configuration.period_index).strftime('%FT%T%z')
@@ -13,6 +14,8 @@
<% if filter %>
+ <% if is_enough_permissions %>
+
<% @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>
@@ -20,22 +23,39 @@
<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 -%>'
+ (function () {
+ var query = '<%= filter.data -%>';
+
+ // do not show widget if the filter contains "my" criterion,
+ // and a user is not authenticated
+ if (query && query.indexOf('__me__') !== -1 && !window.SS.user) {
+ jQuery('#<%= container_id -%>').closest('.block').addClass('hidden');
+ return;
+ }
+
+ require(['widgets/issue-filter'], function (IssueFilter) {
+ window.requestMessages().done(function () {
+ new IssueFilter({
+ el: '#<%= container_id -%>',
+ query: query,
+ distributionAxis: '<%= distribution_axis -%>',
+ <% if period_date %>
+ periodDate: '<%= period_date -%>',
+ <% end %>
+ componentUuid: '<%= @project.uuid -%>',
+ componentKey: '<%= @project.key -%>'
+ });
});
});
- });
+ })();
</script>
+ <% else %>
+
+ <p class="alert alert-warning"><%= message 'widget.issue_filter.insufficient_privileges_warning' -%></p>
+
+ <% end %>
+
<% else %>
<p class="alert alert-warning"><%= message 'widget.issue_filter.unknown_filter_warning' -%></p>