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

Remove ApplicationComponentStreams

Oliver Günthere2e90f0fba03
diff --git a/modules/meeting/app/components/banner_message_component.html.erb b/app/components/op_primer/banner_message_component.html.erb
similarity index 100%
rename from modules/meeting/app/components/banner_message_component.html.erb
rename to app/components/op_primer/banner_message_component.html.erb
diff --git a/modules/meeting/app/controllers/concerns/application_component_streams.rb b/app/components/op_primer/banner_message_component.rb
similarity index 74%
rename from modules/meeting/app/controllers/concerns/application_component_streams.rb
rename to app/components/op_primer/banner_message_component.rb
index 50fa9caae01..82685bb4231 100644
--- a/modules/meeting/app/controllers/concerns/application_component_streams.rb
+++ b/app/components/op_primer/banner_message_component.rb
@@ -26,16 +26,18 @@
# See COPYRIGHT and LICENSE files for more details.
#++
-module ApplicationComponentStreams
- extend ActiveSupport::Concern
+module OpPrimer
+ class BannerMessageComponent < Primer::Alpha::Banner
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
- included do
- def render_error_flash_message_via_turbo_stream(**kwargs)
- update_flash_message_via_turbo_stream(**kwargs.merge(scheme: :danger, icon: :stop))
- end
+ def initialize(**system_arguments)
+ system_arguments[:test_selector] ||= "primer-banner-message-component"
+ system_arguments[:dismiss_scheme] ||= :remove
+ system_arguments[:dismiss_label] ||= I18n.t(:button_close)
- def update_flash_message_via_turbo_stream(**)
- turbo_streams << turbo_stream.prepend("flash-container", Meetings::UpdateFlashComponent.new(**).render_in(view_context))
+ super
end
end
end
diff --git a/app/controllers/admin/custom_fields/custom_field_projects_controller.rb b/app/controllers/admin/custom_fields/custom_field_projects_controller.rb
index da1767f0438..8f69e323e74 100644
--- a/app/controllers/admin/custom_fields/custom_field_projects_controller.rb
+++ b/app/controllers/admin/custom_fields/custom_field_projects_controller.rb
@@ -31,7 +31,6 @@
class Admin::CustomFields::CustomFieldProjectsController < ApplicationController
include OpTurbo::ComponentStream
include OpTurbo::DialogStreamHelper
- include ApplicationComponentStreams
include FlashMessagesOutputSafetyHelper
layout "admin"
diff --git a/app/controllers/admin/settings/project_custom_fields_controller.rb b/app/controllers/admin/settings/project_custom_fields_controller.rb
index e8ba9ceb344..b532962b12f 100644
--- a/app/controllers/admin/settings/project_custom_fields_controller.rb
+++ b/app/controllers/admin/settings/project_custom_fields_controller.rb
@@ -31,7 +31,6 @@ module Admin::Settings
include CustomFields::SharedActions
include OpTurbo::ComponentStream
include OpTurbo::DialogStreamHelper
- include ApplicationComponentStreams
include FlashMessagesOutputSafetyHelper
include Admin::Settings::ProjectCustomFields::ComponentStreams
diff --git a/app/controllers/concerns/op_turbo/component_stream.rb b/app/controllers/concerns/op_turbo/component_stream.rb
index 88fbf6f9abd..23dd63c9457 100644
--- a/app/controllers/concerns/op_turbo/component_stream.rb
+++ b/app/controllers/concerns/op_turbo/component_stream.rb
@@ -73,6 +73,14 @@ module OpTurbo
turbo_streams << target_component.insert_as_turbo_stream(component:, view_context:, action: :before)
end
+ def render_error_flash_message_via_turbo_stream(**kwargs)
+ update_flash_message_via_turbo_stream(**kwargs.merge(scheme: :danger, icon: :stop))
+ end
+
+ def update_flash_message_via_turbo_stream(component: OpPrimer::BannerMessageComponent, **)
+ turbo_streams << component.new(**).render_as_turbo_stream(view_context:, action: :flash)
+ end
+
def turbo_streams
@turbo_streams ||= []
end
diff --git a/lookbook/previews/open_project/common/flash_preview.rb b/lookbook/previews/open_project/common/flash_preview.rb
index 82605c4f69b..e926fc68980 100644
--- a/lookbook/previews/open_project/common/flash_preview.rb
+++ b/lookbook/previews/open_project/common/flash_preview.rb
@@ -3,31 +3,26 @@ module OpenProject
# @hidden
class FlashPreview < Lookbook::Preview
def default
- render(Meetings::UpdateFlashComponent.new(
- button_path_object: @meeting,
- message: I18n.t("notice_meeting_updated")
- ))
+ render(OpPrimer::BannerMessageComponent.new) do |_component|
+ I18n.t("notice_meeting_updated")
+ end
end
def danger
- render(Meetings::UpdateFlashComponent.new(
- button_path_object: @meeting,
- message: I18n.t("notice_meeting_updated"),
- scheme: :danger,
- icon: :stop
- ))
+ render(OpPrimer::BannerMessageComponent.new(scheme: :danger, icon: :stop)) do |_component|
+ "Stop right there."
+ end
end
def button
- render(Meetings::UpdateFlashComponent.new(
- button_path_object: @meeting,
- message: I18n.t("notice_meeting_updated"),
- scheme: :success,
- icon: :check,
- button: true,
- button_message: I18n.t("label_meeting_reload")
- # button_path_object: # TODO
- ))
+ render(OpPrimer::BannerMessageComponent.new) do |component|
+ component.with_action_button(
+ tag: :a,
+ href: "/"
+ ) { "Go home" }
+
+ I18n.t("notice_meeting_updated")
+ end
end
end
end
diff --git a/modules/meeting/app/components/banner_message_component.rb b/modules/meeting/app/components/banner_message_component.rb
deleted file mode 100644
index d4d61a53cf0..00000000000
--- a/modules/meeting/app/components/banner_message_component.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 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.
-#++
-
-class BannerMessageComponent < Primer::Alpha::Banner
- include ApplicationHelper
- include OpTurbo::Streamable
- include OpPrimer::ComponentHelpers
-
- def initialize(**system_arguments)
- system_arguments[:test_selector] ||= "primer-banner-message-component"
- system_arguments[:dismiss_scheme] ||= :remove
- system_arguments[:dismiss_label] ||= I18n.t(:button_close)
-
- super
- end
-end
diff --git a/modules/meeting/app/components/meetings/update_flash_component.html.erb b/modules/meeting/app/components/meetings/update_flash_component.html.erb
deleted file mode 100644
index 447927b419f..00000000000
--- a/modules/meeting/app/components/meetings/update_flash_component.html.erb
+++ /dev/null
@@ -1,19 +0,0 @@
-<div class="op-primer-banner--item">
- <%=
- render(Primer::Alpha::Banner.new(
- full: false,
- icon: :info,
- scheme: :default,
- data: {
- singleton: true
- }
- )) do |component|
- component.with_action_button(
- tag: :a,
- href: meeting_path(@meeting),
- data: { turbo: false },
- size: :medium) { I18n.t("label_meeting_reload") }
- I18n.t("notice_meeting_updated")
- end
- %>
-</div>
diff --git a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
index 963e7f28ff3..415e0275a9f 100644
--- a/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
+++ b/modules/meeting/app/controllers/meeting_agenda_items_controller.rb
@@ -30,7 +30,6 @@ class MeetingAgendaItemsController < ApplicationController
include AttachableServiceCall
include OpTurbo::ComponentStream
include Meetings::AgendaComponentStreams
- include ApplicationComponentStreams
before_action :set_meeting
before_action :set_agenda_item_type, only: %i[new create]
diff --git a/modules/meeting/app/controllers/meeting_sections_controller.rb b/modules/meeting/app/controllers/meeting_sections_controller.rb
index b9af976ef1d..e4356904c0a 100644
--- a/modules/meeting/app/controllers/meeting_sections_controller.rb
+++ b/modules/meeting/app/controllers/meeting_sections_controller.rb
@@ -30,7 +30,6 @@ class MeetingSectionsController < ApplicationController
include AttachableServiceCall
include OpTurbo::ComponentStream
include Meetings::AgendaComponentStreams
- include ApplicationComponentStreams
before_action :set_meeting
before_action :set_meeting_section,
diff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rb
index c8bf2a0a4fa..c83418b239c 100644
--- a/modules/meeting/app/controllers/meetings_controller.rb
+++ b/modules/meeting/app/controllers/meetings_controller.rb
@@ -50,7 +50,6 @@ class MeetingsController < ApplicationController
include OpTurbo::ComponentStream
include OpTurbo::FlashStreamHelper
- include ApplicationComponentStreams
include Meetings::AgendaComponentStreams
include MetaTagsHelper
@@ -79,12 +78,7 @@ class MeetingsController < ApplicationController
if params[:reference] == @meeting.changed_hash
head :no_content
else
- respond_with_flash(Meetings::UpdateFlashComponent.new(
- button_path_object: @meeting,
- message: I18n.t("notice_meeting_updated"),
- button: true,
- button_message: I18n.t("label_meeting_reload")
- ))
+ respond_with_flash(Meetings::UpdateFlashComponent.new(@meeting))
end
end
diff --git a/modules/storages/app/controllers/storages/admin/storages/project_storages_controller.rb b/modules/storages/app/controllers/storages/admin/storages/project_storages_controller.rb
index a69bc0028e7..3e842e26be0 100644
--- a/modules/storages/app/controllers/storages/admin/storages/project_storages_controller.rb
+++ b/modules/storages/app/controllers/storages/admin/storages/project_storages_controller.rb
@@ -32,7 +32,6 @@ class Storages::Admin::Storages::ProjectStoragesController < ApplicationControll
include OpTurbo::ComponentStream
include OpTurbo::DialogStreamHelper
include FlashMessagesOutputSafetyHelper
- include ApplicationComponentStreams
include Storages::OAuthAccessGrantable
layout "admin"