aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2012-12-05 15:48:03 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2012-12-05 15:48:13 +0100
commit7d603e52d7e084f93485d50a71227b4c32eff3e8 (patch)
treec570e0b2203c856c2e3447b8a2f689b453e79c7f
parent31a625a9830a13fe0e9291c4919d0a54dfbdf012 (diff)
downloadsonarqube-7d603e52d7e084f93485d50a71227b4c32eff3e8.tar.gz
sonarqube-7d603e52d7e084f93485d50a71227b4c32eff3e8.zip
SONAR-3825 allow to drop/edit system filters
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter.rb6
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/measures/manage.html.erb22
2 files changed, 23 insertions, 5 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter.rb
index b2ebe1a5c7e..b4deac57625 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/measure_filter.rb
@@ -174,6 +174,10 @@ class MeasureFilter < ActiveRecord::Base
end
end
+ def system?
+ user_id == nil
+ end
+
# ==== Options
# :user : the authenticated user
def execute(controller, options={})
@@ -279,6 +283,8 @@ class MeasureFilter < ActiveRecord::Base
if shared
count = MeasureFilter.count('id', :conditions => ['name=? and shared=? and user_id!=?', name, true, user_id])
errors.add_to_base('Other users already shared filters with the same name') if count>0
+ elsif system?
+ errors.add_to_base("System filters can't be unshared.")
end
end
end \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/manage.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/manage.html.erb
index e1c9a1976ae..820f2f55969 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/measures/manage.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/measures/manage.html.erb
@@ -5,10 +5,10 @@
var filterId = $j(this).attr('filter-id');
var star = $j(this);
$j.ajax({
- type:'POST',
- url:baseUrl + "/measures/toggle_fav",
- data:{id:filterId},
- success:function (data) {
+ type: 'POST',
+ url: baseUrl + "/measures/toggle_fav",
+ data: {id: filterId},
+ success: function (data) {
if (data == 'true') {
star.removeClass('notfav').addClass('fav');
star.attr('title', '<%= escape_javascript message('click_to_remove_from_favourites') -%>');
@@ -42,7 +42,7 @@
<tbody>
<% if current_user.measure_filters.empty? %>
<tr class="even">
- <td colspan="4"><%= message('filters.no_filters') -%></td>
+ <td colspan="4"><%= message('measure_filter.no_filters') -%></td>
</tr>
<% else %>
<% current_user.measure_filters.each do |filter| %>
@@ -116,6 +116,18 @@
</td>
<td class="thin nowrap right">
<a id="copy-<%= filter.name.parameterize -%>" href="<%= ApplicationController.root_context -%>/measures/copy_form/<%= filter.id -%>" class="link-action open-modal"><%= message('copy') -%></a>
+ <% if filter.system? && has_role?(:admin) %>
+ &nbsp;
+ <a id="edit_system_<%= filter.name.parameterize -%>" href="<%= ApplicationController.root_context -%>/measures/edit_form/<%= filter.id -%>" class="link-action open-modal"><%= message('edit') -%></a>
+ &nbsp;
+ <%= link_to_action message('delete'), "#{ApplicationController.root_context}/measures/delete/#{filter.id}",
+ :class => 'link-action link-red',
+ :id => "delete_system_#{filter.name.parameterize}",
+ :confirm_button => message('delete'),
+ :confirm_title => 'measure_filter.delete_confirm_title',
+ :confirm_msg => 'measure_filter.are_you_sure_want_delete_filter_x',
+ :confirm_msg_params => [filter.name] -%>
+ <% end %>
</td>
</tr>
<% end %>