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.

Improve store switcher on small screen sizes, add test for menu.

Matthew Kennedy2ca0fb8537f0
diff --git a/backend/app/assets/images/backend-store.svg b/backend/app/assets/images/backend-store.svg
index 37a1a3fb0f..6991d22aaf 100644
--- a/backend/app/assets/images/backend-store.svg
+++ b/backend/app/assets/images/backend-store.svg
@@ -1,14 +1,3 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 512 512" style="clip-rule:evenodd;fill-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;version:1">
-<style>
- .store-svg{
- fill:none;
- stroke-width:35px;
- stroke:currentColor;
- }
-</style>
- <path d="M256.7 177.1c4.5 10.2 28.3 29.3 51.9 29.3 27.1 0 48.6-18 56.8-28.7 7.6 11.5 30.6 28.2 59 28.2 28.4 0 57.1-17.9 57.1-42.7 0-6.2-1.3-10.7-3.5-16.7l-22.2-67.2 -187.1 0" class="store-svg"/>
- <path d="M268.6 79.3l-14.5 0 -199.2 0 -22.2 67.2c-2.3 6-3.5 10.2-3.5 16.4 0 24.8 28.8 42.9 57.2 42.9 28.4 0 51.5-16.6 59.2-28 8.2 10.7 30.1 29 57.1 29 23.5 0 49.4-19.5 53.9-29.7" class="store-svg"/>
- <path d="M452.8 209.2l0 194.8c0 16.7-15.5 31.7-32.2 31.7l-327.2 0c-16.7 0-33.2-15-33.2-31.7l0-200.9" class="store-svg"/>
- <path d="M313.9 420.6l0-121.2c0-14.6 12.6-26.8 27.2-26.8l31 0c14.6 0 26.4 12.2 26.4 26.8l0 121.2" class="store-svg"/>
- <path d="M247.5 369.3c0 6.7-5.4 12.1-12.1 12.1l-108.7 0c-6.7 0-12.1-5.4-12.1-12.1l0-84.6c0-6.7 5.4-12.1 12.1-12.1l108.7 0c6.7 0 12.1 5.4 12.1 12.1l0 84.6 0 0Z" class="store-svg"/>
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-shop-window" viewBox="0 0 16 16">
+ <path d="M2.97 1.35A1 1 0 0 1 3.73 1h8.54a1 1 0 0 1 .76.35l2.609 3.044A1.5 1.5 0 0 1 16 5.37v.255a2.375 2.375 0 0 1-4.25 1.458A2.371 2.371 0 0 1 9.875 8 2.37 2.37 0 0 1 8 7.083 2.37 2.37 0 0 1 6.125 8a2.37 2.37 0 0 1-1.875-.917A2.375 2.375 0 0 1 0 5.625V5.37a1.5 1.5 0 0 1 .361-.976l2.61-3.045zm1.78 4.275a1.375 1.375 0 0 0 2.75 0 .5.5 0 0 1 1 0 1.375 1.375 0 0 0 2.75 0 .5.5 0 0 1 1 0 1.375 1.375 0 1 0 2.75 0V5.37a.5.5 0 0 0-.12-.325L12.27 2H3.73L1.12 5.045A.5.5 0 0 0 1 5.37v.255a1.375 1.375 0 0 0 2.75 0 .5.5 0 0 1 1 0zM1.5 8.5A.5.5 0 0 1 2 9v6h12V9a.5.5 0 0 1 1 0v6h.5a.5.5 0 0 1 0 1H.5a.5.5 0 0 1 0-1H1V9a.5.5 0 0 1 .5-.5zm2 .5a.5.5 0 0 1 .5.5V13h8V9.5a.5.5 0 0 1 1 0V13a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V9.5a.5.5 0 0 1 .5-.5z"/>
</svg>
diff --git a/backend/app/assets/images/backend-users.svg b/backend/app/assets/images/backend-users.svg
index df8e457681..b09ba76f26 100644
--- a/backend/app/assets/images/backend-users.svg
+++ b/backend/app/assets/images/backend-users.svg
@@ -1,6 +1,3 @@
-<svg viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="2">
- <g fill-rule="nonzero" stroke="currentColor" stroke-width="9.5">
- <path fill="currentColor" d="M401.722 230.445c23.142-14.24 38.654-39.707 38.654-68.787 0-44.569-36.308-80.829-80.932-80.829-44.623 0-80.932 36.26-80.932 80.829 0 29.08 15.512 54.547 38.655 68.787-49.972 11.194-85.037 41.775-85.037 78.782 0 30.285 80.031 38.366 127.314 38.366 47.283 0 127.314-8.081 127.314-38.366 0-37.007-35.065-67.588-85.036-78.782zm-106.538-68.787c0-35.375 28.83-64.156 64.26-64.156 35.43 0 64.26 28.781 64.26 64.156 0 35.376-28.83 64.151-64.26 64.151-35.43 0-64.26-28.775-64.26-64.151zm64.26 169.262c-67.969 0-108.655-14.338-110.637-21.749.052-36.777 49.666-66.689 110.637-66.689 60.965 0 110.575 29.907 110.636 66.678-1.932 7.406-42.622 21.76-110.636 21.76z"/>
- <path fill="currentColor" d="M218.769 305.288c26.479-15.872 44.227-44.258 44.227-76.67 0-49.677-41.543-90.092-92.599-90.092-51.056 0-92.599 40.415-92.599 90.092 0 32.412 17.748 60.798 44.227 76.67-57.175 12.477-97.294 46.562-97.294 87.811 0 33.755 91.567 42.762 145.666 42.762 54.099 0 145.666-9.007 145.666-42.762 0-41.249-40.119-75.334-97.294-87.811zm-121.895-76.67c0-39.429 32.986-71.509 73.523-71.509s73.523 32.08 73.523 71.509c0 39.43-32.986 71.503-73.523 71.503s-73.523-32.073-73.523-71.503zm73.523 188.66c-77.767 0-124.318-15.982-126.585-24.242.059-40.991 56.825-74.331 126.585-74.331 69.753 0 126.514 33.333 126.584 74.319-2.21 8.254-48.766 24.254-126.584 24.254z"/>
- </g>
+<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-people" viewBox="0 0 16 16">
+ <path d="M15 14s1 0 1-1-1-4-5-4-5 3-5 4 1 1 1 1h8zm-7.978-1A.261.261 0 0 1 7 12.996c.001-.264.167-1.03.76-1.72C8.312 10.629 9.282 10 11 10c1.717 0 2.687.63 3.24 1.276.593.69.758 1.457.76 1.72l-.008.002a.274.274 0 0 1-.014.002H7.022zM11 7a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm3-2a3 3 0 1 1-6 0 3 3 0 0 1 6 0zM6.936 9.28a5.88 5.88 0 0 0-1.23-.247A7.35 7.35 0 0 0 5 9c-4 0-5 3-5 4 0 .667.333 1 1 1h4.216A2.238 2.238 0 0 1 5 13c0-1.01.377-2.042 1.09-2.904.243-.294.526-.569.846-.816zM4.92 10A5.493 5.493 0 0 0 4 13H1c0-.26.164-1.03.76-1.724.545-.636 1.492-1.256 3.16-1.275zM1.5 5.5a3 3 0 1 1 6 0 3 3 0 0 1-6 0zm3-2a2 2 0 1 0 0 4 2 2 0 0 0 0-4z"/>
</svg>
diff --git a/backend/app/views/spree/admin/shared/_account_nav.html.erb b/backend/app/views/spree/admin/shared/_account_nav.html.erb
index 29f05187f9..baa22c2e47 100644
--- a/backend/app/views/spree/admin/shared/_account_nav.html.erb
+++ b/backend/app/views/spree/admin/shared/_account_nav.html.erb
@@ -1,8 +1,8 @@
<% if try_spree_current_user %>
<div class="btn-group">
- <button id="accountNav" type="button" class="btn text-light" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
- <%= svg_icon name: "user.svg", width: '24', height: '24' %>
+ <button id="accountNav" type="button" class="btn text-light px-3" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+ <%= svg_icon name: "user.svg", width: '24', height: '24', classes: 'mb-0' %>
</button>
<div class="dropdown-menu dropdown-menu-right overflow-hidden mt-2 p-0 mr-2">
diff --git a/backend/app/views/spree/admin/shared/_header.html.erb b/backend/app/views/spree/admin/shared/_header.html.erb
index fe2e6e1c1e..98bab63b09 100644
--- a/backend/app/views/spree/admin/shared/_header.html.erb
+++ b/backend/app/views/spree/admin/shared/_header.html.erb
@@ -1,16 +1,17 @@
<header class="header logged-in">
- <nav class="navbar fixed-top navbar-dark">
+ <nav class="navbar fixed-top navbar-dark flex-nowrap">
<div class="col p-0 d-lg-none">
<button
id="sidebar-open"
- class="navbar-toggler h-100 text-light"
+ class="navbar-toggler h-100 text-light px-3"
type="button"
aria-expanded="false"
aria-label="Toggle navigation">
<%= svg_icon name: "menu.svg", width: '20', height: '20' %>
</button>
</div>
- <div class="col-auto text-center text-lg-left px-0 px-lg-2 align-items-center">
+
+ <div id="storeSwitcherDropdown" class="col-auto text-center text-lg-left px-0 px-lg-2 align-items-center dropdown">
<%= render partial: 'spree/admin/shared/store_switcher' %>
</div>
diff --git a/backend/app/views/spree/admin/shared/_store_switcher.html.erb b/backend/app/views/spree/admin/shared/_store_switcher.html.erb
index 76ea3bcc37..170cfe135a 100644
--- a/backend/app/views/spree/admin/shared/_store_switcher.html.erb
+++ b/backend/app/views/spree/admin/shared/_store_switcher.html.erb
@@ -1,18 +1,16 @@
<% if can?(:admin, current_store) %>
- <div id="storeSwitcherDropdown" class="dropdown">
-
<span class="d-none d-lg-inline text-light">
<%= svg_icon name: "spree-icon.svg", width: '35', height: '35' %>
</span>
<a class="px-0 py-1 btn text-light" id="storeSelectorDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
- <%= current_store.unique_name %> <%= svg_icon name: "chevron-down.svg", width: '12', height: '12', classes: 'ml-1 mb-0' %>
+ <span class="d-sm-none"><%= svg_icon name: "store.svg", width: '18', height: '18' %></span>
+ <span class="d-none d-sm-inline"><%= current_store.name %></span> (<%= current_store.code %>) <%= svg_icon name: "chevron-down.svg", width: '12', height: '12', classes: 'ml-1 mb-0' %>
</a>
- <div class="dropdown-menu dropdown-menu-left overflow-hidden mt-2 py-0" aria-labelledby="storeSelectorDropdown">
+ <div class="dropdown-menu dropdown-menu-left overflow-hidden ml-lg-2 mt-2 py-0" aria-labelledby="storeSelectorDropdown">
<% @stores.each do |store| %>
<%= store_switcher_link(store) %>
<% end %>
</div>
- </div>
<% end %>
diff --git a/backend/spec/features/admin/menus/index_menu_spec.rb b/backend/spec/features/admin/menus/index_menu_spec.rb
index 6f992ff072..66e38dede9 100644
--- a/backend/spec/features/admin/menus/index_menu_spec.rb
+++ b/backend/spec/features/admin/menus/index_menu_spec.rb
@@ -14,11 +14,13 @@ describe 'Menus Index', type: :feature do
end
context 'when menus are present' do
+ let!(:other_store) { create(:store) }
let!(:main_menu) { create(:menu, name: 'Main Menu') }
let!(:main_menu_fr) { create(:menu, name: 'Main Menu FR', locale: 'fr') }
-
let!(:footer_menu) { create(:menu, name: 'Footer Menu', location: 'footer') }
+ let!(:main_menu_other_store) { create(:menu, name: 'Other Store Main Menu', store: other_store) }
+
before do
visit spree.admin_menus_path
I18n.backend.store_translations(:fr,
@@ -29,13 +31,19 @@ describe 'Menus Index', type: :feature do
})
end
- it 'lists each menu with stores' do
+ it 'lists each menu' do
within_table('menusTable') do
expect(page).to have_text 'Main Menu'
expect(page).to have_text 'Footer Menu'
end
end
+ it 'does not list menus from other store' do
+ within_table('menusTable') do
+ expect(page).not_to have_text 'Other Store Main Menu'
+ end
+ end
+
it 'does not prompt you to create your first menu' do
expect(page).not_to have_text Spree.t('admin.navigation.you_have_no_menus')
end