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

refactor[Op#55133]: Reduce fingerprint in FlashMessagesHelper mixin

Kabiru Mwenja1e03bb1be2c6
diff --git a/app/controllers/admin/settings/project_custom_fields_controller.rb b/app/controllers/admin/settings/project_custom_fields_controller.rb
index f6c2984df9c..f2adb901acd 100644
--- a/app/controllers/admin/settings/project_custom_fields_controller.rb
+++ b/app/controllers/admin/settings/project_custom_fields_controller.rb
@@ -31,7 +31,7 @@ module Admin::Settings
include CustomFields::SharedActions
include OpTurbo::ComponentStream
include ApplicationComponentStreams
- include FlashMessagesHelper
+ include FlashMessagesOutputSafetyHelper
include Admin::Settings::ProjectCustomFields::ComponentStreams
menu_item :project_custom_fields_settings
diff --git a/app/helpers/flash_messages_helper.rb b/app/helpers/flash_messages_helper.rb
index 47c7f190110..889111e5142 100644
--- a/app/helpers/flash_messages_helper.rb
+++ b/app/helpers/flash_messages_helper.rb
@@ -31,8 +31,7 @@ module FlashMessagesHelper
extend ActiveSupport::Concern
included do
- # For .safe_join in join_flash_messages
- include ActionView::Helpers::OutputSafetyHelper
+ include FlashMessagesOutputSafetyHelper
end
def render_primer_banner_message?
@@ -68,14 +67,6 @@ module FlashMessagesHelper
safe_join messages, "\n"
end
- def join_flash_messages(messages)
- if messages.respond_to?(:join)
- safe_join(messages, "<br />".html_safe)
- else
- messages
- end
- end
-
def render_flash_message(type, message, html_options = {}) # rubocop:disable Metrics/AbcSize
if type.to_s == "notice"
type = "success"
diff --git a/app/helpers/flash_messages_output_helper.rb b/app/helpers/flash_messages_output_helper.rb
new file mode 100644
index 00000000000..56307941979
--- /dev/null
+++ b/app/helpers/flash_messages_output_helper.rb
@@ -0,0 +1,45 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2024 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.
+#++
+#
+
+module FlashMessagesOutputSafetyHelper
+ extend ActiveSupport::Concern
+
+ included do
+ # For .safe_join in join_flash_messages
+ include ActionView::Helpers::OutputSafetyHelper
+ end
+
+ def join_flash_messages(messages)
+ if messages.respond_to?(:join)
+ safe_join(messages, "<br />".html_safe)
+ else
+ messages
+ end
+ end
+end
diff --git a/modules/storages/app/controllers/storages/admin/storages_controller.rb b/modules/storages/app/controllers/storages/admin/storages_controller.rb
index 7c7983b3d81..bacb294a174 100644
--- a/modules/storages/app/controllers/storages/admin/storages_controller.rb
+++ b/modules/storages/app/controllers/storages/admin/storages_controller.rb
@@ -32,7 +32,7 @@
class Storages::Admin::StoragesController < ApplicationController
using Storages::Peripherals::ServiceResultRefinements
- include FlashMessagesHelper
+ include FlashMessagesOutputSafetyHelper
include OpTurbo::ComponentStream
# See https://guides.rubyonrails.org/layouts_and_rendering.html for reference on layout