Commit 50a24707 authored by jplang's avatar jplang

Restores the "New issue" tab in the project menu and makes it optional (#6204).

git-svn-id: https://svn.redmine.org/redmine/trunk@15407 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent c3039d1d
......@@ -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
......
......@@ -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) %>
......
......@@ -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
......
......@@ -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
......
......@@ -275,3 +275,5 @@ non_working_week_days:
default:
- '6'
- '7'
new_project_issue_tab_enabled:
default: 0
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment