Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[48251] Implement home URL to be configurable

Oliver Güntherffd0bce35deb
diff --git a/app/helpers/additional_url_helpers.rb b/app/helpers/additional_url_helpers.rb
index 46792c941e3..10d0af25994 100644
--- a/app/helpers/additional_url_helpers.rb
+++ b/app/helpers/additional_url_helpers.rb
@@ -7,6 +7,10 @@ module AdditionalUrlHelpers
home_url(script_name: OpenProject::Configuration.rails_relative_url_root)
end
+ def configurable_home_url
+ Setting.home_url.presence || fixed_home_url
+ end
+
def add_params_to_uri(uri, args = {})
uri = URI.parse uri
query = URI.decode_www_form String(uri.query)
diff --git a/config/constants/settings/definition.rb b/config/constants/settings/definition.rb
index f10fb78713d..bd101a3174c 100644
--- a/config/constants/settings/definition.rb
+++ b/config/constants/settings/definition.rb
@@ -722,6 +722,11 @@ module Settings
default: true,
writable: false
},
+ home_url: {
+ description: 'Override default link when clicking on the top menu logo (Homescreen by default).',
+ format: :string,
+ default: nil
+ },
registration_footer: {
default: {
'en' => ''
diff --git a/lib/redmine/menu_manager/top_menu_helper.rb b/lib/redmine/menu_manager/top_menu_helper.rb
index 37eab683449..75caa269f3f 100644
--- a/lib/redmine/menu_manager/top_menu_helper.rb
+++ b/lib/redmine/menu_manager/top_menu_helper.rb
@@ -45,7 +45,7 @@ module Redmine::MenuManager::TopMenuHelper
def render_top_menu_center
content_tag :div, class: 'op-logo' do
- link_to(I18n.t('label_home'), fixed_home_url, class: 'op-logo--link')
+ link_to(I18n.t('label_home'), configurable_home_url, class: 'op-logo--link')
end
end
diff --git a/spec/helpers/additional_url_helper_spec.rb b/spec/helpers/additional_url_helper_spec.rb
new file mode 100644
index 00000000000..4f497f2d613
--- /dev/null
+++ b/spec/helpers/additional_url_helper_spec.rb
@@ -0,0 +1,47 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 the OpenProject GmbH
+#
+# 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 COPYRIGHT and LICENSE files for more details.
+#++
+
+require 'spec_helper'
+
+describe AdditionalUrlHelpers do
+ describe '#configurable_home_url' do
+ subject { helper.send :configurable_home_url }
+
+ context 'when home_url is defined', with_settings: { home_url: 'https://example.com/foo/bar' } do
+ it 'outputs that' do
+ expect(subject).to eq 'https://example.com/foo/bar'
+ end
+ end
+
+ context 'when home_url is not defined', with_settings: { home_url: nil } do
+ it 'falls back to the default' do
+ expect(subject).to eq 'http://test.host/'
+ end
+ end
+ end
+end