From f4f7420ac33d09583316a1a3f03d65c1e1bf3621 Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Thu, 18 Apr 2024 12:40:48 +0200 Subject: [PATCH 1/2] Move backend controllers and views to lib/ This allows us to keep the backend controllers out of the autoloaded `app` directory, which in turn allows us to ditch the direct dependency on solidus_backend. We do, however, load it still, just ignore it if it's not available. --- Gemfile | 1 + legacy_promotions/config/routes.rb | 22 ++++++++++--------- .../admin/promotion_actions_controller.rb | 0 .../admin/promotion_categories_controller.rb | 0 .../promotion_code_batches_controller.rb | 0 .../spree/admin/promotion_codes_controller.rb | 0 .../spree/admin/promotion_rules_controller.rb | 0 .../spree/admin/promotions_controller.rb | 0 .../lib/solidus_legacy_promotions.rb | 15 +++++++++---- .../admin/promotion_actions/create.js.erb | 0 .../admin/promotion_actions/destroy.js.erb | 0 .../admin/promotion_categories/_form.html.erb | 0 .../admin/promotion_categories/edit.html.erb | 0 .../admin/promotion_categories/index.html.erb | 0 .../admin/promotion_categories/new.html.erb | 0 .../_form_fields.html.erb | 0 .../promotion_code_batches/download.csv.ruby | 0 .../promotion_code_batches/index.html.erb | 0 .../admin/promotion_code_batches/new.html.erb | 0 .../admin/promotion_codes/index.csv.ruby | 0 .../admin/promotion_codes/index.html.erb | 0 .../spree/admin/promotion_codes/new.html.erb | 0 .../spree/admin/promotion_rules/create.js.erb | 0 .../admin/promotion_rules/destroy.js.erb | 0 .../spree/admin/promotions/_actions.html.erb | 0 .../promotions/_activations_edit.html.erb | 0 .../promotions/_activations_new.html.erb | 0 .../spree/admin/promotions/_form.html.erb | 0 .../promotions/_promotion_action.html.erb | 0 .../admin/promotions/_promotion_rule.html.erb | 0 .../spree/admin/promotions/_rules.html.erb | 0 .../actions/_create_adjustment.html.erb | 0 .../actions/_create_item_adjustments.html.erb | 0 .../_create_quantity_adjustments.html.erb | 0 .../actions/_free_shipping.html.erb | 0 ...on_calculators_with_custom_fields.html.erb | 0 .../calculators/_default_fields.html.erb | 0 .../distributed_amount/_fields.html.erb | 0 .../calculators/flat_rate/_fields.html.erb | 0 .../tiered_flat_rate/_fields.html.erb | 0 .../tiered_percent/_fields.html.erb | 0 .../spree/admin/promotions/edit.html.erb | 0 .../spree/admin/promotions/index.html.erb | 0 .../spree/admin/promotions/new.html.erb | 0 .../promotions/rules/_first_order.html.erb | 0 .../_first_repeat_purchase_since.html.erb | 0 .../promotions/rules/_item_total.html.erb | 0 .../rules/_minimum_quantity.html.erb | 0 .../promotions/rules/_nth_order.html.erb | 0 .../rules/_one_use_per_user.html.erb | 0 .../promotions/rules/_option_value.html.erb | 0 .../admin/promotions/rules/_product.html.erb | 0 .../admin/promotions/rules/_store.html.erb | 0 .../admin/promotions/rules/_taxon.html.erb | 0 .../admin/promotions/rules/_user.html.erb | 0 .../promotions/rules/_user_logged_in.html.erb | 0 .../promotions/rules/_user_role.html.erb | 0 .../solidus_legacy_promotions.gemspec | 1 - 58 files changed, 24 insertions(+), 15 deletions(-) rename legacy_promotions/{app/controllers => lib/controllers/backend}/spree/admin/promotion_actions_controller.rb (100%) rename legacy_promotions/{app/controllers => lib/controllers/backend}/spree/admin/promotion_categories_controller.rb (100%) rename legacy_promotions/{app/controllers => lib/controllers/backend}/spree/admin/promotion_code_batches_controller.rb (100%) rename legacy_promotions/{app/controllers => lib/controllers/backend}/spree/admin/promotion_codes_controller.rb (100%) rename legacy_promotions/{app/controllers => lib/controllers/backend}/spree/admin/promotion_rules_controller.rb (100%) rename legacy_promotions/{app/controllers => lib/controllers/backend}/spree/admin/promotions_controller.rb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotion_actions/create.js.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotion_actions/destroy.js.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotion_categories/_form.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotion_categories/edit.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotion_categories/index.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotion_categories/new.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotion_code_batches/_form_fields.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotion_code_batches/download.csv.ruby (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotion_code_batches/index.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotion_code_batches/new.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotion_codes/index.csv.ruby (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotion_codes/index.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotion_codes/new.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotion_rules/create.js.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotion_rules/destroy.js.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/_actions.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/_activations_edit.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/_activations_new.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/_form.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/_promotion_action.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/_promotion_rule.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/_rules.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/actions/_create_adjustment.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/actions/_create_item_adjustments.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/actions/_create_quantity_adjustments.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/actions/_free_shipping.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/actions/_promotion_calculators_with_custom_fields.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/calculators/_default_fields.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/calculators/distributed_amount/_fields.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/calculators/flat_rate/_fields.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/calculators/tiered_flat_rate/_fields.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/calculators/tiered_percent/_fields.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/edit.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/index.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/new.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/rules/_first_order.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/rules/_first_repeat_purchase_since.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/rules/_item_total.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/rules/_minimum_quantity.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/rules/_nth_order.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/rules/_one_use_per_user.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/rules/_option_value.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/rules/_product.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/rules/_store.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/rules/_taxon.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/rules/_user.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/rules/_user_logged_in.html.erb (100%) rename legacy_promotions/{app/views => lib/views/backend}/spree/admin/promotions/rules/_user_role.html.erb (100%) diff --git a/Gemfile b/Gemfile index e22ffa36df0..b60264e0a6b 100644 --- a/Gemfile +++ b/Gemfile @@ -60,6 +60,7 @@ end group :legacy_promotions do gem 'solidus_legacy_promotions', path: 'legacy_promotions', require: false gem 'solidus_admin', path: 'admin', require: false + gem 'solidus_backend', path: 'backend', require: false gem 'axe-core-rspec', '~> 4.8', require: false gem 'axe-core-capybara', '~> 4.8', require: false end diff --git a/legacy_promotions/config/routes.rb b/legacy_promotions/config/routes.rb index c3c2a52d53f..a9e9dd2bc10 100644 --- a/legacy_promotions/config/routes.rb +++ b/legacy_promotions/config/routes.rb @@ -1,17 +1,19 @@ # frozen_string_literal: true -Spree::Core::Engine.routes.draw do - namespace :admin do - resources :promotions do - resources :promotion_rules - resources :promotion_actions - resources :promotion_codes, only: [:index, :new, :create] - resources :promotion_code_batches, only: [:index, :new, :create] do - get '/download', to: "promotion_code_batches#download", defaults: { format: "csv" } +if SolidusSupport.backend_available? + Spree::Core::Engine.routes.draw do + namespace :admin do + resources :promotions do + resources :promotion_rules + resources :promotion_actions + resources :promotion_codes, only: [:index, :new, :create] + resources :promotion_code_batches, only: [:index, :new, :create] do + get '/download', to: "promotion_code_batches#download", defaults: { format: "csv" } + end end - end - resources :promotion_categories, except: [:show] + resources :promotion_categories, except: [:show] + end end end diff --git a/legacy_promotions/app/controllers/spree/admin/promotion_actions_controller.rb b/legacy_promotions/lib/controllers/backend/spree/admin/promotion_actions_controller.rb similarity index 100% rename from legacy_promotions/app/controllers/spree/admin/promotion_actions_controller.rb rename to legacy_promotions/lib/controllers/backend/spree/admin/promotion_actions_controller.rb diff --git a/legacy_promotions/app/controllers/spree/admin/promotion_categories_controller.rb b/legacy_promotions/lib/controllers/backend/spree/admin/promotion_categories_controller.rb similarity index 100% rename from legacy_promotions/app/controllers/spree/admin/promotion_categories_controller.rb rename to legacy_promotions/lib/controllers/backend/spree/admin/promotion_categories_controller.rb diff --git a/legacy_promotions/app/controllers/spree/admin/promotion_code_batches_controller.rb b/legacy_promotions/lib/controllers/backend/spree/admin/promotion_code_batches_controller.rb similarity index 100% rename from legacy_promotions/app/controllers/spree/admin/promotion_code_batches_controller.rb rename to legacy_promotions/lib/controllers/backend/spree/admin/promotion_code_batches_controller.rb diff --git a/legacy_promotions/app/controllers/spree/admin/promotion_codes_controller.rb b/legacy_promotions/lib/controllers/backend/spree/admin/promotion_codes_controller.rb similarity index 100% rename from legacy_promotions/app/controllers/spree/admin/promotion_codes_controller.rb rename to legacy_promotions/lib/controllers/backend/spree/admin/promotion_codes_controller.rb diff --git a/legacy_promotions/app/controllers/spree/admin/promotion_rules_controller.rb b/legacy_promotions/lib/controllers/backend/spree/admin/promotion_rules_controller.rb similarity index 100% rename from legacy_promotions/app/controllers/spree/admin/promotion_rules_controller.rb rename to legacy_promotions/lib/controllers/backend/spree/admin/promotion_rules_controller.rb diff --git a/legacy_promotions/app/controllers/spree/admin/promotions_controller.rb b/legacy_promotions/lib/controllers/backend/spree/admin/promotions_controller.rb similarity index 100% rename from legacy_promotions/app/controllers/spree/admin/promotions_controller.rb rename to legacy_promotions/lib/controllers/backend/spree/admin/promotions_controller.rb diff --git a/legacy_promotions/lib/solidus_legacy_promotions.rb b/legacy_promotions/lib/solidus_legacy_promotions.rb index bd9134432cc..3c7c33c17f6 100644 --- a/legacy_promotions/lib/solidus_legacy_promotions.rb +++ b/legacy_promotions/lib/solidus_legacy_promotions.rb @@ -2,17 +2,24 @@ require "solidus_core" require "solidus_api" -require "solidus_backend" require "solidus_support" -# If `solidus_admin` is available, it needs to load before -# our engine is initialized, so that our load paths can -# be initialized. +# We carry controllers and views for both the traditional backend +# and the new Solidus Admin interface, but we want to continue to function +# if either of them are not present. If they are present, +# however, they need to load before us. begin require 'solidus_admin' rescue LoadError # Solidus Admin is not available end + +begin + require "solidus_backend" +rescue LoadError + # Solidus backend is not available +end + module SolidusLegacyPromotions VERSION = Spree.solidus_version end diff --git a/legacy_promotions/app/views/spree/admin/promotion_actions/create.js.erb b/legacy_promotions/lib/views/backend/spree/admin/promotion_actions/create.js.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotion_actions/create.js.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotion_actions/create.js.erb diff --git a/legacy_promotions/app/views/spree/admin/promotion_actions/destroy.js.erb b/legacy_promotions/lib/views/backend/spree/admin/promotion_actions/destroy.js.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotion_actions/destroy.js.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotion_actions/destroy.js.erb diff --git a/legacy_promotions/app/views/spree/admin/promotion_categories/_form.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotion_categories/_form.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotion_categories/_form.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotion_categories/_form.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotion_categories/edit.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotion_categories/edit.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotion_categories/edit.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotion_categories/edit.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotion_categories/index.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotion_categories/index.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotion_categories/index.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotion_categories/index.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotion_categories/new.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotion_categories/new.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotion_categories/new.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotion_categories/new.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotion_code_batches/_form_fields.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotion_code_batches/_form_fields.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotion_code_batches/_form_fields.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotion_code_batches/_form_fields.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotion_code_batches/download.csv.ruby b/legacy_promotions/lib/views/backend/spree/admin/promotion_code_batches/download.csv.ruby similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotion_code_batches/download.csv.ruby rename to legacy_promotions/lib/views/backend/spree/admin/promotion_code_batches/download.csv.ruby diff --git a/legacy_promotions/app/views/spree/admin/promotion_code_batches/index.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotion_code_batches/index.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotion_code_batches/index.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotion_code_batches/index.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotion_code_batches/new.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotion_code_batches/new.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotion_code_batches/new.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotion_code_batches/new.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotion_codes/index.csv.ruby b/legacy_promotions/lib/views/backend/spree/admin/promotion_codes/index.csv.ruby similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotion_codes/index.csv.ruby rename to legacy_promotions/lib/views/backend/spree/admin/promotion_codes/index.csv.ruby diff --git a/legacy_promotions/app/views/spree/admin/promotion_codes/index.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotion_codes/index.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotion_codes/index.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotion_codes/index.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotion_codes/new.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotion_codes/new.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotion_codes/new.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotion_codes/new.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotion_rules/create.js.erb b/legacy_promotions/lib/views/backend/spree/admin/promotion_rules/create.js.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotion_rules/create.js.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotion_rules/create.js.erb diff --git a/legacy_promotions/app/views/spree/admin/promotion_rules/destroy.js.erb b/legacy_promotions/lib/views/backend/spree/admin/promotion_rules/destroy.js.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotion_rules/destroy.js.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotion_rules/destroy.js.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/_actions.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/_actions.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/_actions.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/_actions.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/_activations_edit.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/_activations_edit.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/_activations_edit.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/_activations_edit.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/_activations_new.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/_activations_new.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/_activations_new.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/_activations_new.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/_form.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/_form.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/_form.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/_form.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/_promotion_action.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/_promotion_action.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/_promotion_action.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/_promotion_action.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/_promotion_rule.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/_promotion_rule.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/_promotion_rule.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/_promotion_rule.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/_rules.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/_rules.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/_rules.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/_rules.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/actions/_create_adjustment.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/actions/_create_adjustment.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/actions/_create_adjustment.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/actions/_create_adjustment.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/actions/_create_item_adjustments.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/actions/_create_item_adjustments.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/actions/_create_item_adjustments.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/actions/_create_item_adjustments.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/actions/_create_quantity_adjustments.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/actions/_create_quantity_adjustments.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/actions/_create_quantity_adjustments.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/actions/_create_quantity_adjustments.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/actions/_free_shipping.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/actions/_free_shipping.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/actions/_free_shipping.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/actions/_free_shipping.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/actions/_promotion_calculators_with_custom_fields.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/actions/_promotion_calculators_with_custom_fields.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/actions/_promotion_calculators_with_custom_fields.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/actions/_promotion_calculators_with_custom_fields.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/calculators/_default_fields.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/calculators/_default_fields.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/calculators/_default_fields.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/calculators/_default_fields.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/calculators/distributed_amount/_fields.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/calculators/distributed_amount/_fields.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/calculators/distributed_amount/_fields.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/calculators/distributed_amount/_fields.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/calculators/flat_rate/_fields.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/calculators/flat_rate/_fields.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/calculators/flat_rate/_fields.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/calculators/flat_rate/_fields.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/calculators/tiered_flat_rate/_fields.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/calculators/tiered_flat_rate/_fields.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/calculators/tiered_flat_rate/_fields.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/calculators/tiered_flat_rate/_fields.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/calculators/tiered_percent/_fields.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/calculators/tiered_percent/_fields.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/calculators/tiered_percent/_fields.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/calculators/tiered_percent/_fields.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/edit.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/edit.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/edit.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/edit.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/index.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/index.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/index.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/index.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/new.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/new.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/new.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/new.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/rules/_first_order.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_first_order.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/rules/_first_order.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_first_order.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/rules/_first_repeat_purchase_since.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_first_repeat_purchase_since.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/rules/_first_repeat_purchase_since.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_first_repeat_purchase_since.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/rules/_item_total.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_item_total.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/rules/_item_total.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_item_total.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/rules/_minimum_quantity.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_minimum_quantity.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/rules/_minimum_quantity.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_minimum_quantity.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/rules/_nth_order.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_nth_order.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/rules/_nth_order.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_nth_order.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/rules/_one_use_per_user.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_one_use_per_user.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/rules/_one_use_per_user.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_one_use_per_user.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/rules/_option_value.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_option_value.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/rules/_option_value.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_option_value.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/rules/_product.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_product.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/rules/_product.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_product.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/rules/_store.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_store.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/rules/_store.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_store.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/rules/_taxon.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_taxon.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/rules/_taxon.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_taxon.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/rules/_user.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_user.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/rules/_user.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_user.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/rules/_user_logged_in.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_user_logged_in.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/rules/_user_logged_in.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_user_logged_in.html.erb diff --git a/legacy_promotions/app/views/spree/admin/promotions/rules/_user_role.html.erb b/legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_user_role.html.erb similarity index 100% rename from legacy_promotions/app/views/spree/admin/promotions/rules/_user_role.html.erb rename to legacy_promotions/lib/views/backend/spree/admin/promotions/rules/_user_role.html.erb diff --git a/legacy_promotions/solidus_legacy_promotions.gemspec b/legacy_promotions/solidus_legacy_promotions.gemspec index 82cd6073f83..a31c951abd4 100644 --- a/legacy_promotions/solidus_legacy_promotions.gemspec +++ b/legacy_promotions/solidus_legacy_promotions.gemspec @@ -25,6 +25,5 @@ Gem::Specification.new do |s| s.add_dependency 'solidus_core', s.version s.add_dependency 'solidus_api', s.version - s.add_dependency 'solidus_backend', s.version s.add_dependency 'solidus_support' end From f3b621b50de113b75a541e12f8e5b0809791b68d Mon Sep 17 00:00:00 2001 From: Martin Meyerhoff Date: Thu, 18 Apr 2024 16:23:12 +0200 Subject: [PATCH 2/2] Only add backend menu items if backend is available --- .../lib/solidus_legacy_promotions/engine.rb | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/legacy_promotions/lib/solidus_legacy_promotions/engine.rb b/legacy_promotions/lib/solidus_legacy_promotions/engine.rb index 6c552656381..2f897653ee9 100644 --- a/legacy_promotions/lib/solidus_legacy_promotions/engine.rb +++ b/legacy_promotions/lib/solidus_legacy_promotions/engine.rb @@ -3,29 +3,30 @@ module SolidusLegacyPromotions class Engine < ::Rails::Engine include SolidusSupport::EngineExtensions - MenuItem = Spree::BackendConfiguration::MenuItem - initializer "solidus_legacy_promotions.add_menu_item" do - promotions_menu_item = MenuItem.new( - label: :promotions, - icon: Spree::Backend::Config.admin_updated_navbar ? "ri-megaphone-line" : "bullhorn", - partial: "spree/admin/shared/promotion_sub_menu", - condition: -> { can?(:admin, Spree::Promotion) }, - url: :admin_promotions_path, - data_hook: :admin_promotion_sub_tabs, - children: [ - MenuItem.new( - label: :promotions, - condition: -> { can?(:admin, Spree::Promotion) } - ), - MenuItem.new( - label: :promotion_categories, - condition: -> { can?(:admin, Spree::PromotionCategory) } - ) - ] - ) - 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) + initializer "solidus_legacy_promotions.add_backend_menu_item" do + if SolidusSupport.backend_available? + promotions_menu_item = Spree::BackendConfiguration::MenuItem.new( + label: :promotions, + icon: Spree::Backend::Config.admin_updated_navbar ? "ri-megaphone-line" : "bullhorn", + partial: "spree/admin/shared/promotion_sub_menu", + condition: -> { can?(:admin, Spree::Promotion) }, + url: :admin_promotions_path, + data_hook: :admin_promotion_sub_tabs, + children: [ + Spree::BackendConfiguration::MenuItem.new( + label: :promotions, + condition: -> { can?(:admin, Spree::Promotion) } + ), + Spree::BackendConfiguration::MenuItem.new( + label: :promotion_categories, + condition: -> { can?(:admin, Spree::PromotionCategory) } + ) + ] + ) + 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 initializer "solidus_legacy_promotions.add_solidus_admin_menu_items" do