<%= you_are_here_info %>
diff --git a/modules/meeting/app/components/banner_message_component.html.erb b/modules/meeting/app/components/banner_message_component.html.erb
new file mode 100644
index 000000000000..f9704a986934
--- /dev/null
+++ b/modules/meeting/app/components/banner_message_component.html.erb
@@ -0,0 +1,32 @@
+<%#-- 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.
+
+++#%>
+
+<%=
+ render(Primer::Alpha::Banner.new(full:, full_when_narrow:, dismiss_scheme:, icon:, scheme:,test_selector:)) { message }
+%>
diff --git a/modules/meeting/app/components/banner_message_component.rb b/modules/meeting/app/components/banner_message_component.rb
new file mode 100644
index 000000000000..0c865f821c5a
--- /dev/null
+++ b/modules/meeting/app/components/banner_message_component.rb
@@ -0,0 +1,44 @@
+#-- 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.
+#++
+
+class BannerMessageComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
+ def initialize(message: nil, full: true, full_when_narrow: false, dismiss_scheme: :hide, icon: false, scheme: :default,
+ test_selector: "primer-banner-message-component")
+ super
+
+ @message = message
+ @full = full
+ @full_when_narrow = full_when_narrow
+ @dismiss_scheme = dismiss_scheme
+ @icon = icon
+ @scheme = scheme
+ @test_selector = test_selector
+ end
+
+ attr_reader :message, :full, :full_when_narrow, :dismiss_scheme, :icon, :scheme, :test_selector
+end
diff --git a/modules/storages/app/controllers/storages/admin/automatically_managed_project_folders_controller.rb b/modules/storages/app/controllers/storages/admin/automatically_managed_project_folders_controller.rb
index 08c6ccabbbcd..a0cd6e738c25 100644
--- a/modules/storages/app/controllers/storages/admin/automatically_managed_project_folders_controller.rb
+++ b/modules/storages/app/controllers/storages/admin/automatically_managed_project_folders_controller.rb
@@ -74,7 +74,10 @@ def create
service_result = call_update_service
if service_result.success?
- flash[:notice] = I18n.t(:'storages.notice_successful_storage_connection')
+ flash[:primer_banner] = {
+ message: I18n.t(:'storages.notice_successful_storage_connection'),
+ scheme: :success
+ }
redirect_to admin_settings_storages_path
else
respond_to do |format|
diff --git a/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb b/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb
index de67ad1a96db..bdb512f35972 100644
--- a/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb
+++ b/modules/storages/app/controllers/storages/admin/oauth_clients_controller.rb
@@ -62,7 +62,7 @@ def new
# Actually create a OAuthClient object.
# Use service pattern to create a new OAuthClient
# Called by: Global app/config/routes.rb to serve Web page
- def create # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
+ def create # rubocop:disable Metrics/AbcSize
call_oauth_clients_create_service
service_result.on_failure do
@@ -77,7 +77,7 @@ def create # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
format.turbo_stream { render :create }
end
elsif @storage.provider_type_one_drive?
- flash[:notice] = I18n.t(:'storages.notice_successful_storage_connection')
+ flash[:primer_banner] = { message: I18n.t(:'storages.notice_successful_storage_connection'), scheme: :success }
redirect_to admin_settings_storages_path
else
raise "Unsupported provider type: #{@storage.short_provider_type}"
diff --git a/modules/storages/app/controllers/storages/admin/storages_controller.rb b/modules/storages/app/controllers/storages/admin/storages_controller.rb
index 6ad24737f62c..3bf99d2784ea 100644
--- a/modules/storages/app/controllers/storages/admin/storages_controller.rb
+++ b/modules/storages/app/controllers/storages/admin/storages_controller.rb
@@ -31,6 +31,7 @@
# Purpose: CRUD the global admin page of Storages (=Nextcloud servers)
class Storages::Admin::StoragesController < ApplicationController
using Storages::Peripherals::ServiceResultRefinements
+ include FlashMessagesHelper
# See https://guides.rubyonrails.org/layouts_and_rendering.html for reference on layout
layout 'admin'
@@ -133,19 +134,14 @@ def edit_host
# Update is similar to create above
# See also: create above
# Called by: Global app/config/routes.rb to serve Web page
- def update # rubocop:disable Metrics/AbcSize
+ def update
service_result = ::Storages::Storages::UpdateService
.new(user: current_user, model: @storage)
.call(permitted_storage_params)
@storage = service_result.result
if service_result.success?
- flash[:notice] = I18n.t(:notice_successful_update)
-
- respond_to do |format|
- format.html { redirect_to edit_admin_settings_storage_path(@storage) }
- format.turbo_stream
- end
+ respond_to { |format| format.turbo_stream }
else
respond_to do |format|
format.html { render :edit }
@@ -159,15 +155,19 @@ def confirm_destroy
end
def destroy
- Storages::Storages::DeleteService
+ service_result = Storages::Storages::DeleteService
.new(user: User.current, model: @storage)
.call
- .match(
- # rubocop:disable Rails/ActionControllerFlashBeforeRender
- on_success: ->(*) { flash[:notice] = I18n.t(:notice_successful_delete) },
- on_failure: ->(error) { flash[:error] = error.full_messages }
- # rubocop:enable Rails/ActionControllerFlashBeforeRender
- )
+
+ # rubocop:disable Rails/ActionControllerFlashBeforeRender
+ service_result.on_failure do
+ flash[:primer_banner] = { message: join_flash_messages(service_result.errors.full_messages), scheme: :danger }
+ end
+
+ service_result.on_success do
+ flash[:primer_banner] = { message: I18n.t(:notice_successful_delete), scheme: :success }
+ end
+ # rubocop:enable Rails/ActionControllerFlashBeforeRender
redirect_to admin_settings_storages_path
end
diff --git a/modules/storages/spec/features/admin_storages_spec.rb b/modules/storages/spec/features/admin_storages_spec.rb
index a13f6b2bc96f..c470062d5571 100644
--- a/modules/storages/spec/features/admin_storages_spec.rb
+++ b/modules/storages/spec/features/admin_storages_spec.rb
@@ -250,8 +250,11 @@
end
expect(page).to have_current_path(admin_settings_storages_path)
- expect(page).to have_text("Storage connected successfully! Remember to activate the module and the specific " \
- "storage in the project settings of each desired project to use it.")
+ expect(page).to have_test_selector(
+ "primer-banner-message-component",
+ text: "Storage connected successfully! Remember to activate the module and the specific " \
+ "storage in the project settings of each desired project to use it."
+ )
end
end
end
@@ -320,8 +323,11 @@
end
expect(page).to have_current_path(admin_settings_storages_path)
- wait_for(page).to have_text("Storage connected successfully! Remember to activate the module and the specific " \
- "storage in the project settings of each desired project to use it.")
+ wait_for(page).to have_test_selector(
+ "primer-banner-message-component",
+ text: "Storage connected successfully! Remember to activate the module and the specific " \
+ "storage in the project settings of each desired project to use it."
+ )
end
end
end
@@ -367,6 +373,7 @@
storage_delete_button.click
expect(page).not_to have_text("Foo Nextcloud")
+ expect(page).to have_text('Successful deletion.')
expect(page).to have_current_path(admin_settings_storages_path)
end