Merge pull request #4462 from oliverguenther/feature/23170/override-help-link
[23170] Allow overriding the help linkpull/4473/head
commit
ac58159333
@ -0,0 +1,98 @@ |
||||
#-- encoding: UTF-8 |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF) |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang |
||||
# Copyright (C) 2010-2013 the ChiliProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License |
||||
# as published by the Free Software Foundation; either version 2 |
||||
# of the License, or (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
# |
||||
# See doc/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
module OpenProject |
||||
module Static |
||||
module Links |
||||
class << self |
||||
|
||||
def help_link_overridden? |
||||
OpenProject::Configuration.force_help_link.present? |
||||
end |
||||
|
||||
def help_link |
||||
OpenProject::Configuration.force_help_link.presence || links[:user_guides] |
||||
end |
||||
|
||||
def links |
||||
{ |
||||
user_guides: { |
||||
href: 'https://www.openproject.org/help/user-guides', |
||||
label: 'homescreen.links.user_guides' |
||||
}, |
||||
faq: { |
||||
href: 'https://www.openproject.org/help/faq', |
||||
label: 'homescreen.links.faq' |
||||
}, |
||||
glossary: { |
||||
href: 'https://www.openproject.org/help/user-guides/glossary/', |
||||
label: 'homescreen.links.glossary' |
||||
}, |
||||
shortcuts: { |
||||
href: 'https://www.openproject.org/help/user-guides/keyboard-shortcuts-access-keys/', |
||||
label: 'homescreen.links.shortcuts' |
||||
}, |
||||
boards: { |
||||
href: 'https://community.openproject.com/projects/openproject/boards', |
||||
label: 'homescreen.links.boards' |
||||
}, |
||||
professional_support: { |
||||
href: 'https://www.openproject.org/professional-services/', |
||||
label: :label_professional_support |
||||
}, |
||||
blog: { |
||||
href: 'https://www.openproject.org/blog', |
||||
label: 'homescreen.links.blog' |
||||
}, |
||||
release_notes: { |
||||
href: 'https://www.openproject.org/open-source/release-notes/', |
||||
label: :label_release_notes |
||||
}, |
||||
report_bug: { |
||||
href: 'https://www.openproject.org/open-source/report-bug/', |
||||
label: :label_report_bug |
||||
}, |
||||
roadmap: { |
||||
href: 'https://community.openproject.org/projects/openproject/roadmap', |
||||
label: :label_development_roadmap |
||||
}, |
||||
crowdin: { |
||||
href: 'https://crowdin.com/projects/opf', |
||||
label: :label_add_edit_translations |
||||
}, |
||||
api_docs: { |
||||
href: 'https://www.openproject.org/api', |
||||
label: :label_api_documentation |
||||
}, |
||||
} |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,98 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF) |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang |
||||
# Copyright (C) 2010-2013 the ChiliProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License |
||||
# as published by the Free Software Foundation; either version 2 |
||||
# of the License, or (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
# |
||||
# See doc/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
require 'concerns/omniauth_login' |
||||
require 'open_project/static/links' |
||||
|
||||
module Redmine::MenuManager::HelpMenuHelper |
||||
def render_help_top_menu_node(item = help_menu_item) |
||||
if OpenProject::Static::Links.help_link_overridden? |
||||
render_menu_node(item) |
||||
else |
||||
render_help_dropdown |
||||
end |
||||
end |
||||
|
||||
def render_help_dropdown |
||||
link_to_help_pop_up = link_to '', '', |
||||
class: 'icon-help1', |
||||
aria: { haspopup: 'true' } |
||||
|
||||
result = ''.html_safe |
||||
render_drop_down_menu_node(link_to_help_pop_up, class: 'drop-down hidden-for-mobile') do |
||||
content_tag :ul, style: 'display:none', class: 'drop-down--help' do |
||||
render_help_and_support result |
||||
render_additional_resources result |
||||
end |
||||
end |
||||
end |
||||
|
||||
private |
||||
|
||||
def render_help_and_support(result) |
||||
result << content_tag(:li) do |
||||
content_tag :span, l('top_menu.help_and_support'), |
||||
class: 'drop-down--help-headline', |
||||
title: l('top_menu.help_and_support') |
||||
end |
||||
result << static_link_item(:user_guides) |
||||
result << static_link_item(:faq) |
||||
result << content_tag(:li) do |
||||
link_to l('homescreen.links.shortcuts'), |
||||
'', |
||||
title: l('homescreen.links.shortcuts'), |
||||
onClick: 'modalHelperInstance.createModal(\'/help/keyboard_shortcuts\');' |
||||
end |
||||
result << static_link_item(:boards) |
||||
result << static_link_item(:professional_support) |
||||
|
||||
end |
||||
|
||||
def render_additional_resources(result) |
||||
result << content_tag(:li) do |
||||
content_tag :span, |
||||
l('top_menu.additional_resources'), |
||||
class: 'drop-down--help-headline', |
||||
title: l('top_menu.additional_resources') |
||||
end |
||||
result << static_link_item(:blog) |
||||
result << static_link_item(:release_notes) |
||||
result << static_link_item(:report_bug) |
||||
result << static_link_item(:roadmap) |
||||
result << static_link_item(:crowdin) |
||||
result << static_link_item(:api_docs) |
||||
end |
||||
|
||||
def static_link_item(key) |
||||
link = OpenProject::Static::Links.links[key] |
||||
label = I18n.t(link[:label]) |
||||
content_tag(:li) do |
||||
link_to label, link[:href], title: label |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,62 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF) |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang |
||||
# Copyright (C) 2010-2013 the ChiliProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License |
||||
# as published by the Free Software Foundation; either version 2 |
||||
# of the License, or (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
# |
||||
# See doc/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
require 'spec_helper' |
||||
|
||||
feature 'Help menu items' do |
||||
let(:user) { FactoryGirl.create :admin } |
||||
let(:help_item) { find('.icon-help1') } |
||||
|
||||
before do |
||||
login_as user |
||||
end |
||||
|
||||
describe 'When force_help_link is not set', js: true do |
||||
it 'renders a dropdown' do |
||||
visit home_path |
||||
|
||||
help_item.click |
||||
expect(page).to have_selector('.drop-down--help li', |
||||
text: I18n.t('homescreen.links.user_guides')) |
||||
end |
||||
end |
||||
|
||||
describe 'When force_help_link is set' do |
||||
let(:custom_url) { 'https://mycustomurl.example.org' } |
||||
before do |
||||
allow(OpenProject::Configuration).to receive(:force_help_link) |
||||
.and_return custom_url |
||||
end |
||||
it 'renders a link' do |
||||
visit home_path |
||||
|
||||
expect(help_item[:href]).to eq(custom_url) |
||||
expect(page).to have_no_selector('.drop-down--help', visible: false) |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue