From 7fb6c24c478db3b8f60cc41baa771402339fb21b Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Wed, 3 Nov 2010 11:04:26 +0000 Subject: [PATCH] SONAR-1643 change URL format for permalinks and breadcrumb --- .../app/controllers/dashboard_controller.rb | 22 +++++++++---------- .../app/controllers/dashboards_controller.rb | 2 +- .../WEB-INF/app/helpers/application_helper.rb | 2 +- .../dashboard/_configure_widget.html.erb | 2 +- .../app/views/dashboard/_header.html.erb | 6 ++--- .../app/views/dashboard/_widget.html.erb | 2 +- .../dashboard/_widget_definition.html.erb | 2 +- .../app/views/dashboard/configure.html.erb | 2 +- .../app/views/dashboard/edit_layout.html.erb | 10 ++++----- .../app/views/dashboards/index.html.erb | 4 ++-- .../app/views/layouts/_layout.html.erb | 2 +- 11 files changed, 28 insertions(+), 28 deletions(-) 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 b554f01d01a..293a45ff67d 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 @@ -44,7 +44,7 @@ class DashboardController < ApplicationController end def set_layout - dashboard=Dashboard.find(params[:id].to_i) + dashboard=Dashboard.find(params[:did].to_i) if dashboard.editable_by?(current_user) dashboard.column_layout=params[:layout] if dashboard.save @@ -55,7 +55,7 @@ class DashboardController < ApplicationController end end end - redirect_to :action => 'index', :id => dashboard.id, :resource => params[:resource] + redirect_to :action => 'index', :did => dashboard.id, :id => params[:id] end def set_dashboard @@ -84,7 +84,7 @@ class DashboardController < ApplicationController end def add_widget - dashboard=Dashboard.find(params[:id].to_i) + dashboard=Dashboard.find(params[:did].to_i) widget_id=nil if dashboard.editable_by?(current_user) definition=java_facade.getWidget(params[:widget]) @@ -97,12 +97,12 @@ class DashboardController < ApplicationController widget_id=new_widget.id end end - redirect_to :action => 'configure', :id => dashboard.id, :resource => params[:resource], :highlight => widget_id + redirect_to :action => 'configure', :did => dashboard.id, :id => params[:id], :highlight => widget_id end def save_widget - widget=Widget.find(params[:id].to_i) + widget=Widget.find(params[:wid].to_i) #TODO check owner of dashboard definition=java_facade.getWidget(widget.widget_key) errors_by_property_key={} @@ -124,7 +124,7 @@ class DashboardController < ApplicationController widget.save widget.properties.each {|p| p.save} render :update do |page| - page.redirect_to(url_for(:action => :configure, :id => widget.dashboard_id, :resource => params[:resource])) + page.redirect_to(url_for(:action => :configure, :did => widget.dashboard_id, :id => params[:id])) end else widget.configured=false @@ -140,8 +140,8 @@ class DashboardController < ApplicationController def load_dashboard @active=nil if logged_in? - if params[:id] - @active=ActiveDashboard.find(:first, :include => 'dashboard', :conditions => ['active_dashboards.dashboard_id=? AND active_dashboards.user_id=?', params[:id].to_i, current_user.id]) + if params[:did] + @active=ActiveDashboard.find(:first, :include => 'dashboard', :conditions => ['active_dashboards.dashboard_id=? AND active_dashboards.user_id=?', params[:did].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 @@ -151,8 +151,8 @@ class DashboardController < ApplicationController if @active.nil? # anonymous or not found in user dashboards - if params[:id] - @active=ActiveDashboard.find(:first, :include => 'dashboard', :conditions => ['active_dashboards.dashboard_id=? AND active_dashboards.user_id IS NULL', params[:id].to_i]) + if params[:did] + @active=ActiveDashboard.find(:first, :include => 'dashboard', :conditions => ['active_dashboards.dashboard_id=? AND active_dashboards.user_id IS NULL', params[:did].to_i]) elsif params[:name] @active=ActiveDashboard.find(:first, :include => 'dashboard', :conditions => ['dashboards.name=? AND active_dashboards.user_id IS NULL', params[:name]]) else @@ -163,7 +163,7 @@ class DashboardController < ApplicationController end def load_resource - @resource=Project.by_key(params[:resource]) + @resource=Project.by_key(params[:id]) if @resource.nil? # TODO display error page redirect_to home_path 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 69b6296a12b..a27e5c595dc 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 @@ -50,7 +50,7 @@ class DashboardsController < ApplicationController add_default_dashboards_if_first_user_dashboard last_active_dashboard=current_user.active_dashboards.max{|x,y| x.order_index<=>y.order_index} current_user.active_dashboards.create(:dashboard => @dashboard, :user_id => current_user.id, :order_index => (last_active_dashboard ? last_active_dashboard.order_index+1: 1)) - redirect_to :controller => 'dashboard', :action => 'configure', :id => @dashboard.id, :resource => params[:resource] + redirect_to :controller => 'dashboard', :action => 'configure', :did => @dashboard.id, :id => params[:resource] else flash[:error]=@dashboard.errors.full_messages.join('
') redirect_to :controller => 'dashboards', :action => 'index', :resource => params[:resource] diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb index 11f71379f6c..ef27c1109be 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/application_helper.rb @@ -300,7 +300,7 @@ module ApplicationHelper def link_to_resource(resource, name=nil, options={}) if resource.display_dashboard? if options[:dashboard] - link_to(name || resource.name, {:overwrite_params => {:controller => 'project', :action => 'index', :id => resource.copy_resource_id || resource.id}}, :title => options[:title]) + link_to(name || resource.name, {:overwrite_params => {:controller => 'dashboard', :action => 'index', :id => resource.copy_resource_id || resource.id}}, :title => options[:title]) else # stay on the same page (for example components) link_to(name || resource.name, {:overwrite_params => {:id => resource.copy_resource_id || resource.id}}, :title => options[:title]) diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb index db775bfe743..94f8cbc6375 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb @@ -18,7 +18,7 @@
- <% form_remote_tag :url => {:action => 'save_widget', :id => widget.id, :resource => params[:resource]}, :method => :post do -%> + <% form_remote_tag :url => {:action => 'save_widget', :wid => widget.id, :id => params[:id]}, :method => :post do -%> <% definition.getProperties().each do |property_def| diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb index c68cee1a18b..040d8ba867f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_header.html.erb @@ -2,11 +2,11 @@ <% if logged_in? %>
- <%= link_to active.name, {:controller => :dashboard, :action => :index, :id => active.dashboard_id, :resource => params[:resource]} -%> + <%= link_to active.name, {:controller => :dashboard, :action => :index, :did => active.dashboard_id, :id => params[:resource]} -%> <% if active.dashboard.description.present? %>

<%= h active.dashboard.description -%>

<% end %> @@ -43,7 +43,7 @@
<% if active.owner?(current_user) %> - <%= link_to 'Configure widgets', {:controller => :dashboard, :action => 'configure', :id => active.dashboard_id, :resource => params[:resource]}, :id => "configure-#{u active.name}" %> + <%= link_to 'Configure widgets', {:controller => :dashboard, :action => 'configure', :did => active.dashboard_id, :id => params[:resource]}, :id => "configure-#{u active.name}" %> | <%= link_to_remote "Edit", :update => "admin_form", :url => { :action => "edit", :id => active.dashboard_id, :resource => params[:resource] }, :id => "edit-#{u active.name}", :method => :get %> | diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb index cedafc0abcb..aeefa08a45f 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb @@ -35,7 +35,7 @@ <% elsif (selected_section==Navigation::SECTION_RESOURCE) %> <% ActiveDashboard.user_dashboards(current_user).each do |active_dashboard| %> -
  • <%= active_dashboard.dashboard.name -%>
  • +
  • <%= active_dashboard.dashboard.name -%>
  • <% end %>
  • Components
  • Violations drilldown
  • -- 2.39.5