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
Fix test and localize links.
Matthew Kennedy21d98666bdb2
diff --git a/backend/app/assets/javascripts/spree/backend/menus/menu_item.es6 b/backend/app/assets/javascripts/spree/backend/menus/menu_item.es6index c47ae531f3..b0c1058d34 100644--- a/backend/app/assets/javascripts/spree/backend/menus/menu_item.es6+++ b/backend/app/assets/javascripts/spree/backend/menus/menu_item.es6@@ -30,8 +30,12 @@ document.addEventListener('DOMContentLoaded', function() {});function updateContainerMessage () {- const selectedLinkType = $('#menu_item_item_type').val()const linkSettingsPanel = document.getElementById('LinkSettings')++ if (!linkSettingsPanel) return++ const selectedLinkType = $('#menu_item_item_type').val()+const usingConainerMessage = document.getElementById('usingContainerInfo')if (selectedLinkType === 'Container') {diff --git a/backend/app/views/spree/admin/menus/edit.html.erb b/backend/app/views/spree/admin/menus/edit.html.erbindex a4edcf1502..93b1b3d784 100644--- a/backend/app/views/spree/admin/menus/edit.html.erb+++ b/backend/app/views/spree/admin/menus/edit.html.erb@@ -22,7 +22,7 @@</div><div id="menuArea">- <div class="row mt-5">+ <div class="row mt-2"><div class="col-12"><div class="card mb-3"><div class="card-header">diff --git a/core/app/helpers/spree/base_helper.rb b/core/app/helpers/spree/base_helper.rbindex 7bfad08180..2ef7b1056a 100644--- a/core/app/helpers/spree/base_helper.rb+++ b/core/app/helpers/spree/base_helper.rb@@ -25,6 +25,27 @@ module Spreeto_htmlend+ def localized_item_link(item)+ return if item.destination.nil?++ output_locale = if current_locale == current_store.default_locale+ ''+ else+ current_locale.to_s+ end++ if Spree::MenuItem::DYNAMIC_RESOURCE_TYPE.include? item.linked_resource_type+ "/#{output_locale + item.destination}"+ else+ case item.linked_resource_type+ when 'URL'+ item.destination+ when 'Home Page'+ "/#{output_locale}"+ end+ end+ end+def display_compare_at_price(product_or_variant)product_or_variant.price_in(current_currency).diff --git a/frontend/app/views/spree/shared/_footer.html.erb b/frontend/app/views/spree/shared/_footer.html.erbindex 5a357fea1e..90d73cc66b 100644--- a/frontend/app/views/spree/shared/_footer.html.erb+++ b/frontend/app/views/spree/shared/_footer.html.erb@@ -56,13 +56,13 @@<% if root.root? %><div class="col-3"><div class="footer-spree-label">- <%= link_to root.name, root.destination %>+ <%= link_to root.name, localized_item_link(root) %></div><% root.children.each do |child| %><% if child.code == 'category' && child.item_type == 'Container' %><% if child.children.present? %><% child.children.each do |category_link| %>- <div class="pt-2"><%= link_to category_link.name, category_link.destination %></div>+ <div class="pt-2"><%= link_to category_link.name, localized_item_link(category_link) %></div><% end %><% end %><% end %>diff --git a/frontend/app/views/spree/shared/_main_nav_bar.html.erb b/frontend/app/views/spree/shared/_main_nav_bar.html.erbindex e21804f357..d9278ae4bc 100644--- a/frontend/app/views/spree/shared/_main_nav_bar.html.erb+++ b/frontend/app/views/spree/shared/_main_nav_bar.html.erb@@ -12,7 +12,7 @@<% dropdown_toggle_class = has_dropdown ? "dropdown-toggle" : "" %><% data_attr = has_dropdown ? { toggle: "dropdown" } : {} %><% aria_attr = has_dropdown ? { haspopup: true, expanded: false } : {} %>- <%= link_to(root.name, root.destination, class: "nav-link main-nav-bar-item main-nav-bar-category-button #{dropdown_toggle_class}", data: data_attr, aria: aria_attr) %>+ <%= link_to(root.name, localized_item_link(root), class: "nav-link main-nav-bar-item main-nav-bar-category-button #{dropdown_toggle_class}", data: data_attr, aria: aria_attr) %><% if has_dropdown %><div class="dropdown-menu w-100 shadow main-nav-bar-category-dropdown"><div class="container p-0 d-flex justify-content-xl-around mx-auto">@@ -29,7 +29,7 @@<ul class="pl-0"><% child.children.each do |category_link| %><li>- <%= link_to category_link.name, category_link.destination, class: "text-uppercase main-nav-bar-category-links dropdown-item truncate" %>+ <%= link_to category_link.name, localized_item_link(category_link), class: "text-uppercase main-nav-bar-category-links dropdown-item truncate" %></li><% end %></ul>@@ -41,7 +41,7 @@<% if child.code == promo && child.item_type == 'Container' %><% if child.children.present? %><% child.children.each do |promo_banner| %>- <%= link_to promo_banner.destination, class: "dropdown-item" do %>+ <%= link_to localized_item_link(promo_banner), class: "dropdown-item" do %><div class="category-image text-center my-4 mx-3"><% if promo_banner.has_attached_image %><%= image_tag main_app.url_for(promo_banner.image_asset), title: promo_banner.subtitle %>diff --git a/frontend/app/views/spree/shared/_mobile_navigation.html.erb b/frontend/app/views/spree/shared/_mobile_navigation.html.erbindex b5dd552c7f..82601b25de 100644--- a/frontend/app/views/spree/shared/_mobile_navigation.html.erb+++ b/frontend/app/views/spree/shared/_mobile_navigation.html.erb@@ -23,7 +23,7 @@<% main_menu_items.each do |root| %><% if root.root? %><li class="d-flex justify-content-between align-items-center mobile-navigation-list-item">- <%= link_to root.name, root.destination, class: 'w-75' %>+ <%= link_to root.name, localized_item_link(root), class: 'w-75' %><% if root.children.present? %><a class="w-25 text-right mobile-navigation-category-link" data-category="<%= root.name.parameterize %>" href="#" aria-label="<%= Spree.t('go_to_category') %>"><%= icon(name: 'arrow-right',@@ -41,7 +41,7 @@<% if child.children.present? %><% child.children.each do |category_link| %><li class="d-flex justify-content-between align-items-center mobile-navigation-list-item">- <%= link_to category_link.name, category_link.destination, class: 'w-75' %>+ <%= link_to category_link.name, localized_item_link(category_link), class: 'w-75' %></li><% end %><% end %>diff --git a/frontend/spec/features/locale_spec.rb b/frontend/spec/features/locale_spec.rbindex d007d3ec96..737a0f6117 100644--- a/frontend/spec/features/locale_spec.rb+++ b/frontend/spec/features/locale_spec.rb@@ -6,7 +6,7 @@ describe 'setting locale', type: :feature, js: true dolet!(:main_menu) { create(:menu, name: 'Main Menu', unique_code: 'spree-all-main', store_ids: [store.id]) }- let!(:mi_root) { create(:menu_item, name: 'URL', menu_id: main_menu.id, url: 'https://spree.com') }+ let!(:mi_root) { create(:menu_item, name: 'URL', menu_id: main_menu.id, destination: 'https://spree.com') }let!(:mi_home) { create(:menu_item, name: 'Home', menu_id: main_menu.id, linked_resource_type: 'Home Page') }let!(:mi_ta) { create(:menu_item, name: 'Taxon', menu_id: main_menu.id, linked_resource_type: 'Spree::Taxon') }let!(:mi_pro) { create(:menu_item, name: 'Product', menu_id: main_menu.id, linked_resource_type: 'Spree::Product') }