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.

Make admin views not dependant on page builder

Damian Legawiecbc30d5cc739e
diff --git a/admin/app/views/spree/admin/dashboard/_sidebar.html.erb b/admin/app/views/spree/admin/dashboard/_sidebar.html.erb
index b296ef1f2b..96c1e63879 100644
--- a/admin/app/views/spree/admin/dashboard/_sidebar.html.erb
+++ b/admin/app/views/spree/admin/dashboard/_sidebar.html.erb
@@ -1,2 +1 @@
-<%= render 'updater' %>
-<%= render 'store_preview' %>
\ No newline at end of file
+<%= render 'updater' %>
\ No newline at end of file
diff --git a/admin/app/views/spree/admin/stores/form/_checkout.html.erb b/admin/app/views/spree/admin/stores/form/_checkout.html.erb
index 2c46a0dfe6..e6e148e401 100644
--- a/admin/app/views/spree/admin/stores/form/_checkout.html.erb
+++ b/admin/app/views/spree/admin/stores/form/_checkout.html.erb
@@ -34,17 +34,19 @@
</div>
</div>
-<div class="card mb-6">
- <div class="card-header">
- <h5 class="card-title"><%= Spree.t('admin.checkout_settings.checkout_links.label') %></h5>
- </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 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>
- <%= render 'spree/admin/stores/form/checkout_links' %>
</div>
-</div>
+<% end %>
diff --git a/admin/spec/controllers/spree/admin/stores_controller_spec.rb b/admin/spec/controllers/spree/admin/stores_controller_spec.rb
index 903e69a18d..fde91192b0 100644
--- a/admin/spec/controllers/spree/admin/stores_controller_spec.rb
+++ b/admin/spec/controllers/spree/admin/stores_controller_spec.rb
@@ -46,6 +46,24 @@ describe Spree::Admin::StoresController do
end
end
+ describe 'GET #edit' do
+ subject { get :edit }
+
+ it 'renders the edit template' do
+ subject
+ expect(response).to render_template('spree/admin/stores/edit')
+ end
+
+ context 'checkout form' do
+ subject { get :edit, params: { section: 'checkout' } }
+
+ it 'renders the checkout form' do
+ subject
+ expect(response.body).to include('Checkout Settings')
+ end
+ end
+ end
+
describe 'PUT #update' do
subject { patch :update, params: { id: store.id, store: store_params, **other_params } }
diff --git a/admin/app/views/spree/admin/dashboard/_store_preview.html.erb b/page_builder/app/views/spree/admin/dashboard/_store_preview.html.erb
similarity index 95%
rename from admin/app/views/spree/admin/dashboard/_store_preview.html.erb
rename to page_builder/app/views/spree/admin/dashboard/_store_preview.html.erb
index 8963fce855..d81e21b68a 100644
--- a/admin/app/views/spree/admin/dashboard/_store_preview.html.erb
+++ b/page_builder/app/views/spree/admin/dashboard/_store_preview.html.erb
@@ -1,4 +1,4 @@
-<% if current_store.respond_to?(:default_theme) && current_store.default_theme %>
+<% if current_store.default_theme %>
<div class="card mb-6">
<%= link_to spree.edit_admin_theme_path(current_store.default_theme), class: 'block border rounded-lg mx-2 mt-2 mb-0 overflow-auto bg-gray-25 relative store-preview-link hover:shadow-xs transition-shadow duration-200', data: { turbo_prefetch: false } do %>
<div class="absolute w-full h-full items-center justify-center hover:opacity-100 opacity-0 transition-opacity duration-200 store-preview-actions">
diff --git a/page_builder/config/initializers/spree_admin_partials.rb b/page_builder/config/initializers/spree_admin_partials.rb
new file mode 100644
index 0000000000..648b0478f6
--- /dev/null
+++ b/page_builder/config/initializers/spree_admin_partials.rb
@@ -0,0 +1,3 @@
+Rails.application.config.after_initialize do
+ Spree.admin.partials.dashboard_sidebar << 'spree/admin/dashboard/store_preview'
+end