]> source.dussan.org Git - redmine.git/commitdiff
Restores the "New issue" tab in the project menu and makes it optional (#6204).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 9 May 2016 17:16:55 +0000 (17:16 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Mon, 9 May 2016 17:16:55 +0000 (17:16 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@15407 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issues_controller.rb
app/views/settings/_display.html.erb
config/locales/en.yml
config/locales/fr.yml
config/settings.yml
lib/redmine.rb
test/functional/issues_controller_test.rb

index 7c10769aa190d4c65cf0113d8dc56f0a68d56ef0..cf402de226824182a0d7bb47baba7998b6e83eb2 100644 (file)
@@ -350,6 +350,16 @@ class IssuesController < ApplicationController
     end
   end
 
+  # Overrides Redmine::MenuManager::MenuController::ClassMethods for
+  # when the "New issue" tab is enabled
+  def current_menu_item
+    if Setting.new_project_issue_tab_enabled? && [:new, :create].include?(action_name.to_sym) 
+      :new_issue
+    else
+      super
+    end
+  end
+
   private
 
   def retrieve_previous_and_next_issue_ids
index 3497f9076a8431cbba1cee2022c6284c11bfb0c2..1185a7caefd25d782accd1259cb8cce3a04242d8 100644 (file)
@@ -24,6 +24,8 @@
 <p><%= setting_check_box :thumbnails_enabled %></p>
 
 <p><%= setting_text_field :thumbnails_size, :size => 6 %></p>
+
+<p><%= setting_check_box :new_project_issue_tab_enabled %></p>
 </div>
 
 <%= submit_tag l(:button_save) %>
index e1a8f2bd46a3afb8a9812cf20e4152f8745d1d41..b3396c5de92b8091fc5d4e0d42d82f0e52a21b11 100644 (file)
@@ -443,6 +443,7 @@ en:
   setting_search_results_per_page: Search results per page
   setting_attachment_extensions_allowed: Allowed extensions
   setting_attachment_extensions_denied: Disallowed extensions
+  setting_new_project_issue_tab_enabled: Display the "New issue" tab
 
   permission_add_project: Create project
   permission_add_subprojects: Create subprojects
index 659a873eaa431809a2bcb9d6a077b84cbd78bff0..6a72024f6b33ae386fa9b7966b629c2e5c80d7e6 100644 (file)
@@ -455,6 +455,7 @@ fr:
   setting_attachment_extensions_denied: Extensions non autorisées
   setting_sys_api_key: Clé de protection de l'API
   setting_lost_password: Autoriser la réinitialisation par email de mot de passe perdu
+  setting_new_project_issue_tab_enabled: Afficher l'onglet "Nouvelle demande"
 
   permission_add_project: Créer un projet
   permission_add_subprojects: Créer des sous-projets
index 20dfe54167f0f67ef8d39e077434d742dc7daeb4..fd807c8a112b5f172879bfc4c383672dec54ae2d 100644 (file)
@@ -275,3 +275,5 @@ non_working_week_days:
   default:
   - '6'
   - '7'
+new_project_issue_tab_enabled:
+  default: 0
index 540384071ea16fb7ed7691baf3e85357f20b73e8..1d37a523b5196ff6a5d80ed9261500d489440cb9 100644 (file)
@@ -231,6 +231,10 @@ Redmine::MenuManager.map :project_menu do |menu|
   menu.push :roadmap, { :controller => 'versions', :action => 'index' }, :param => :project_id,
               :if => Proc.new { |p| p.shared_versions.any? }
   menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural
+  menu.push :new_issue, { :controller => 'issues', :action => 'new', :copy_from => nil }, :param => :project_id, :caption => :label_issue_new,
+              :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) },
+              :if => Proc.new { |p| Setting.new_project_issue_tab_enabled? && p.trackers.any? },
+              :permission => :add_issues
   menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :param => :project_id, :caption => :label_gantt
   menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :param => :project_id, :caption => :label_calendar
   menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural
index 0a021289acee3485e19f4174d5280bff3dd6f187..8e04d7cf5353a2c4f2fbe221bdb07a14e3e781ef 100644 (file)
@@ -1060,7 +1060,7 @@ class IssuesControllerTest < ActionController::TestCase
   def test_index_should_include_new_issue_link
     @request.session[:user_id] = 2
     get :index, :project_id => 1
-    assert_select 'a.new-issue[href="/projects/ecookbook/issues/new"]', :text => 'New issue'
+    assert_select '#content a.new-issue[href="/projects/ecookbook/issues/new"]', :text => 'New issue'
   end
 
   def test_index_should_not_include_new_issue_link_for_project_without_trackers
@@ -1068,7 +1068,7 @@ class IssuesControllerTest < ActionController::TestCase
 
     @request.session[:user_id] = 2
     get :index, :project_id => 1
-    assert_select 'a.new-issue', 0
+    assert_select '#content a.new-issue', 0
   end
 
   def test_index_should_not_include_new_issue_link_for_users_with_copy_issues_permission_only
@@ -1078,13 +1078,59 @@ class IssuesControllerTest < ActionController::TestCase
 
     @request.session[:user_id] = 2
     get :index, :project_id => 1
-    assert_select 'a.new-issue', 0
+    assert_select '#content a.new-issue', 0
   end
 
   def test_index_without_project_should_include_new_issue_link
     @request.session[:user_id] = 2
     get :index
-    assert_select 'a.new-issue[href="/issues/new"]', :text => 'New issue'
+    assert_select '#content a.new-issue[href="/issues/new"]', :text => 'New issue'
+  end
+
+  def test_index_should_not_include_new_issue_tab_when_disabled
+    with_settings :new_project_issue_tab_enabled => '0' do
+      @request.session[:user_id] = 2
+      get :index, :project_id => 1
+      assert_select '#main-menu a.new-issue', 0
+    end
+  end
+
+  def test_index_should_include_new_issue_tab_when_enabled
+    with_settings :new_project_issue_tab_enabled => '1' do
+      @request.session[:user_id] = 2
+      get :index, :project_id => 1
+      assert_select '#main-menu a.new-issue[href="/projects/ecookbook/issues/new"]', :text => 'New issue'
+    end
+  end
+
+  def test_new_should_have_new_issue_tab_as_current_menu_item
+    with_settings :new_project_issue_tab_enabled => '1' do
+      @request.session[:user_id] = 2
+      get :new, :project_id => 1
+      assert_select '#main-menu a.new-issue.selected'
+    end
+  end
+
+  def test_index_should_not_include_new_issue_tab_for_project_without_trackers
+    with_settings :new_project_issue_tab_enabled => '1' do
+      Project.find(1).trackers.clear
+  
+      @request.session[:user_id] = 2
+      get :index, :project_id => 1
+      assert_select '#main-menu a.new-issue', 0
+    end
+  end
+
+  def test_index_should_not_include_new_issue_tab_for_users_with_copy_issues_permission_only
+    with_settings :new_project_issue_tab_enabled => '1' do
+      role = Role.find(1)
+      role.remove_permission! :add_issues
+      role.add_permission! :copy_issues
+  
+      @request.session[:user_id] = 2
+      get :index, :project_id => 1
+      assert_select '#main-menu a.new-issue', 0
+    end
   end
 
   def test_show_by_anonymous