From 46e8250f7ef5bcf664ffa8db752a17cfc370f340 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Fri, 15 Nov 2024 13:11:16 +0100 Subject: [PATCH 1/4] Fix component translation scopes In the `view_component` gem, the `i18n_scope` for a component depends on the file name of the component, and removes `app_components` and everything before that in order to construct a scope. This fails to work with components that live in `lib/components/admin/`, as with our extensions, as there is no `app/components` in the path to these components. This change uses the class name instead, which should be easier on memory and correctly works with components from solidus extensions. This also fixes translations in inherited components, allowing to delete some redundant translations in the promotion gem's `order` component. --- .../components/solidus_admin/base_component.rb | 4 ++++ .../orders/index/component.yml | 15 --------------- .../solidus_promotions/orders/index/component.yml | 2 ++ 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/admin/app/components/solidus_admin/base_component.rb b/admin/app/components/solidus_admin/base_component.rb index 7bfe1b52852..e41e65235cf 100644 --- a/admin/app/components/solidus_admin/base_component.rb +++ b/admin/app/components/solidus_admin/base_component.rb @@ -25,6 +25,10 @@ def missing_translation(key, options) end end + def self.i18n_scope + @i18n_scope ||= name.underscore.tr("/", ".") + end + def self.stimulus_id @stimulus_id ||= name.underscore .sub(/^solidus_admin\/(.*)\/component$/, '\1') diff --git a/legacy_promotions/lib/components/admin/solidus_legacy_promotions/orders/index/component.yml b/legacy_promotions/lib/components/admin/solidus_legacy_promotions/orders/index/component.yml index 454b31bbdb7..3829db2d825 100644 --- a/legacy_promotions/lib/components/admin/solidus_legacy_promotions/orders/index/component.yml +++ b/legacy_promotions/lib/components/admin/solidus_legacy_promotions/orders/index/component.yml @@ -1,20 +1,5 @@ en: - columns: - items: - one: 1 Item - other: '%{count} Items' filters: - status: Status - shipment_state: Shipment State - payment_state: Payment State promotions: Promotions - date: - formats: - short: '%d %b %y' scopes: - all_orders: All - canceled: Canceled - complete: Complete - returned: Returned - in_progress: In Progress promotions: Promotions diff --git a/promotions/lib/components/admin/solidus_promotions/orders/index/component.yml b/promotions/lib/components/admin/solidus_promotions/orders/index/component.yml index 95af3f495d4..3829db2d825 100644 --- a/promotions/lib/components/admin/solidus_promotions/orders/index/component.yml +++ b/promotions/lib/components/admin/solidus_promotions/orders/index/component.yml @@ -1,3 +1,5 @@ en: filters: promotions: Promotions + scopes: + promotions: Promotions From f4d24f2d91241d55e89d238f21ed7b3c8706eec4 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Fri, 15 Nov 2024 13:26:33 +0100 Subject: [PATCH 2/4] Only set promo configuration to legacy if no other set This sets the promotion configuration to the legacy promotion system if no other promotion system, like `solidus_promotion` has been configured in the `spree` initializer. This should get rid of errors people encounter when trying to use `solidus_promotions`, but the system being reconfigured without their intervention to use the legacy system. --- .../lib/solidus_legacy_promotions/engine.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/legacy_promotions/lib/solidus_legacy_promotions/engine.rb b/legacy_promotions/lib/solidus_legacy_promotions/engine.rb index b1526f4eb42..a0e0b939282 100644 --- a/legacy_promotions/lib/solidus_legacy_promotions/engine.rb +++ b/legacy_promotions/lib/solidus_legacy_promotions/engine.rb @@ -86,12 +86,17 @@ class Engine < ::Rails::Engine end initializer "solidus_legacy_promotions", after: "spree.load_config_initializers" do - Spree::Config.order_contents_class = "Spree::OrderContents" - Spree::Config.promotions = SolidusLegacyPromotions::Configuration.new - Spree::Config.adjustment_promotion_source_types << "Spree::PromotionAction" + # Only set these if there is no promotion configuration set. In this case, + # we're running on a store without the new `solidus_promotions` gem and we + # need to set the configuration to the legacy one. + if Spree::Config.promotions.is_a?(Spree::Core::NullPromotionConfiguration) + Spree::Config.order_contents_class = "Spree::OrderContents" + Spree::Config.promotions = SolidusLegacyPromotions::Configuration.new + end Spree::Api::Config.adjustment_attributes << :promotion_code_id Spree::Api::Config.adjustment_attributes << :eligible + Spree::Config.adjustment_promotion_source_types << "Spree::PromotionAction" end end end From 4acd2302d92dc968a8b7737ffb5cf13496b93300 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Fri, 15 Nov 2024 15:44:43 +0100 Subject: [PATCH 3/4] chore(github labeler): Add labels for new promotion gems We released two new gems and need the appropriate labels for the pull request reviews. --- .github/labeler.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/labeler.yml b/.github/labeler.yml index e7f0f9028d2..0b59473b94a 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -18,6 +18,16 @@ - changed-files: - any-glob-to-any-file: - "admin/**/*" +"changelog:solidus_promotions": +- any: + - changed-files: + - any-glob-to-any-file: + - "promotions/**/*" +"changelog:solidus_legacy_promotions": +- any: + - changed-files: + - any-glob-to-any-file: + - "legacy_promotions/**/*" "changelog:solidus_sample": - any: - changed-files: @@ -40,6 +50,8 @@ - "!backend/**/*" - "!api/**/*" - "!admin/**/*" + - "!promotions/**/*" + - "!legacy_promotions/**/*" - "!sample/**/*" - "!lib/**/*" - "!README.md" From 21bb8373177bb88eddcb12cac6249280836122e1 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Fri, 15 Nov 2024 21:30:12 +0100 Subject: [PATCH 4/4] Use new global variables stylesheet in legacy promotions Prior to this change, the promotion admin would have a blue color scheme, and not the red one that all the other pages have. --- .../stylesheets/solidus_legacy_promotions/promotions.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/legacy_promotions/app/assets/stylesheets/solidus_legacy_promotions/promotions.scss b/legacy_promotions/app/assets/stylesheets/solidus_legacy_promotions/promotions.scss index eee8b872043..4a37ef631b1 100644 --- a/legacy_promotions/app/assets/stylesheets/solidus_legacy_promotions/promotions.scss +++ b/legacy_promotions/app/assets/stylesheets/solidus_legacy_promotions/promotions.scss @@ -1,3 +1,3 @@ -@import "spree/backend/themes/classic"; +@import "spree/backend/globals/variables"; @import "solidus_legacy_promotions/promotions/edit";