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

feat[Op#50985]: Use Primer Flash for Administration settings with Primer

Kabiru Mwenja5c678e350b0e
diff --git a/modules/meeting/app/components/flash_message_component.rb b/modules/meeting/app/components/flash_message_component.rb
index bddfb6cc9fe..0431be865f2 100644
--- a/modules/meeting/app/components/flash_message_component.rb
+++ b/modules/meeting/app/components/flash_message_component.rb
@@ -31,7 +31,8 @@ class FlashMessageComponent < ApplicationComponent
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers
- def initialize(message: nil, full: false, spacious: false, dismissible: false, icon: nil, scheme: :default)
+ def initialize(message: nil, full: false, spacious: false, dismissible: false, icon: nil, scheme: :default,
+ test_selector: "primer-flash-message-component")
super
@message = message
@@ -40,6 +41,7 @@ class FlashMessageComponent < ApplicationComponent
@dismissible = dismissible # TODO: not working yet -> JS dependency not provided?
@icon = icon
@scheme = scheme
+ @test_selector = test_selector
end
def call
@@ -56,7 +58,8 @@ class FlashMessageComponent < ApplicationComponent
def flash_partial
render(Primer::Beta::Flash.new(
- full: @full, spacious: @spacious, dismissible: @dismissible, icon: @icon, scheme: @scheme
+ full: @full, spacious: @spacious, dismissible: @dismissible, icon: @icon, scheme: @scheme,
+ test_selector: @test_selector
)) { @message }
end
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 08c6ccabbbc..9fe01f4ebae 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,12 @@ class Storages::Admin::AutomaticallyManagedProjectFoldersController < Applicatio
service_result = call_update_service
if service_result.success?
- flash[:notice] = I18n.t(:'storages.notice_successful_storage_connection')
+ flash[:primer_flash] = {
+ message: I18n.t(:'storages.notice_successful_storage_connection'),
+ scheme: :success,
+ dismissible: true,
+ full: true
+ }
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 de67ad1a96d..a0ea23dce9b 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 @@ class Storages::Admin::OAuthClientsController < ApplicationController
# 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,12 @@ class Storages::Admin::OAuthClientsController < ApplicationController
format.turbo_stream { render :create }
end
elsif @storage.provider_type_one_drive?
- flash[:notice] = I18n.t(:'storages.notice_successful_storage_connection')
+ flash[:primer_flash] = {
+ message: I18n.t(:'storages.notice_successful_storage_connection'),
+ scheme: :success,
+ dismissible: true,
+ full: true
+ }
redirect_to admin_settings_storages_path
else
raise "Unsupported provider type: #{@storage.short_provider_type}"
diff --git a/modules/storages/spec/features/admin_storages_spec.rb b/modules/storages/spec/features/admin_storages_spec.rb
index a13f6b2bc96..f68936d8a97 100644
--- a/modules/storages/spec/features/admin_storages_spec.rb
+++ b/modules/storages/spec/features/admin_storages_spec.rb
@@ -250,8 +250,11 @@ RSpec.describe 'Admin storages',
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-flash-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 @@ RSpec.describe 'Admin storages',
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-flash-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