Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Move more shared JS dependencies to core (#12492)

Damian Kaczmarczyka60633778eb8
diff --git a/admin/config/importmap.rb b/admin/config/importmap.rb
index ba5f968967..b8fbe6f6fa 100644
--- a/admin/config/importmap.rb
+++ b/admin/config/importmap.rb
@@ -5,7 +5,6 @@ pin '@rails/activestorage', to: 'activestorage.esm.js', preload: ['application-s
pin '@rails/actiontext', to: '@[email protected]', preload: ['application-spree-admin']
pin 'trix', to: '[email protected]', preload: ['application-spree-admin']
-pin '@rails/request.js', to: '@rails--request.js.js', preload: ['application-spree-admin'] # @0.0.8
pin 'sortablejs', preload: ['application-spree-admin'] # @1.15.6
pin 'chartkick', to: 'chartkick.js', preload: ['application-spree-admin']
pin 'Chart.bundle', to: 'Chart.bundle.js', preload: ['application-spree-admin']
@@ -16,7 +15,6 @@ pin 'bootstrap', to: 'bootstrap--dist--js--bootstrap.bundle.min.js.js', preload:
pin 'dompurify', preload: ['application-spree-admin'] # @3.2.3
# Stimulus components
-pin '@stimulus-components/auto-submit', to: '@stimulus-components--auto-submit.js', preload: ['application-spree-admin'] # @6.0.0
pin '@stimulus-components/rails-nested-form', to: '@stimulus-components--rails-nested-form.js', preload: ['application-spree-admin'] # @5.0.0
pin 'stimulus-notification', preload: ['application-spree-admin'] # @2.2.0
pin 'stimulus-password-visibility', preload: ['application-spree-admin'] # @2.1.1
diff --git a/core/config/importmap.rb b/core/config/importmap.rb
index b24d75445b..2156dafef9 100644
--- a/core/config/importmap.rb
+++ b/core/config/importmap.rb
@@ -1,6 +1,8 @@
# Shared dependencies between storefront and admin
+pin '@rails/request.js', to: '@rails--request.js.js', preload: ['application-spree-admin'] # @0.0.8
pin 'tailwindcss-stimulus-components', preload: ['application-spree-storefront', 'application-spree-admin'] # @3.0.4
pin 'stimulus-reveal-controller', preload: ['application-spree-storefront', 'application-spree-admin'] # @4.1.0
+pin '@stimulus-components/auto-submit', to: '@stimulus-components--auto-submit.js', preload: ['application-spree-admin'] # @6.0.0
pin_all_from Spree::Core::Engine.root.join('app/javascript/spree/core/controllers'),
under: 'spree/core/controllers',
diff --git a/admin/vendor/javascript/@rails--request.js.js b/core/vendor/javascript/@rails--request.js.js
similarity index 100%
rename from admin/vendor/javascript/@rails--request.js.js
rename to core/vendor/javascript/@rails--request.js.js
diff --git a/admin/vendor/javascript/@stimulus-components--auto-submit.js b/core/vendor/javascript/@stimulus-components--auto-submit.js
similarity index 100%
rename from admin/vendor/javascript/@stimulus-components--auto-submit.js
rename to core/vendor/javascript/@stimulus-components--auto-submit.js
diff --git a/storefront/app/views/themes/default/spree/page_sections/_featured_product.html.erb b/storefront/app/views/themes/default/spree/page_sections/_featured_product.html.erb
index f8de1e1824..7731dd5d01 100644
--- a/storefront/app/views/themes/default/spree/page_sections/_featured_product.html.erb
+++ b/storefront/app/views/themes/default/spree/page_sections/_featured_product.html.erb
@@ -32,8 +32,11 @@
</div>
<% end %>
<div class="lg:col-span-5 lg:col-start-8">
+ <% show_waitlist_modal = spree.respond_to?(:waitlists_path) && current_variant.present? %>
<div
+ <% if show_waitlist_modal %>
data-controller="modal"
+ <% end %>
data-modal-allow-background-close="true"
class="h-full w-full waitlist-modal"
data-modal-backdrop-color-value="rgba(0,0,0,0.32)">
@@ -124,7 +127,7 @@
<% end %>
<% end %>
<% end %>
- <%= render('spree/products/add_to_waitlist', variant: current_variant) if spree.respond_to?(:waitlists_path) && current_variant.present? %>
+ <%= render('spree/products/add_to_waitlist', variant: current_variant) if show_waitlist_modal %>
</div>
</div>
</div>
diff --git a/storefront/app/views/themes/default/spree/page_sections/_product_details.html.erb b/storefront/app/views/themes/default/spree/page_sections/_product_details.html.erb
index 2e10f6639c..9284f5c0d5 100644
--- a/storefront/app/views/themes/default/spree/page_sections/_product_details.html.erb
+++ b/storefront/app/views/themes/default/spree/page_sections/_product_details.html.erb
@@ -72,8 +72,11 @@
%>
</div>
<%= render 'spree/products/tags', product: product %>
+ <% show_waitlist_modal = spree.respond_to?(:waitlists_path) && current_variant.present? %>
<div
+ <% if show_waitlist_modal %>
data-controller="modal"
+ <% end %>
data-modal-allow-background-close="true"
class="h-full w-full waitlist-modal"
data-modal-backdrop-color-value="rgba(0,0,0,0.32)">
@@ -85,7 +88,7 @@
<%= render 'spree/products/add_to_wishlist', variant: current_variant, css_classes: 'btn-secondary ml-5 h-12 !py-0 !px-3 border-default', icon_size: 24 %>
</div>
<% end %>
- <%= render 'spree/products/add_to_waitlist', variant: current_variant if spree.respond_to?(:waitlists_path) && current_variant.present? %>
+ <%= render 'spree/products/add_to_waitlist', variant: current_variant if show_waitlist_modal %>
</div>
<%= render 'spree/products/details', product: product %>