Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Remove old .yml navigation install files.
Matthew Kennedy959f6496d2c5
diff --git a/frontend/app/controllers/spree/store_controller.rb b/frontend/app/controllers/spree/store_controller.rbindex 08036a6af9..245b456b9b 100644--- a/frontend/app/controllers/spree/store_controller.rb+++ b/frontend/app/controllers/spree/store_controller.rb@@ -31,33 +31,6 @@ module Spreerender json: current_order(create_order_if_necessary: true) # force creation of order if doesn't existsend- # Find a menu by its unique_code- # this method will only return a menu if it is- # available for use in the current store.- def menu(unique_code)- menu = available_menus.by_unique_code(unique_code)- menu[0]- end- helper_method :menu-- # Returns the root for the menu by unique_code.- # You can use .children to retrieve the top level of menu items,- # or .descendants to retrieve all menu items.- def root_item_for_menu(unique_code)- if menu(unique_code).present?- menu(unique_code).root- end- end- helper_method :root_item_for_menu-- # Returns only the top level items for the menu by unique_code- def top_level_items_for_menu(unique_code)- if menu(unique_code).present?- menu(unique_code).root.children- end- end- helper_method :top_level_items_for_menu-protecteddef config_localediff --git a/frontend/app/helpers/spree/navigation_helper.rb b/frontend/app/helpers/spree/navigation_helper.rbindex 7453f06476..0adaf6364c 100644--- a/frontend/app/helpers/spree/navigation_helper.rb+++ b/frontend/app/helpers/spree/navigation_helper.rb@@ -2,17 +2,9 @@ require 'digest'module Spreemodule NavigationHelper- def spree_navigation_data- @spree_navigation_data ||= SpreeStorefrontConfig.dig(I18n.locale, :navigation) || SpreeStorefrontConfig.dig(current_store.code, :navigation) || SpreeStorefrontConfig.dig(:default, :navigation) || []- # safeguard for older Spree installs that don't have spree_navigation initializer- # or spree.yml file present- rescue- []- end-def spree_nav_cache_key(section = 'header')@spree_nav_cache_key = begin- keys = base_cache_key + [current_store, spree_navigation_data_cache_key, Spree::Config[:logo], stores&.cache_key, section]+ keys = base_cache_key + [current_store, Spree::Config[:logo], stores&.cache_key, section]Digest::MD5.hexdigest(keys.join('-'))endend@@ -33,10 +25,42 @@ module Spree(defined?(should_render_currency_dropdown?) && should_render_currency_dropdown?)end+ # Find a menu by its unique_code+ # this method will only return a menu if it is+ # available for use in the current store.+ def menu(unique_code)+ menu = available_menus.by_unique_code(unique_code)+ menu[0]+ end++ # Returns the root for the menu by unique_code.+ # You can use .children to retrieve the top level of menu items,+ # or .descendants to retrieve all menu items.+ def root_item_for_menu(unique_code)+ if menu(unique_code).present?+ menu(unique_code).root+ end+ end++ # Returns only the top level items for the menu by unique_code+ def top_level_items_for_menu(unique_code)+ if menu(unique_code).present?+ menu(unique_code).root.children+ end+ end++ # Returns all items for the menu by unique_code+ def all_items_for_menu(unique_code)+ if menu(unique_code).present?+ menu(unique_code).root.descendants+ end+ end+privatedef spree_navigation_data_cache_key- @spree_navigation_data_cache_key ||= Digest::MD5.hexdigest(spree_navigation_data.to_s)+ # TODO: Fix cache key for new menus+ # @spree_navigation_data_cache_key ||= root_item_for_menu('spree-all-main').self_and_descendantsendendenddiff --git a/frontend/lib/generators/spree/frontend/install/install_generator.rb b/frontend/lib/generators/spree/frontend/install/install_generator.rbindex 2b27f5f2fd..3d592d5c04 100644--- a/frontend/lib/generators/spree/frontend/install/install_generator.rb+++ b/frontend/lib/generators/spree/frontend/install/install_generator.rb@@ -16,9 +16,6 @@ module Spreeenddef install- # main navigation configuration- template 'config/initializers/spree_storefront.rb', 'config/initializers/spree_storefront.rb'- template 'config/spree_storefront.yml', 'config/spree_storefront.yml'# static imagesdirectory 'noimage', './app/assets/images/noimage'directory 'homepage', './app/assets/images/homepage'diff --git a/frontend/lib/generators/spree/frontend/install/templates/config/initializers/spree_storefront.rb b/frontend/lib/generators/spree/frontend/install/templates/config/initializers/spree_storefront.rbdeleted file mode 100644index 2698623d17..0000000000--- a/frontend/lib/generators/spree/frontend/install/templates/config/initializers/spree_storefront.rb+++ /dev/null@@ -1 +0,0 @@-SpreeStorefrontConfig = YAML.load_file(Rails.root.join('config', 'spree_storefront.yml')).with_indifferent_accessdiff --git a/frontend/lib/generators/spree/frontend/install/templates/config/spree_storefront.yml b/frontend/lib/generators/spree/frontend/install/templates/config/spree_storefront.ymldeleted file mode 100644index ab95a67cec..0000000000--- a/frontend/lib/generators/spree/frontend/install/templates/config/spree_storefront.yml+++ /dev/null@@ -1,99 +0,0 @@-default:- navigation:- - title: Women- subtitle: Categories- url: /t/women- items:- - :title: Skirts- :url: /t/women/skirts- - :title: Dresses- :url: /t/women/dresses- - :title: Shirts and Blouses- :url: /t/women/shirts-and-blouses- - :title: Sweaters- :url: /t/women/sweaters- - :title: Tops and T-shirts- :url: /t/women/tops-and-t-shirts- - :title: Jackets and Coats- :url: /t/women/jackets-and-coats- promo_banners:- - subtitle: New collection- title: Summer 2021- url: /t/new-collection/summer-2021- image: 'meganav/promo_banner_left-first-category.jpg'- - subtitle: Special Offers- title: Get up to 30% off- url: /t/special-offers/30-percent-off- image: 'meganav/promo_banner_right-first-category.jpg'- - title: Men- subtitle: Categories- url: /t/men- items:- - :title: Shirts- :url: /t/men/shirts- - :title: T-shirts- :url: /t/men/t-shirts- - :title: Sweaters- :url: /t/men/sweaters- - :title: Jackets and Coats- :url: /t/men/jackets-and-coats- promo_banners:- - subtitle: New collection- title: Summer 2021- url: /t/new-collection/summer-2021- image: 'meganav/promo_banner_left-second-category.jpg'- - subtitle: Special Offers- title: Get up to 30% off- url: /t/special-offers/30-percent-off- image: 'meganav/promo_banner_right-second-category.jpg'- - title: Sportswear- subtitle: Categories- url: /t/sportswear- items:- - :title: Tops- :url: /t/sportswear/tops- - :title: Sweatshirts- :url: /t/sportswear/sweatshirts- - :title: Pants- :url: /t/sportswear/pants- promo_banners:- - subtitle: New collection- title: Summer 2021- url: /t/new-collection/summer-2021- image: 'meganav/promo_banner_left-third-category.jpg'- - subtitle: Special Offers- title: Get up to 30% off- url: /t/special-offers/30-percent-off- image: 'meganav/promo_banner_right-third-category.jpg'-fr:- navigation:- - title: Femmes- url: /fr/t/women- promo_banners:- - subtitle: Nouvelle collection- title: Été 2021- url: /fr/t/new-collection/summer-2021- image: 'meganav/promo_banner_left-first-category.jpg'- - subtitle: Offres spéciales- url: /fr/t/special-offers/30-percent-off- image: 'meganav/promo_banner_right-first-category.jpg'- - title: Hommes- url: /fr/t/men- promo_banners:- - subtitle: Nouvelle collection- title: Été 2021- url: /fr/t/new-collection/summer-2021- image: 'meganav/promo_banner_left-second-category.jpg'- - subtitle: Offres spéciales- url: /fr/t/special-offers/30-percent-off- image: 'meganav/promo_banner_right-second-category.jpg'- - title: Vêtements de sport- url: /fr/t/sportswear- promo_banners:- - subtitle: Nouvelle collection- title: Été 2021- url: /fr/t/new-collection/summer-2021- image: 'meganav/promo_banner_left-third-category.jpg'- - subtitle: Offres spéciales- url: /fr/t/special-offers/30-percent-off- image: 'meganav/promo_banner_right-third-category.jpg'diff --git a/frontend/spec/helpers/navigation_helper_spec.rb b/frontend/spec/helpers/navigation_helper_spec.rbindex cc13cdde50..76905a1122 100644--- a/frontend/spec/helpers/navigation_helper_spec.rb+++ b/frontend/spec/helpers/navigation_helper_spec.rb@@ -5,28 +5,6 @@ module Spreeinclude Spree::CurrencyHelperinclude Spree::LocaleHelper- describe '#spree_navigation_data' do- let!(:current_store) { create(:store) }-- context 'fetch via locale' do- before { I18n.locale = :fr }-- after { I18n.locale = :en }-- it { expect(spree_navigation_data.first[:title]).to eq('Femmes') }- end-- context 'fetch via store code' do- before { current_store.update(code: 'fr') }-- it { expect(spree_navigation_data.first[:title]).to eq('Femmes') }- end-- context 'fallback to default' do- it { expect(spree_navigation_data.first[:title]).to eq('Women') }- end- end-describe '#should_render_internationalization_dropdown?' docontext 'store with multiple currencies' dolet(:current_store) { create(:store, supported_currencies: 'EUR,USD') }