From ffe4084b7fb07d84bbb2d1c39653727552580386 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 6 Feb 2025 17:11:37 +1100 Subject: [PATCH] Link to OIDC settings from error message The colour of the link is really bad though. --- app/controllers/admin/dfc_product_imports_controller.rb | 8 ++++++-- config/locales/en.yml | 4 ++-- spec/system/admin/dfc_product_import_spec.rb | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/controllers/admin/dfc_product_imports_controller.rb b/app/controllers/admin/dfc_product_imports_controller.rb index c619adfd7d..ef6f2b0f9a 100644 --- a/app/controllers/admin/dfc_product_imports_controller.rb +++ b/app/controllers/admin/dfc_product_imports_controller.rb @@ -33,8 +33,12 @@ module Admin flash[:error] = e.message redirect_to admin_product_import_path rescue Rack::OAuth2::Client::Error - flash[:error] = t(".connection_invalid") - redirect_to admin_oidc_settings_path + oidc_settings_link = helpers.link_to( + t('spree.admin.tab.oidc_settings'), + admin_oidc_settings_path + ) + flash[:error] = t(".connection_invalid_html", oidc_settings_link:) + redirect_to admin_product_import_path end def import diff --git a/config/locales/en.yml b/config/locales/en.yml index 3ce58b2cb3..37a37c9c91 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -847,9 +847,9 @@ en: map: Map dfc_product_imports: - connection_invalid: | + connection_invalid_html: | Connecting with your OIDC account failed. - Please refresh your OIDC connection. + Please refresh your OIDC connection at: %{oidc_settings_link} index: title: "DFC product catalog" catalog_url: "%{count} products to be imported from: %{catalog_url}" diff --git a/spec/system/admin/dfc_product_import_spec.rb b/spec/system/admin/dfc_product_import_spec.rb index fa157a8df3..1a7393f78c 100644 --- a/spec/system/admin/dfc_product_import_spec.rb +++ b/spec/system/admin/dfc_product_import_spec.rb @@ -132,7 +132,8 @@ RSpec.describe "DFC Product Import" do click_button "Preview" - expect(page).to have_content "OIDC Settings" + expect(page).to have_content "Product Import" expect(page).to have_content "Connecting with your OIDC account failed." + expect(page).to have_content "Please refresh your OIDC connection at: OIDC Settings" end end