Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better promotion menus #5934

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Feat(SolidusPromotions): Allow viewing both promotion systems
Prior to this commit, the new promotion system would exchange the
promotion and promotion category index page components if the gem was
loaded. This made it impossible to actually see the old promotion
configuration when using the new admin.

This commit now only changes the orders/index component if the new
promotion system is activated. In any case, it will display new
promotion and promotion category records under "Promotions (new)".
  • Loading branch information
mamhoff committed Nov 18, 2024
commit 0a69b6a8625e20215731e5ff4e4792393999606d
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def index
set_page_and_extract_portion_from(promotion_categories)

respond_to do |format|
format.html { render component("promotion_categories/index").new(page: @page) }
format.html { render component("solidus_promotions/categories/index").new(page: @page) }
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def index
set_page_and_extract_portion_from(promotions)

respond_to do |format|
format.html { render component("promotions/index").new(page: @page) }
format.html { render component("solidus_promotions/promotions/index").new(page: @page) }
end
end

Expand Down
11 changes: 7 additions & 4 deletions promotions/lib/solidus_promotions/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ class Engine < Rails::Engine
end
end

initializer "solidus_promotions.add_admin_order_index_component", after: "solidus_legacy_promotions.add_admin_order_index_component" do
initializer "solidus_promotions.add_admin_order_index_component", after: "spree.load_config_initializers" do
if SolidusSupport.admin_available?
SolidusAdmin::Config.components["orders/index"] = "SolidusPromotions::Orders::Index::Component"
SolidusAdmin::Config.components["promotions/index"] = "SolidusPromotions::Promotions::Index::Component"
SolidusAdmin::Config.components["promotion_categories/index"] = "SolidusPromotions::PromotionCategories::Index::Component"
if Spree::Config.promotions.is_a?(SolidusPromotions::Configuration)
SolidusAdmin::Config.components["orders/index"] = "SolidusPromotions::Orders::Index::Component"
end

SolidusAdmin::Config.components["solidus_promotions/promotions/index"] = "SolidusPromotions::Promotions::Index::Component"
SolidusAdmin::Config.components["solidus_promotions/categories/index"] = "SolidusPromotions::PromotionCategories::Index::Component"
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

before { sign_in create(:admin_user, email: "[email protected]") }

around do |example|
SolidusAdmin::Config.components["orders/index"] = "SolidusPromotions::Orders::Index::Component"
example.run
SolidusAdmin::Config.components["orders/index"] = "SolidusAdmin::Orders::Index::Component"
end

it "lists products", :js, :flaky do
visit "/admin/orders"

Expand Down