From caf40e7301d510d718712fac5b90a1a6e1b24974 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 12 Feb 2025 11:11:40 +1100 Subject: [PATCH 1/2] Open admin dashboard in same tab by default --- app/views/shared/menu/_signed_in.html.haml | 2 +- app/views/shared/menu/_signed_in_offcanvas.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/shared/menu/_signed_in.html.haml b/app/views/shared/menu/_signed_in.html.haml index 059580c1a2..cfc5b5bd38 100644 --- a/app/views/shared/menu/_signed_in.html.haml +++ b/app/views/shared/menu/_signed_in.html.haml @@ -9,7 +9,7 @@ - if admin_user? or enterprise_user? %li - %a{href: spree.admin_dashboard_path, target:'_blank'} + %a{href: spree.admin_dashboard_path} %i.ofn-i_021-tools = t 'label_administration' diff --git a/app/views/shared/menu/_signed_in_offcanvas.html.haml b/app/views/shared/menu/_signed_in_offcanvas.html.haml index e5ec28bef4..71cf0c8739 100644 --- a/app/views/shared/menu/_signed_in_offcanvas.html.haml +++ b/app/views/shared/menu/_signed_in_offcanvas.html.haml @@ -1,6 +1,6 @@ - if admin_user? or enterprise_user? %li - %a{href: spree.admin_dashboard_path, target:'_blank'} + %a{href: spree.admin_dashboard_path} %i.ofn-i_021-tools = t 'label_admin' From 64a8b5845ac126792a30bdd184ed40c5a89d8487 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 11 Mar 2025 16:38:51 +1100 Subject: [PATCH 2/2] Add feature toggle open_in_same_tab for admin dashboard This allows us to test what users actually want. --- app/helpers/link_helper.rb | 8 ++++++++ app/views/shared/menu/_signed_in.html.haml | 2 +- app/views/shared/menu/_signed_in_offcanvas.html.haml | 2 +- lib/open_food_network/feature_toggle.rb | 3 +++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/helpers/link_helper.rb b/app/helpers/link_helper.rb index 98a0f43e5c..dde2433446 100644 --- a/app/helpers/link_helper.rb +++ b/app/helpers/link_helper.rb @@ -15,4 +15,12 @@ module LinkHelper prefix + url end end + + def new_tab_option + if feature?(:open_in_same_tab, spree_current_user) + {} + else + { target: "_blank" } + end + end end diff --git a/app/views/shared/menu/_signed_in.html.haml b/app/views/shared/menu/_signed_in.html.haml index cfc5b5bd38..8d5fec0fae 100644 --- a/app/views/shared/menu/_signed_in.html.haml +++ b/app/views/shared/menu/_signed_in.html.haml @@ -9,7 +9,7 @@ - if admin_user? or enterprise_user? %li - %a{href: spree.admin_dashboard_path} + %a{href: spree.admin_dashboard_path, **new_tab_option} %i.ofn-i_021-tools = t 'label_administration' diff --git a/app/views/shared/menu/_signed_in_offcanvas.html.haml b/app/views/shared/menu/_signed_in_offcanvas.html.haml index 71cf0c8739..1aa438391b 100644 --- a/app/views/shared/menu/_signed_in_offcanvas.html.haml +++ b/app/views/shared/menu/_signed_in_offcanvas.html.haml @@ -1,6 +1,6 @@ - if admin_user? or enterprise_user? %li - %a{href: spree.admin_dashboard_path} + %a{href: spree.admin_dashboard_path, **new_tab_option} %i.ofn-i_021-tools = t 'label_admin' diff --git a/lib/open_food_network/feature_toggle.rb b/lib/open_food_network/feature_toggle.rb index bac5fa61db..13c07573b2 100644 --- a/lib/open_food_network/feature_toggle.rb +++ b/lib/open_food_network/feature_toggle.rb @@ -58,6 +58,9 @@ module OpenFoodNetwork Activated for a user. The user (INRAE researcher) has access to anonymised sales. DESC + "open_in_same_tab" => <<~DESC, + Open the admin dashboard in the same tab instead of a new tab. + DESC }.merge(conditional_features).freeze; # Features you would like to be enabled to start with.