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 Rails storefront leftovers out of core and admin (#13744)

Damian Legawiec2716910da142
diff --git a/spree/admin/app/controllers/spree/admin/stores_controller.rb b/spree/admin/app/controllers/spree/admin/stores_controller.rb
index 1b0a00e8e3..2361905c3f 100644
--- a/spree/admin/app/controllers/spree/admin/stores_controller.rb
+++ b/spree/admin/app/controllers/spree/admin/stores_controller.rb
@@ -11,8 +11,6 @@ module Spree
def edit
if params[:section] == 'emails'
add_breadcrumb Spree.t(:emails), spree.edit_admin_store_path(section: params[:section])
- elsif params[:section] == 'policies'
- add_breadcrumb Spree.t(:policies), spree.edit_admin_store_path(section: params[:section])
elsif params[:section] == 'checkout'
add_breadcrumb Spree.t(:checkout), spree.edit_admin_store_path(section: params[:section])
else
diff --git a/spree/admin/app/views/spree/admin/shared/_page_section_image.html.erb b/spree/admin/app/views/spree/admin/shared/_page_section_image.html.erb
deleted file mode 100644
index b3f4270a07..0000000000
--- a/spree/admin/app/views/spree/admin/shared/_page_section_image.html.erb
+++ /dev/null
@@ -1,4 +0,0 @@
-<%= f.spree_file_field :asset, width: 400, height: 128, auto_submit: true, label: Spree.t(:image) %>
-<% if f.object.has_preference?(:image_alt) %>
- <%= f.spree_text_field :preferred_image_alt, label: Spree.t(:alt_text), data: { action: 'auto-submit#submit' } %>
-<% end %>
diff --git a/spree/admin/app/views/spree/admin/shared/_page_section_logo.html.erb b/spree/admin/app/views/spree/admin/shared/_page_section_logo.html.erb
deleted file mode 100644
index 7c6da02a98..0000000000
--- a/spree/admin/app/views/spree/admin/shared/_page_section_logo.html.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= f.spree_file_field :asset, width: 400, height: 128, auto_submit: true, label: Spree.t(:logo) %>
diff --git a/spree/admin/app/views/spree/admin/stores/edit.html.erb b/spree/admin/app/views/spree/admin/stores/edit.html.erb
index 24a18630c4..e2ac4a9e9a 100644
--- a/spree/admin/app/views/spree/admin/stores/edit.html.erb
+++ b/spree/admin/app/views/spree/admin/stores/edit.html.erb
@@ -10,7 +10,6 @@
<%= render partial: 'spree/admin/stores/form/basic', locals: { f: f } if params[:section].blank? || params[:section] == 'general-settings' %>
<%= render partial: 'spree/admin/stores/form/emails', locals: { f: f } if params[:section] == 'emails' %>
<%= render partial: 'spree/admin/stores/form/checkout', locals: { f: f } if params[:section] == 'checkout' %>
- <%= render partial: 'spree/admin/stores/form/policies', locals: { f: f } if params[:section] == 'policies' %>
<% end %>
</div>
</div>
\ No newline at end of file
diff --git a/spree/admin/app/views/spree/admin/stores/form/_buttons.html.erb b/spree/admin/app/views/spree/admin/stores/form/_buttons.html.erb
deleted file mode 100644
index 9afe007d54..0000000000
--- a/spree/admin/app/views/spree/admin/stores/form/_buttons.html.erb
+++ /dev/null
@@ -1,3 +0,0 @@
-<div class="form-actions">
- <%= turbo_save_button_tag Spree.t('actions.update') %>
-</div>
diff --git a/spree/admin/app/views/spree/admin/stores/form/_checkout.html.erb b/spree/admin/app/views/spree/admin/stores/form/_checkout.html.erb
index 36c42c550a..e8579c46e2 100644
--- a/spree/admin/app/views/spree/admin/stores/form/_checkout.html.erb
+++ b/spree/admin/app/views/spree/admin/stores/form/_checkout.html.erb
@@ -20,30 +20,3 @@
<%= f.spree_check_box :preferred_special_instructions_enabled, label: Spree.t('admin.checkout_settings.special_instructions.label'), help: Spree.t('admin.checkout_settings.special_instructions.description') %>
</div>
</div>
-
-<div class="card mb-6">
- <div class="card-header">
- <h5 class="card-title"><%= Spree.t(:checkout_message) %></h5>
- </div>
-
- <div class="card-body">
- <%= f.spree_rich_text_area :checkout_message, label: false, help: Spree.t('admin.checkout_settings.checkout_message_description') %>
- </div>
-</div>
-
-<% if current_store.respond_to?(:links) %>
- <div class="card mb-6">
- <div class="card-header">
- <h5 class="card-title"><%= Spree.t('admin.checkout_settings.checkout_links.label') %></h5>
- </div>
-
- <div class="card-body">
- <div class="alert alert-info">
- <div>
- <%= Spree.t('admin.checkout_settings.checkout_links.description') %>
- </div>
- </div>
- <%= render 'spree/admin/stores/form/checkout_links' %>
- </div>
- </div>
-<% end %>
diff --git a/spree/admin/app/views/spree/admin/stores/form/_checkout_links.html.erb b/spree/admin/app/views/spree/admin/stores/form/_checkout_links.html.erb
deleted file mode 100644
index 8e2fcf8c0a..0000000000
--- a/spree/admin/app/views/spree/admin/stores/form/_checkout_links.html.erb
+++ /dev/null
@@ -1,28 +0,0 @@
-<div id="checkout_links">
- <% if current_store.links.any? %>
- <ul class="list-group rounded-lg mb-6 border-gray-200"
- data-controller="sortable"
- data-sortable-handle-value=".handle"
- data-sortable-resource-name-value="page_link"
- data-sortable-response-kind-value="turbo-stream">
- <% current_store.links.each do |link| %>
- <li class="list-group-item p-0 hover:bg-gray-25"
- data-sortable-update-url="<%= spree.admin_page_link_path(link, sorting_only: true, format: :turbo_stream) %>"
- >
- <%= turbo_frame_tag spree_dom_id(link), class: 'flex items-center w-full py-2 pl-6 pr-2' do %>
- <%= link_to link.label, spree.edit_admin_page_link_path(link), class: 'block text-gray-900 flex-1 no-underline' %>
- <span class="btn btn-sm handle shadow-none hover:bg-gray-100 px-1 cursor-move ml-4">
- <%= icon 'grip-vertical', class: 'mr-0' %>
- </span>
- <% end %>
- </li>
- <% end %>
- </ul>
- <% else %>
- <p class="text-gray-600 text-center p-12">
- <%= Spree.t(:no_resource_found, resource: Spree::PageLink.model_name.human) %>
- </p>
- <% end %>
-
- <%= link_to_with_icon 'plus', Spree.t(:add_link), spree.admin_store_links_path(current_store), class: 'btn btn-primary w-full', data: { turbo_method: :post } %>
-</div>
\ No newline at end of file
diff --git a/spree/admin/app/views/spree/admin/stores/form/_policies.html.erb b/spree/admin/app/views/spree/admin/stores/form/_policies.html.erb
deleted file mode 100644
index 19a1e6bd27..0000000000
--- a/spree/admin/app/views/spree/admin/stores/form/_policies.html.erb
+++ /dev/null
@@ -1,69 +0,0 @@
-<%= content_for(:page_title) do %>
- <%= Spree.t(:policies) %>
-<% end %>
-
-<div class="alert alert-info">
- Policies will be automatically added to footer of your store and will be available to customers during checkout.
-</div>
-
-<div class="card mb-6">
- <div class="card-header">
- <h5 class="card-title"><%= Spree.t(:terms_of_service) %></h5>
- </div>
- <div class="card-body">
- <p class="text-gray-600">
- Customers will need to accept these terms of service during signup.
- </p>
- <%= f.spree_rich_text_area :customer_terms_of_service, label: Spree.t(:terms_of_service) %>
- </div>
-</div>
-
-<div class="card mb-6">
- <div class="card-header">
- <h5 class="card-title"><%= Spree.t(:privacy_policy) %></h5>
- </div>
- <div class="card-body">
- <p class="text-gray-600">
- Customers will need to accept these privacy policy during signup.
- </p>
- <%= f.spree_rich_text_area :customer_privacy_policy, label: Spree.t(:privacy_policy) %>
- </div>
-</div>
-
-<div class="card mb-6">
- <div class="card-header">
- <h5 class="card-title"><%= Spree.t(:returns_policy) %></h5>
- </div>
- <div class="card-body">
- <p class="text-gray-600">
- Please provide your customers with a clear and transparent returns policy.
- </p>
- <%= f.spree_rich_text_area :customer_returns_policy, label: Spree.t(:returns_policy) %>
- </div>
-</div>
-
-<div class="card mb-6">
- <div class="card-header">
- <h5 class="card-title"><%= Spree.t(:shipping_policy) %></h5>
- </div>
- <div class="card-body">
- <p class="text-gray-600">
- Please provide your customers with a clear and transparent shipping policy.
- </p>
- <%= f.spree_rich_text_area :customer_shipping_policy, label: Spree.t(:shipping_policy) %>
- </div>
-</div>
-
-<% if current_store.respond_to?(:partners_terms_of_service) %>
- <div class="card mb-6">
- <div class="card-header">
- <h5 class="card-title">Vendors <%= Spree.t(:terms_of_service) %></h5>
- </div>
- <div class="card-body">
- <p class="text-gray-600">
- Vendors you invite will need to accept these terms of service during their onboarding process.
- </p>
- <%= f.spree_rich_text_area :partners_terms_of_service, label: Spree.t(:terms_of_service) %>
- </div>
- </div>
-<% end %>
diff --git a/spree/core/app/models/concerns/spree/stores/socials.rb b/spree/core/app/models/concerns/spree/stores/socials.rb
deleted file mode 100644
index d4c232e5cb..0000000000
--- a/spree/core/app/models/concerns/spree/stores/socials.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-module Spree
- module Stores
- module Socials
- extend ActiveSupport::Concern
-
- SUPPORTED_SOCIAL_NETWORKS = %w[instagram facebook twitter pinterest tiktok youtube spotify discord].freeze
-
- SOCIAL_NETWORKS_CONFIG = {
- twitter: {
- input_placeholder: 'https://twitter.com/your_handle',
- profile_link: 'https://twitter.com/your_handle'
- },
- instagram: {
- input_placeholder: 'https://www.instagram.com/your_handle',
- profile_link: 'https://www.instagram.com/your_handle'
- },
- facebook: {
- input_placeholder: 'https://www.facebook.com/your_page',
- profile_link: 'https://www.facebook.com/your_page'
- },
- youtube: {
- input_placeholder: 'https://www.youtube.com/@your_channel',
- profile_link: 'https://www.youtube.com/@your_channel'
- },
- pinterest: {
- input_placeholder: 'https://pinterest.com/your_handle',
- profile_link: 'https://pinterest.com/your_handle'
- },
- tiktok: {
- input_placeholder: 'your_handle',
- profile_link: 'https://www.tiktok.com/@your_handle'
- },
- spotify: {
- input_placeholder: 'https://open.spotify.com/user/your_handle',
- profile_link: 'https://open.spotify.com/user/your_handle'
- },
- discord: {
- input_placeholder: 'https://discord.com/invite/your_handle',
- profile_link: 'https://discord.com/invite/your_handle'
- }
- }.freeze
-
- included do
- # generate methods for social links
- SUPPORTED_SOCIAL_NETWORKS.each do |social|
- # store the social handle in the public metadata
- store_accessor :public_metadata, social
-
- define_method "#{social}_link" do
- return if send(social).blank?
-
- send(social).match(/http/) ? send(social) : SOCIAL_NETWORKS_CONFIG[social.to_sym][:profile_link].gsub(/your_handle|your_page|your_channel/, send(social).sub(/^\//, '').sub(/^@/, ''))
- end
-
- define_method "#{social}_handle" do
- return if send(social).blank?
-
- (send(social).match(/http/) ? send(social).split('/').last : send(social)).sub(/^\//, '').gsub('@', '').split('?').first
- end
- end
- end
-
- def social_handle
- @social_handle ||= instagram_handle || youtube_handle || tiktok_handle
- end
-
- def social_links
- @social_links ||= [instagram_link, facebook_link, twitter_link, pinterest_link, youtube_link, tiktok_link, spotify_link, discord_link].compact_blank
- end
- end
- end
-end
diff --git a/spree/core/app/models/spree/store.rb b/spree/core/app/models/spree/store.rb
index c6eae80984..897039ab00 100644
--- a/spree/core/app/models/spree/store.rb
+++ b/spree/core/app/models/spree/store.rb
@@ -9,7 +9,6 @@ module Spree
include Spree::Metafields
include Spree::Metadata
include Spree::Stores::Setup
- include Spree::Stores::Socials
include Spree::Stores::Markets
include Spree::Security::Stores if defined?(Spree::Security::Stores)
include Spree::UserManagement
@@ -23,8 +22,7 @@ module Spree
#
# Translations
#
- TRANSLATABLE_FIELDS = %i[name meta_description meta_keywords seo_title facebook
- twitter instagram customer_support_email
+ TRANSLATABLE_FIELDS = %i[name meta_description meta_keywords seo_title customer_support_email
address contact_phone].freeze
translates(*TRANSLATABLE_FIELDS, column_fallback: !Spree.always_use_translations?)
self::Translation.class_eval do
@@ -115,7 +113,6 @@ module Spree
#
# ActionText
#
- has_rich_text :checkout_message
has_rich_text :customer_terms_of_service
has_rich_text :customer_privacy_policy
has_rich_text :customer_returns_policy
diff --git a/spree/core/lib/spree/core/controller_helpers/strong_parameters.rb b/spree/core/lib/spree/core/controller_helpers/strong_parameters.rb
index 6f7bffc875..627d3e8592 100644
--- a/spree/core/lib/spree/core/controller_helpers/strong_parameters.rb
+++ b/spree/core/lib/spree/core/controller_helpers/strong_parameters.rb
@@ -39,7 +39,7 @@ module Spree
end
def permitted_store_attributes
- permitted_attributes.store_attributes + Spree::Store::SUPPORTED_SOCIAL_NETWORKS.map { |social| "store_#{social}" }
+ permitted_attributes.store_attributes
end
end
end