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
Add "used in" section to menus table to show what stores each menu is used in.
Matthew Kennedyb5ce12f6df01
diff --git a/backend/app/helpers/spree/admin/menu_helper.rb b/backend/app/helpers/spree/admin/menu_helper.rbindex 2ad1396028..bac0e50e2b 100644--- a/backend/app/helpers/spree/admin/menu_helper.rb+++ b/backend/app/helpers/spree/admin/menu_helper.rb@@ -12,7 +12,9 @@ module Spreemenu_item_type = content_tag(:small, item.item_type, class: 'form-text text-muted mt-0')image = if item.image_asset.attached? && item.image_asset.image?- content_tag(:div, content_tag(:div, (image_tag main_app.url_for(item.image_asset)), class: 'menu_items_image_holder'), class: 'ml-2')+ content_tag(:div, content_tag(:div,+ (image_tag main_app.url_for(item.image_asset)),+ class: 'menu_items_image_holder'), class: 'ml-2')else''enddiff --git a/backend/app/views/spree/admin/menus/index.html.erb b/backend/app/views/spree/admin/menus/index.html.erbindex ca8e15431d..f6c92cb0a5 100644--- a/backend/app/views/spree/admin/menus/index.html.erb+++ b/backend/app/views/spree/admin/menus/index.html.erb@@ -11,12 +11,18 @@<table id="menusTable" class="table"><thead><th><%= Spree.t(:name) %></th>+ <th><%= Spree.t('admin.navigation.used_in') %></th><th data-hook="admin_menus_index_header_actions" class="actions"></th><thead><tbody><% @menus.each do |menu| %><tr><td><%= menu.name %></td>+ <td>+ <% menu.store_ids.each do |store| %>+ <span class="badge badge-secondary"><%= @stores.find(store).unique_name %></span>+ <% end %>+ </td><td class="actions" data-hook="admin_menus_index_row_actions"><span class="d-flex justify-content-end"><%= link_to_edit(menu, no_text: true) %>diff --git a/backend/spec/features/admin/menus/index_menu_spec.rb b/backend/spec/features/admin/menus/index_menu_spec.rbindex f57fc69fac..04ea29821f 100644--- a/backend/spec/features/admin/menus/index_menu_spec.rb+++ b/backend/spec/features/admin/menus/index_menu_spec.rb@@ -14,7 +14,11 @@ describe 'Menus Index', type: :feature doendcontext 'when menus are present' do- let!(:main_menu) { create(:menu, name: 'Main Menu') }+ let!(:store_1) { create(:store) }+ let!(:store_2) { create(:store) }+ let!(:store_3) { create(:store) }++ let!(:main_menu) { create(:menu, name: 'Main Menu', store_ids: [store_1.id, store_3.id]) }let!(:footer_menu) { create(:menu, name: 'Footer Menu') }before do@@ -28,6 +32,16 @@ describe 'Menus Index', type: :feature doendend+ it 'lists each menu with its store ' do+ within_table('menusTable') do+ expect(page).to have_text 'Main Menu'+ expect(page).to have_text 'Footer Menu'+ expect(page).to have_text store_1.unique_name+ expect(page).to have_text store_3.unique_name+ expect(page).not_to have_text store_2.unique_name+ end+ end+it 'does not prompt you to create your first menu' doexpect(page).not_to have_text Spree.t('admin.navigation.you_have_no_menus')enddiff --git a/core/config/locales/en.yml b/core/config/locales/en.ymlindex cfdc69ce48..82415a1c7c 100644--- a/core/config/locales/en.yml+++ b/core/config/locales/en.yml@@ -598,6 +598,7 @@ en:menus: Menusmenu_items: '%{menu_name} Items'subtitle: Subtitle+ used_in: Used Inyou_have_no_menus: You have no Menus, click the Add New Menu button to create your first Menu.this_link_takes_you_to_your_stores_home_page: This link takes you to your stores home page.administration: Administration