diff --git a/legacy_promotions/config/locales/en.yml b/legacy_promotions/config/locales/en.yml index 6a6b00b220b..b83109c7def 100644 --- a/legacy_promotions/config/locales/en.yml +++ b/legacy_promotions/config/locales/en.yml @@ -23,8 +23,8 @@ en: general: General starts_at_placeholder: Immediately tab: - promotion_categories: Promotion Categories - promotions: Promotions + promotions: Legacy Promotions + promotion_categories: Legacy Promotion Categories back_to_promotion_categories_list: Back To Promotions Categories List back_to_promotions_list: Back To Promotions List base_amount: Base Amount diff --git a/legacy_promotions/lib/solidus_legacy_promotions/engine.rb b/legacy_promotions/lib/solidus_legacy_promotions/engine.rb index b1526f4eb42..c716ba6693e 100644 --- a/legacy_promotions/lib/solidus_legacy_promotions/engine.rb +++ b/legacy_promotions/lib/solidus_legacy_promotions/engine.rb @@ -22,7 +22,8 @@ class Engine < ::Rails::Engine ), Spree::BackendConfiguration::MenuItem.new( label: :promotion_categories, - condition: -> { can?(:admin, Spree::PromotionCategory) } + condition: -> { can?(:admin, Spree::PromotionCategory) }, + url: -> { Spree::Core::Engine.routes.url_helpers.admin_promotion_categories_path }, ) ] ) diff --git a/promotions/config/locales/en.yml b/promotions/config/locales/en.yml index 19b07d81f2f..06d3f481825 100644 --- a/promotions/config/locales/en.yml +++ b/promotions/config/locales/en.yml @@ -5,10 +5,8 @@ en: spree: admin: tab: - promotions: Promotions - promotion_categories: Promotion Categories - legacy_promotions: Legacy Promotions - legacy_promotion_categories: Legacy Promotion Categories + solidus_promotions: Promotions + solidus_promotion_categories: Promotion Categories hints: solidus_promotions/promotion: expires_at: This determines when the promotion expires.
If no value is specified, the promotion will never expire. diff --git a/promotions/lib/solidus_promotions/engine.rb b/promotions/lib/solidus_promotions/engine.rb index 97330073d1b..4170581ec02 100644 --- a/promotions/lib/solidus_promotions/engine.rb +++ b/promotions/lib/solidus_promotions/engine.rb @@ -62,53 +62,28 @@ class Engine < Rails::Engine initializer "solidus_promotions.add_backend_menus", after: "spree.backend.environment" do if SolidusSupport.backend_available? - # Replace the promotions menu from core with ours - Spree::Backend::Config.configure do |config| - config.menu_items = config.menu_items.flat_map do |item| - next item unless item.label.to_sym == :promotions + promotions_menu_item = Spree::BackendConfiguration::MenuItem.new( + label: :solidus_promotions, + icon: Spree::Backend::Config.admin_updated_navbar ? "ri-megaphone-line" : "bullhorn", + condition: -> { can?(:admin, SolidusPromotions::Promotion) }, + url: -> { SolidusPromotions::Engine.routes.url_helpers.admin_promotions_path }, + data_hook: :admin_solidus_promotion_sub_tabs, + children: [ + Spree::BackendConfiguration::MenuItem.new( + label: :solidus_promotions, + url: -> { SolidusPromotions::Engine.routes.url_helpers.admin_promotions_path }, + condition: -> { can?(:admin, SolidusPromotions::Promotion) } + ), + Spree::BackendConfiguration::MenuItem.new( + label: :solidus_promotion_categories, + url: -> { SolidusPromotions::Engine.routes.url_helpers.admin_promotion_categories_path }, + condition: -> { can?(:admin, SolidusPromotions::PromotionCategory) } + ) + ] + ) - [ - Spree::BackendConfiguration::MenuItem.new( - label: :promotions, - icon: config.admin_updated_navbar ? "ri-megaphone-line" : "bullhorn", - condition: -> { can?(:admin, SolidusPromotions::Promotion) }, - url: -> { SolidusPromotions::Engine.routes.url_helpers.admin_promotions_path }, - data_hook: :admin_solidus_promotion_sub_tabs, - children: [ - Spree::BackendConfiguration::MenuItem.new( - label: :promotions, - url: -> { SolidusPromotions::Engine.routes.url_helpers.admin_promotions_path }, - condition: -> { can?(:admin, SolidusPromotions::Promotion) } - ), - Spree::BackendConfiguration::MenuItem.new( - label: :promotion_categories, - url: -> { SolidusPromotions::Engine.routes.url_helpers.admin_promotion_categories_path }, - condition: -> { can?(:admin, SolidusPromotions::PromotionCategory) } - ) - ] - ), - Spree::BackendConfiguration::MenuItem.new( - label: :legacy_promotions, - icon: config.admin_updated_navbar ? "ri-megaphone-line" : "bullhorn", - condition: -> { can?(:admin, SolidusPromotions::Promotion) }, - url: -> { Spree::Core::Engine.routes.url_helpers.admin_promotions_path }, - data_hook: :admin_promotion_sub_tabs, - children: [ - Spree::BackendConfiguration::MenuItem.new( - label: :legacy_promotions, - condition: -> { can?(:admin, Spree::Promotion && Spree::Promotion.any?) }, - url: -> { Spree::Core::Engine.routes.url_helpers.admin_promotions_path }, - ), - Spree::BackendConfiguration::MenuItem.new( - label: :legacy_promotion_categories, - condition: -> { can?(:admin, Spree::PromotionCategory && Spree::Promotion.any?) }, - url: -> { Spree::Core::Engine.routes.url_helpers.admin_promotion_categories_path }, - ) - ] - ) - ] - end - end + product_menu_item_index = Spree::Backend::Config.menu_items.find_index { |item| item.label == :products } + Spree::Backend::Config.menu_items.insert(product_menu_item_index + 1, promotions_menu_item) end end end