Skip to content

Commit 41ebf2e

Browse files
committed
Fix deprecated *_TABS constant
For Solidus 4.2 and greater, we should be using the `MenuItem` class instead of appending to the deprecated `*_TABS` constant.
1 parent c07dcb5 commit 41ebf2e

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

lib/solidus_volume_pricing/engine.rb

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,25 @@ class Engine < Rails::Engine
1717
end
1818
end
1919

20-
def self.activate
21-
::Spree::BackendConfiguration::CONFIGURATION_TABS << :volume_price_models
20+
if SolidusSupport.backend_available?
21+
initializer 'solidus_volume_pricing.admin_menu_item', after: 'solidus_volume_pricing.preferences' do
22+
Spree::Backend::Config.configure do |config|
23+
settings_menu_item = config.menu_items.detect { |mi| mi.label == :settings }
24+
25+
# The API of the MenuItem class changes in Solidus 4.2.0
26+
if settings_menu_item.respond_to?(:children)
27+
settings_menu_item.children.concat([
28+
Spree::BackendConfiguration::MenuItem.new(
29+
label: :volume_price_models,
30+
url: :admin_volume_price_models_path,
31+
match_path: %r{admin/volume_price_models}
32+
)
33+
])
34+
else
35+
::Spree::BackendConfiguration::CONFIGURATION_TABS << :volume_price_models
36+
end
37+
end
38+
end
2239
end
2340

2441
# use rspec for tests

0 commit comments

Comments
 (0)