]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1643 unfollow shared dashboards
authorsimonbrandhof <simon.brandhof@gmail.com>
Thu, 28 Oct 2010 10:31:52 +0000 (10:31 +0000)
committersimonbrandhof <simon.brandhof@gmail.com>
Thu, 28 Oct 2010 10:31:52 +0000 (10:31 +0000)
sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/index.html.erb

index 61f4c54f61e7296150653f409e62f16efe816367..b4ff961f1263dae01b78eddc181b86e43afad99d 100644 (file)
@@ -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
 
index 670f637e4250cc9ddd5d184757f947bd4b4adb19..4fc1e09562edc1297c6b81847302cb1cef96c419 100644 (file)
@@ -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
 
index aafb84fbd8e25fda3c9c346bc9252d2da765bb32..027299e3d03f4ca4d678bec2eac7d11f575c74c6 100644 (file)
@@ -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 %>
               </td>
             </tr>