Patch #1507

Dynamic project selector

Added by Michael Pirogov over 9 years ago. Updated almost 9 years ago.

Status:ClosedStart date:2008-06-20
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Projects
Target version:-

Description

Dirty and ugly hack to make project selector do not jump on project root, but on current action.

Index: app/views/layouts/_project_selector.rhtml
===================================================================
--- app/views/layouts/_project_selector.rhtml    (revision 1565)
+++ app/views/layouts/_project_selector.rhtml    (working copy)
@@ -3,10 +3,21 @@
 <option selected="selected"><%= l(:label_jump_to_a_project) %></option>
 <option disabled="disabled">---</option>
 <% user_projects_by_root.keys.sort.each do |root| %>
-    <%= content_tag('option', h(root.name), :value => url_for(:controller => 'projects', :action => 'show', :id => root)) %>
+    <%#= content_tag('option', h(root.name), :value => url_for(:controller => 'projects', :action => controller.action_name, :id => root)) %>
+    <% if params[:controller] != 'issues' %>
+    <%= content_tag('option', h(root.name), :value => url_for(:controller => 'projects', :action => controller.action_name, :id => root)) %>
+    <% else %>
+    <%= content_tag('option', h(root.name), :value => url_for(:controller => 'projects', :action => root.identifier, :id => 'issues')) %>
+    <% end %>
     <% user_projects_by_root[root].sort.each do |project| %>
         <% next if project == root %>
-        <%= content_tag('option', ('&#187; ' + h(project.name)), :value => url_for(:controller => 'projects', :action => 'show', :id => project)) %>
+        <%#= content_tag('option', ('&#187; ' + h(project.name)), :value => url_for(:controller => 'projects', :action => controller.action_name, :id => project)) %>
+    <% if params[:controller] != 'issues' %>
+        <%= content_tag('option', ('&#187; ' + h(project.name)), :value => url_for(:controller => 'projects', :action => controller.action_name, :id => project)) %>
+        <% else %>
+        <%= content_tag('option', ('&#187; ' + h(project.name)), :value => url_for(:controller => 'projects', :action => project.identifier, :id => 'issues')) %>
+
+        <% end %>
     <% end %>
 <% end %>
 </select>

On nil destination action there is 403 status. You can disable this by next nasty hack:

Index: app/controllers/application.rb
===================================================================
--- app/controllers/application.rb    (revision 1565)
+++ app/controllers/application.rb    (working copy)
@@ -132,9 +132,10 @@
   end

   def render_403
-    @project = nil
-    render :template => "common/403", :layout => !request.xhr?, :status => 403
-    return false
+#@project = nil
+#render :template => "common/403", :layout => !request.xhr?, :status => 403
+#return false
+    redirect_to :controller => :projects, :action => :show,:id => @project
   end

   def render_404


Related issues

Related to Redmine - Feature #2364: Make the "jump to project" combo should navigate to the s... Closed 2008-12-19

History

#1 Updated by Jean-Philippe Lang over 9 years ago

On nil destination action there is 403 status. You can disable this by next nasty hack [...]

This hack generates infinite redirections when a user requests a project he is not authorized to view.

#2 Updated by Michael Pirogov over 9 years ago

OK. It's officially unsupported and not recommended ;-)

#3 Updated by Jean-Philippe Lang almost 9 years ago

  • Status changed from New to Closed

Feature added in r2210.

Also available in: Atom PDF