]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5540 Fix links in breadcrumb
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 27 Aug 2014 15:42:17 +0000 (17:42 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 27 Aug 2014 16:16:09 +0000 (18:16 +0200)
server/sonar-web/src/main/webapp/WEB-INF/app/helpers/application_helper.rb
server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb

index 18649eeb084eee598b185f51957b5447c1a47dad..775a114120ada779051a0085500c0c2bbbc1124b 100644 (file)
@@ -311,32 +311,37 @@ module ApplicationHelper
   def link_to_resource(resource, name=nil, options={})
     period_index=options[:period]
     period_index=nil if period_index && period_index<=0
+
     if resource.display_dashboard?
       if options[:dashboard]
-        url = "#{ApplicationController.root_context}/dashboard/index?id=#{u resource.id}"
-        url += "&period=#{u period_index}" if period_index
-        url += "&tab=#{u options[:tab]}" if options[:tab]
-        url += "&rule=#{u options[:rule]}" if options[:rule]
-        "<a class='#{options[:class]}' title='#{options[:title]}' href='#{url}'>#{name || resource.name}</a>"
+        query = request.query_parameters.merge({:id => resource.id})
+        query[:period] = period_index if period_index
+        query[:tab] = options[:tab] if options[:tab]
+        query[:rule] = options[:rule] if options[:rule]
+        url = URI::HTTP.build(:path => "#{ApplicationController.root_context}/dashboard/index", :query => query.to_query)
+        "<a class='#{options[:class]}' title='#{options[:title]}' href='#{url}'>#{h(name || resource.name)}</a>"
       else
         # stay on the same page (for example components)
-        url = "#{ApplicationController.root_context}/#{u params[:controller]}/#{u params[:action]}?id=#{u resource.id}"
-        url += "&period=#{u period_index}" if period_index
-        url += "&tab=#{u options[:tab]}" if options[:tab]
-        url += "&rule=#{u options[:rule]}" if options[:rule]
-        "<a class='#{options[:class]}' title='#{options[:title]}' href='#{url}'>#{name || resource.name}</a>"
+        query = request.query_parameters.merge({:id => resource.id})
+        query[:period] = period_index if period_index
+        query[:tab] = options[:tab] if options[:tab]
+        query[:rule] = options[:rule] if options[:rule]
+        url = URI::HTTP.build(:path => "#{ApplicationController.root_context}/#{u params[:controller]}/#{u params[:action]}", :query => query.to_query)
+        "<a class='#{options[:class]}' title='#{options[:title]}' href='#{url}'>#{h(name || resource.name)}</a>"
       end
     else
-      url = "#{ApplicationController.root_context}/dashboard/index?id=#{u resource.key}"
-      url += "&period=#{u period_index}" if period_index
-      url += "&tab=#{u options[:tab]}" if options[:tab]
-      url += "&rule=#{u options[:rule]}" if options[:rule]
-      url += "&metric=#{u options[:metric]}" if options[:metric]
+      query = {:id => resource.id}
+      query[:period] = period_index if period_index
+      query[:tab] = options[:tab] if options[:tab]
+      query[:rule] = options[:rule] if options[:rule]
+      query[:metric] = options[:metric] if options[:metric]
+      url = URI::HTTP.build(:path => "#{ApplicationController.root_context}/dashboard/index", :query => query.to_query)
       url += '#L' + options[:line].to_s if options[:line]
       "<a class='#{options[:class]}' title='#{options[:title]}' " +
           "onclick='window.open(this.href,\"resource-#{resource.key.parameterize}\",\"\");return false;' " +
-          "href='#{url}'>#{name || resource.name}</a>"
+          "href='#{url}'>#{h(name || resource.name)}</a>"
     end
+
   end
 
 
index e3dcb357702b2e6b33515a0579ce82aecce44c44..3d7974dc9ea177f04f7710c20747728ad961157f 100644 (file)
@@ -54,7 +54,7 @@
     </ul>
     <ul id="bc">
       <%
-         resource_link = {}
+         resource_link = {:controller => params[:controller], :action => params[:action]}
          if display_only_root
            resource_link = {:controller => 'dashboard', :action => 'index'}
          end
           <li>
             <%= qualifier_icon(resource) -%>
             &nbsp;
-            <%= link_to(h(resource.name), params.merge({:id => resource.key}.merge(resource_link))) -%>
+            <%=
+                query = request.query_parameters.merge({:id => resource.key})
+                url = URI::HTTP.build(:path => "#{ApplicationController.root_context}/#{u resource_link[:controller]}/#{u resource_link[:action]}", :query => query.to_query)
+                "<a href='#{url}'>#{h(resource.name)}</a>"
+            -%>
           </li>
         <%
            end