Skip to content

Commit

Permalink
tmp: wip: fix promotions menu item
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdeyen committed Nov 14, 2024
1 parent 79b0511 commit e10da0d
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions promotions/lib/solidus_promotions/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,29 +64,32 @@ class Engine < Rails::Engine
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
config.menu_items.insert(
3,
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: :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) }
)
]
),
if defined?(Spree::Promotion)
config.menu_items.insert(
3,
Spree::BackendConfiguration::MenuItem.new(
label: :legacy_promotions,
icon: config.admin_updated_navbar ? "ri-megaphone-line" : "bullhorn",
Expand All @@ -106,7 +109,7 @@ class Engine < Rails::Engine
)
]
)
]
)
end
end
end
Expand Down

0 comments on commit e10da0d

Please sign in to comment.