From: simonbrandhof Date: Thu, 28 Oct 2010 10:31:52 +0000 (+0000) Subject: SONAR-1643 unfollow shared dashboards X-Git-Tag: 2.6~739 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=47b94087e3c4b7b3b0f7368bc01a95840c145712;p=sonarqube.git SONAR-1643 unfollow shared dashboards --- diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb index 61f4c54f61e..b4ff961f126 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb @@ -109,6 +109,8 @@ class DashboardController < ApplicationController @active=ActiveDashboard.find(:first, :include => 'dashboard', :conditions => ['active_dashboards.dashboard_id=? AND active_dashboards.user_id=?', params[:id].to_i, current_user.id]) elsif params[:name] @active=ActiveDashboard.find(:first, :include => 'dashboard', :conditions => ['dashboards.name=? AND active_dashboards.user_id=?', params[:name], current_user.id]) + else + @active=ActiveDashboard.find(:first, :include => 'dashboard', :conditions => ['active_dashboards.user_id=?', current_user.id], :order => 'order_index ASC') end end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb index 670f637e425..4fc1e09562e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb @@ -21,7 +21,7 @@ class DashboardsController < ApplicationController SECTION=Navigation::SECTION_RESOURCE - verify :method => :post, :only => [:create, :update, :delete, :up, :down], :redirect_to => {:action => :index} + verify :method => :post, :only => [:create, :update, :delete, :up, :down, :unfollow], :redirect_to => {:action => :index} before_filter :login_required def index @@ -126,7 +126,13 @@ class DashboardsController < ApplicationController redirect_to :action => 'index', :resource => params[:resource] end - + def unfollow + active_dashboard=ActiveDashboard.find(:first, :conditions => ['user_id=? AND dashboard_id=?', current_user.id, params[:id].to_i]) + if active_dashboard + active_dashboard.destroy + end + redirect_to :action => :index, :resource => params[:resource] + end private diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/index.html.erb index aafb84fbd8e..027299e3d03 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/index.html.erb @@ -44,7 +44,7 @@ | <%= link_to 'Delete', {:action => 'delete', :id => active.dashboard_id, :resource => params[:resource]}, :method => :post, :confirm => 'Do you want to delete this dashboard ?', :id => "delete-#{u active.name}" %> <% else %> - <%= link_to 'Unfollow', {:action => 'unfollow', :id => active.dashboard_id}, :method => :post, :id => "hide-#{u active.name}" %> + <%= link_to 'Unfollow', {:action => 'unfollow', :id => active.dashboard_id, :resource => params[:resource]}, :method => :post, :id => "unfollow-#{u active.name}" %> <% end %>