Project

General

Profile

Actions

Patch #1507

closed

Dynamic project selector

Added by Michael Pirogov almost 16 years ago. Updated over 15 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Projects
Target version:
-
Start date:
2008-06-20
Due date:
% Done:

0%

Estimated time:

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 same current page in the selected projectClosed2008-12-19

Actions
Actions #1

Updated by Jean-Philippe Lang almost 16 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.

Actions #2

Updated by Michael Pirogov almost 16 years ago

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

Actions #3

Updated by Jean-Philippe Lang over 15 years ago

  • Status changed from New to Closed

Feature added in r2210.

Actions

Also available in: Atom PDF