]> source.dussan.org Git - sonarqube.git/commitdiff
Fix links in My Dashboards sections
authorDavid Gageot <david@gageot.net>
Fri, 18 May 2012 11:39:33 +0000 (13:39 +0200)
committerDavid Gageot <david@gageot.net>
Fri, 18 May 2012 11:43:35 +0000 (13:43 +0200)
sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/models/active_dashboard.rb
sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/_create.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/dashboards/index.html.erb

index afe9b33a584df716bd891f622f3a32818d27b90c..f012d8b8edb10e6f6d196ff2e8cf2df537634368 100644 (file)
@@ -80,7 +80,7 @@ class DashboardsController < ApplicationController
       load_dashboard_from_params(dashboard)
 
       if dashboard.save
-        if !dashboard.shared?
+        unless dashboard.shared?
           ActiveDashboard.destroy_all(['dashboard_id = ? and (user_id<>? OR user_id IS NULL)', dashboard.id, current_user.id])
         end
       else
@@ -182,5 +182,4 @@ class DashboardsController < ApplicationController
     end
   end
 
-
 end
index b902485966ececf62502738b4ff303af5cfc45a2..abdbbfa00c8f9cca60def39edafd1d7a12340baf 100644 (file)
@@ -43,6 +43,10 @@ class ActiveDashboard < ActiveRecord::Base
     dashboard.owner?(user)
   end
 
+  def editable_by?(user)
+    dashboard.editable_by?(user)
+  end
+
   def follower?(user)
     self.user.nil? || self.user_id==user.id
   end
index 63661de833300232cba3bc2ef3e97dad069fa4a9..f3e9a09e4ee26227cbfc966e62a94bfd7b9e9fe8 100644 (file)
@@ -15,7 +15,7 @@
     </tr>
     <% if is_admin? %>
       <tr>
-        <td class="left" valign="top">
+        <td class="left" valign="top" colspan="2">
           <%= message('shared') -%>:<br/><input type="checkbox" name="shared" value="true">
         </td>
       </tr>
index fc41d6de89493e89a5170cb42d35ac2aa1a8040f..705f7d27e0d1131a0a4abdc75228bdc7b358eef7 100644 (file)
@@ -24,7 +24,7 @@
         <% @actives.each_with_index do |active, index| %>
           <tr id="dashboard-<%= u active.name -%>" class="<%= cycle('even', 'odd', :name => 'dashboard') -%>">
             <td>
-              <%= link_to active.name(true), {:controller => :dashboard, :action => :index, :did => active.dashboard_id, :id => (params[:resource] unless active.global?)} -%>
+              <%= active.name(true) -%>
               <div class="description"><%= h active.dashboard.description -%></div>
             </td>
             <% if is_admin %>
             <% end %>
             <td>
               <% if index > 0 %>
-                <%= link_to image_tag('blue-up.png'), {:action => 'up', :id => active.id, :resource => params[:resource]}, :method => :post, :id => "up-#{u active.name}" %>
+                <%= link_to image_tag('blue-up.png'), {:action => :up, :id => active.id, :resource => params[:resource]}, :method => :post, :id => "up-#{u active.name}" %>
               <% else %>
                 <%= image_tag('transparent_16.gif') %>
               <% end %>
               <% if index < @actives.size-1 %>
-                <%= link_to image_tag('blue-down.png'), {:action => 'down', :id => active.id, :resource => params[:resource]}, :method => :post, :id => "down-#{u active.name}" %>
+                <%= link_to image_tag('blue-down.png'), {:action => :down, :id => active.id, :resource => params[:resource]}, :method => :post, :id => "down-#{u active.name}" %>
               <% end %>
             </td>
             <td class="thin nowrap right">
-              <% if active.owner?(current_user) %>
+              <% if active.editable_by?(current_user) %>
                 <%= link_to message('dashboard.configure_widgets'), {:controller => :dashboard, :action => :configure, :did => active.dashboard_id, :id => (params[:resource] unless active.global?)},
                             :id => "configure-#{u active.name}", :class => 'link-action' %>
                 |
                 <%= link_to_remote message('edit'), {:update => "create_dashboard", :url => {:action => :edit, :id => active.dashboard_id, :resource => params[:resource]}},
                                    {:id => "edit-#{u active.name}", :method => :get, :class => 'link-action'} %>
                 <% if @actives.size() > 1 %>
-                  |
-                  <%= link_to message('delete'), {:action => :delete, :id => active.dashboard_id, :resource => params[:resource]}, :method => :post,
-                              :confirm => message('dashboard.do_you_want_to_delete_dashboard'), :id => "delete-#{u active.name}", :class => 'link-action' %>
+                    |
+                  <% if active.owner?(current_user) %>
+                      <%= link_to message('delete'), {:action => :delete, :id => active.dashboard_id, :resource => params[:resource]}, :method => :post,
+                                  :confirm => message('dashboard.do_you_want_to_delete_dashboard'), :id => "delete-#{u active.name}", :class => 'link-action' %>
+                  <% else %>
+                      <%= link_to message('unfollow'), {:action => :unfollow, :id => active.dashboard_id, :resource => params[:resource]}, :method => :post,
+                                  :id => "unfollow-#{u active.name}", :class => 'link-action' %>
+                  <% end %>
                 <% end %>
-              <% elsif @actives.size() > 1 %>
+              <% elsif !active.owner?(current_user) && (@actives.size() > 1) %>
                 <%= link_to message('unfollow'), {:action => :unfollow, :id => active.dashboard_id, :resource => params[:resource]}, :method => :post,
                             :id => "unfollow-#{u active.name}", :class => 'link-action' %>
               <% end %>
            @shared_dashboards.each do |dashboard| %>
           <tr id="shared-dashboard-<%= u dashboard.name -%>" class="<%= cycle('even', 'odd', :name => 'shared') -%>">
             <td>
-              <%= link_to dashboard.name(true), {:controller => :dashboard, :action => :index, :id => params[:resource], :did => dashboard.id} -%>
-              <% if dashboard.description.present? %>
-                <p class="small"><%= h dashboard.description -%></p>
-              <% end %>
+              <%= dashboard.name(true) -%>
+              <div class="description"><%= h dashboard.description -%></div>
             </td>
             <td>
               <%= dashboard.user_name -%>