From: Julien Lancelot Date: Wed, 27 Aug 2014 15:42:17 +0000 (+0200) Subject: SONAR-5540 Fix links in breadcrumb X-Git-Tag: 4.5-RC1~68 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ad7b5a4e10c5556d3449c842e233e2dfd2562074;p=sonarqube.git SONAR-5540 Fix links in breadcrumb --- diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/application_helper.rb index 18649eeb084..775a114120a 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/application_helper.rb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/helpers/application_helper.rb @@ -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] - "#{name || resource.name}" + 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) + "#{h(name || resource.name)}" 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] - "#{name || resource.name}" + 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) + "#{h(name || resource.name)}" 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] "#{name || resource.name}" + "href='#{url}'>#{h(name || resource.name)}" end + end diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb index e3dcb357702..3d7974dc9ea 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_breadcrumb.html.erb @@ -54,7 +54,7 @@