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.

[SD-1346] Adds admin panel stock menu for stock locations and transfers (#11134)

Robert Nowakowskie76be13ad05b
diff --git a/backend/app/assets/images/backend-box.svg b/backend/app/assets/images/backend-box.svg
new file mode 100644
index 0000000000..e1506b8385
--- /dev/null
+++ b/backend/app/assets/images/backend-box.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-box-seam" viewBox="0 0 16 16">
+ <path d="M8.186 1.113a.5.5 0 0 0-.372 0L1.846 3.5l2.404.961L10.404 2l-2.218-.887zm3.564 1.426L5.596 5 8 5.961 14.154 3.5l-2.404-.961zm3.25 1.7-6.5 2.6v7.922l6.5-2.6V4.24zM7.5 14.762V6.838L1 4.239v7.923l6.5 2.6zM7.443.184a1.5 1.5 0 0 1 1.114 0l7.129 2.852A.5.5 0 0 1 16 3.5v8.662a1 1 0 0 1-.629.928l-7.185 2.874a.5.5 0 0 1-.372 0L.63 13.09a1 1 0 0 1-.63-.928V3.5a.5.5 0 0 1 .314-.464L7.443.184z"/>
+</svg>
\ No newline at end of file
diff --git a/backend/app/views/spree/admin/shared/_main_menu.html.erb b/backend/app/views/spree/admin/shared/_main_menu.html.erb
index b8ce902d1f..148f8feece 100644
--- a/backend/app/views/spree/admin/shared/_main_menu.html.erb
+++ b/backend/app/views/spree/admin/shared/_main_menu.html.erb
@@ -28,6 +28,12 @@
</ul>
<% end %>
+ <% if can?(:admin, Spree::StockLocation) || can?(:admin, Spree::StockTransfer) %>
+ <ul class="nav nav-sidebar border-bottom" id="sidebarStock">
+ <%= main_menu_tree Spree.t(:stock), icon: "box.svg", sub_menu: "stock", url: "#sidebar-stock" %>
+ </ul>
+ <% end %>
+
<% if can? :admin, Spree::Admin::ReportsController %>
<ul class="nav nav-sidebar border-bottom" id="sidebarReport">
<%= tab *Spree::BackendConfiguration::REPORT_TABS, icon: 'report.svg' %>
diff --git a/backend/app/views/spree/admin/shared/sub_menu/_configuration.html.erb b/backend/app/views/spree/admin/shared/sub_menu/_configuration.html.erb
index 99505c6295..d15122710c 100644
--- a/backend/app/views/spree/admin/shared/sub_menu/_configuration.html.erb
+++ b/backend/app/views/spree/admin/shared/sub_menu/_configuration.html.erb
@@ -13,8 +13,6 @@
<%= configurations_sidebar_menu_item(Spree.t(:payment_methods), spree.admin_payment_methods_path) if can? :manage, Spree::PaymentMethod %>
<%= configurations_sidebar_menu_item(Spree.t(:shipping_methods), spree.admin_shipping_methods_path) if can? :manage, Spree::ShippingMethod %>
<%= configurations_sidebar_menu_item(Spree.t(:shipping_categories), spree.admin_shipping_categories_path) if can? :manage, Spree::ShippingCategory %>
- <%= configurations_sidebar_menu_item(Spree.t(:stock_transfers), spree.admin_stock_transfers_path) if can? :manage, Spree::StockTransfer %>
- <%= configurations_sidebar_menu_item(Spree.t(:stock_locations), spree.admin_stock_locations_path) if can? :manage, Spree::StockLocation %>
<%= configurations_sidebar_menu_item(Spree.t(:store_credit_categories), spree.admin_store_credit_categories_path) if can? :manage, Spree::StoreCreditCategory %>
<%= configurations_sidebar_menu_item(Spree.t(:refund_reasons), spree.admin_refund_reasons_path) if can? :manage, Spree::RefundReason %>
<%= configurations_sidebar_menu_item(Spree.t(:reimbursement_types), spree.admin_reimbursement_types_path) if can? :manage, Spree::ReimbursementType %>
diff --git a/backend/app/views/spree/admin/shared/sub_menu/_stock.html.erb b/backend/app/views/spree/admin/shared/sub_menu/_stock.html.erb
new file mode 100644
index 0000000000..fb29cff606
--- /dev/null
+++ b/backend/app/views/spree/admin/shared/sub_menu/_stock.html.erb
@@ -0,0 +1,4 @@
+<ul id="sidebar-stock" class="border-top bg-white collapse nav nav-pills nav-stacked" data-hook="admin_stock_sub_tabs">
+ <%= tab(:stock_transfers, spree.admin_stock_transfers_path) if can? :manage, Spree::StockTransfer %>
+ <%= tab(:stock_locations, spree.admin_stock_locations_path) if can? :manage, Spree::StockLocation %>
+</ul>
diff --git a/backend/spec/features/admin/homepage_spec.rb b/backend/spec/features/admin/homepage_spec.rb
index dc0fb8be39..e6fc597392 100644
--- a/backend/spec/features/admin/homepage_spec.rb
+++ b/backend/spec/features/admin/homepage_spec.rb
@@ -25,6 +25,10 @@ describe 'Homepage', type: :feature do
expect(page).to have_link('Products', href: '/admin/products')
end
+ it 'has a link to stock' do
+ expect(page).to have_link('Stock', href: '#sidebar-stock')
+ end
+
it 'has a link to reports' do
expect(page).to have_link('Reports', href: '/admin/reports')
end
@@ -78,6 +82,20 @@ describe 'Homepage', type: :feature do
within('.sidebar') { expect(page).to have_link('Prototypes', href: '/admin/prototypes') }
end
end
+
+ context 'visiting the stock tab' do
+ before do
+ visit spree.admin_stock_transfers_path
+ end
+
+ it 'has a link to stock transfers' do
+ within('.sidebar') { expect(page).to have_link('Stock Transfers', href: '/admin/stock_transfers') }
+ end
+
+ it 'has a link to stock locations' do
+ within('.sidebar') { expect(page).to have_link('Stock Locations', href: '/admin/stock_locations') }
+ end
+ end
end
context 'as fakedispatch user' do