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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add new flash stream action
Oliver Günther10386769b202
diff --git a/app/components/concerns/op_turbo/streamable.rb b/app/components/concerns/op_turbo/streamable.rbindex 000bdc1088c..66c22ed5060 100644--- a/app/components/concerns/op_turbo/streamable.rb+++ b/app/components/concerns/op_turbo/streamable.rb@@ -43,7 +43,7 @@ module OpTurboincluded dodef render_as_turbo_stream(view_context:, action: :update)case action- when :update, :dialog+ when :update, *inline_actions@inner_html_only = truetemplate = render_in(view_context)when :replace@@ -56,7 +56,7 @@ module OpTurboraise ArgumentError, "Unsupported action #{action}"end- if action != :dialog && !wrapped?+ if inline_actions.exclude?(action) && !wrapped?raise MissingComponentWrapper,"Wrap your component in a `component_wrapper` block in order to use turbo-stream methods"end@@ -100,6 +100,10 @@ module OpTurboendend+ def inline_actions+ %i[dialog flash]+ end+def wrapped?!!@wrappedenddiff --git a/app/controllers/concerns/op_turbo/flash_stream_helper.rb b/app/controllers/concerns/op_turbo/flash_stream_helper.rbnew file mode 100644index 00000000000..fa743e4e376--- /dev/null+++ b/app/controllers/concerns/op_turbo/flash_stream_helper.rb@@ -0,0 +1,41 @@+#-- 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 OpTurbo+ module FlashStreamHelper+ def respond_with_flash(flash_component, status: :ok, &format_block)+ respond_to do |format|+ format.turbo_stream do+ render turbo_stream: flash_component.render_as_turbo_stream(view_context:, action: :flash), status:+ end++ yield(format) if format_block+ end+ end+ end+enddiff --git a/config/initializers/turbo_stream_actions.rb b/config/initializers/turbo_stream_actions.rbindex 22f8bacc9c7..6dbafe6e36e 100644--- a/config/initializers/turbo_stream_actions.rb+++ b/config/initializers/turbo_stream_actions.rb@@ -2,4 +2,8 @@ ActiveSupport.on_load :turbo_streams_tag_builder dodef dialog(&)action(:dialog, nil, &)end++ def flash(&)+ action(:flash, nil, &)+ endenddiff --git a/modules/meeting/app/components/meetings/update_flash_component.html.erb b/modules/meeting/app/components/meetings/update_flash_component.html.erbnew file mode 100644index 00000000000..9902f60371d--- /dev/null+++ b/modules/meeting/app/components/meetings/update_flash_component.html.erb@@ -0,0 +1,6 @@+<%= render(Primer::Alpha::Banner.new(full: false, icon: 'info', scheme: :default)) do |component| %>+ <% component.with_action_button(+ src: meeting_path(@meeting),+ size: :medium) { "Reload page" } %>+ You really need to update this upage+<% end %>diff --git a/modules/meeting/app/components/meetings/update_flash_component.rb b/modules/meeting/app/components/meetings/update_flash_component.rbnew file mode 100644index 00000000000..72f98bf8e19--- /dev/null+++ b/modules/meeting/app/components/meetings/update_flash_component.rb@@ -0,0 +1,41 @@+#-- 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 Meetings+ class UpdateFlashComponent < ApplicationComponent+ include ApplicationHelper+ include OpTurbo::Streamable+ include OpPrimer::ComponentHelpers++ def initialize(meeting:)+ super++ @meeting = meeting+ end+ end+end