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.

Fixed creating new Stores in dev environment plus added a nice UI for… (#12617)

Damian Legawiec8c8d7a587097
diff --git a/admin/app/assets/stylesheets/spree/admin/components/_dropdowns.scss b/admin/app/assets/stylesheets/spree/admin/components/_dropdowns.scss
index 72bf80a578..9f4361f7dc 100644
--- a/admin/app/assets/stylesheets/spree/admin/components/_dropdowns.scss
+++ b/admin/app/assets/stylesheets/spree/admin/components/_dropdowns.scss
@@ -26,7 +26,6 @@
box-shadow: $dropdown-box-shadow;
.dropdown-item, .dropdown-header {
- margin-bottom: 0.25rem;
padding-left: $input-btn-padding-x;
padding-right: $input-btn-padding-x;
padding-top: $input-btn-padding-y;
@@ -34,6 +33,7 @@
}
.dropdown-item {
+ margin-bottom: 0.25rem;
border-radius: $border-radius;
display: flex;
align-items: center;
diff --git a/admin/app/assets/stylesheets/spree/admin/components/_main.scss b/admin/app/assets/stylesheets/spree/admin/components/_main.scss
index 89e2790d90..2f8abbc635 100644
--- a/admin/app/assets/stylesheets/spree/admin/components/_main.scss
+++ b/admin/app/assets/stylesheets/spree/admin/components/_main.scss
@@ -82,7 +82,7 @@ turbo-frame[loading] .spinner-border, turbo-frame[busy] .spinner-border {
}
}
- .badge {
+ .badge:not(.badge-info) {
@extend .badge-light;
}
}
diff --git a/admin/app/assets/stylesheets/spree/admin/global/_variables.scss b/admin/app/assets/stylesheets/spree/admin/global/_variables.scss
index d49de62cdf..e58f2f600a 100644
--- a/admin/app/assets/stylesheets/spree/admin/global/_variables.scss
+++ b/admin/app/assets/stylesheets/spree/admin/global/_variables.scss
@@ -21,13 +21,16 @@ $black: #000000 !default;
$blue: #0077ff !default;
$white: #FFFFFF !default;
+$action: #f1faff !default;
+$action-border: #e2ecff !default;
+
$theme-colors: (
"white": $white,
"black": $black,
"primary": $primary,
"secondary": rgba($blue, 0.1),
- "action": #f1faff,
- "action-border": #e2ecff,
+ "action": $action,
+ "action-border": $action-border,
"active": $gray-25,
"partial": #E2E8F0,
"warning": #ffe17d,
@@ -67,6 +70,9 @@ $border-color: $gray-100 !default;
$input-border-color: $gray-100 !default;
$list-group-border-color: $border-color !default;
$list-group-hover-bg: $gray-25 !default;
+$list-group-active-bg: $action !default;
+$list-group-active-border-color: $action-border !default;
+
$thumbnail-border-color: $gray-100 !default;
$hr-border-color: $border-color !default;
$table-border-color: $gray-50 !default;
diff --git a/admin/app/views/spree/admin/dashboard/_setup_progress.html.erb b/admin/app/views/spree/admin/dashboard/_setup_progress.html.erb
index a22f5d41d5..7dc5caa273 100644
--- a/admin/app/views/spree/admin/dashboard/_setup_progress.html.erb
+++ b/admin/app/views/spree/admin/dashboard/_setup_progress.html.erb
@@ -2,12 +2,14 @@
<div class="card-body">
<div class="mb-3">
Your overall setup progress
- <span class="float-right badge badge-<%= current_store.setup_completed? ? 'success' : 'light' %>">
+ <span class="float-right badge badge-<%= current_store.setup_completed? ? 'success' : 'info' %>">
<% if current_store.setup_completed? %>
<%= icon('check', class: 'text-success') %>
<% end %>
- <%= current_store.setup_tasks_done %> of <%= current_store.setup_tasks_total %> steps done
+ <span>
+ <strong><%= current_store.setup_tasks_done %></strong> of <%= current_store.setup_tasks_total %> steps done
+ </span>
</span>
</div>
<div class="progress">
diff --git a/admin/app/views/spree/admin/shared/sidebar/_store_dropdown.html.erb b/admin/app/views/spree/admin/shared/sidebar/_store_dropdown.html.erb
index 2ec98c7a0f..94501913e6 100644
--- a/admin/app/views/spree/admin/shared/sidebar/_store_dropdown.html.erb
+++ b/admin/app/views/spree/admin/shared/sidebar/_store_dropdown.html.erb
@@ -1,3 +1,42 @@
+<% if available_stores.count > 1 %>
+ <div class="modal fade" id="switch-store-modal" tabindex="-1" role="dialog" aria-labelledby="switchStoreModalLabel" aria-hidden="true">
+ <div class="modal-dialog" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <h5 class="modal-title" id="switchStoreModalLabel">
+ <%= icon 'switch-horizontal', class: 'mr-2' %>
+ <%= Spree.t(:switch_store) %>
+ </h5>
+ <button type="button" class="btn-close" data-dismiss="modal" aria-label="<%= Spree.t(:close) %>" />
+ </div>
+ <div class="modal-body">
+ <div class="list-group">
+ <% available_stores.each do |store| %>
+ <% if store.id != current_store.id %>
+ <%= link_to spree.admin_dashboard_url(host: store.url), class: 'list-group-item hover-light d-flex text-dark w-100 align-items-center text-primary' do %>
+ <%= store_admin_icon(current_store, height: 32, width: 32) %>
+ <span class="ml-3">
+ <%= store.name %>
+ </span>
+ <% end %>
+ <% else %>
+ <div class="list-group-item d-flex text-dark w-100 align-items-center cursor-disabled active">
+ <%= store_admin_icon(current_store, height: 32, width: 32) %>
+ <span class="ml-3">
+ <%= store.name %>
+ </span>
+
+ <%= icon('check', class: 'ml-auto') %>
+ </div>
+ <% end %>
+ <% end %>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+<% end %>
+
<div class="border-bottom border-bottom-dashed pb-2 d-flex align-items-center justify-content-between pr-1" id="store-menu" data-turbo-permanent>
<div class="dropdown">
<button type="button" class="btn d-flex align-items-center justify-content-between text-left dropdown-toggle d-flex align-items-center gap-2"
@@ -18,15 +57,11 @@
<% end if current_store.default_theme && can?(:manage, Spree::Theme) %>
<% if available_stores.count > 1 %>
- <div class="dropdown-header">
+ <div class="dropdown-divider"></div>
+ <%= link_to "#", class: 'dropdown-item mb-0', data: { toggle: 'modal', target: '#switch-store-modal' } do %>
+ <%= icon 'switch-horizontal' %>
<%= Spree.t(:switch_store) %>
- </div>
- <% available_stores.each do |store| %>
- <% next if store.id == current_store.id %>
- <%= link_to store.name, spree.admin_dashboard_url(host: store.url), class: 'dropdown-item' %>
<% end %>
-
- <div class="dropdown-divider"></div>
<% end %>
</div>
</div>
diff --git a/admin/app/views/spree/admin/shared/sidebar/_store_nav.html.erb b/admin/app/views/spree/admin/shared/sidebar/_store_nav.html.erb
index f8edf74d43..a1ccb38980 100644
--- a/admin/app/views/spree/admin/shared/sidebar/_store_nav.html.erb
+++ b/admin/app/views/spree/admin/shared/sidebar/_store_nav.html.erb
@@ -77,6 +77,10 @@
<%= active_link_to spree.admin_getting_started_path, class: 'nav-link' do %>
<%= icon 'map' %>
<%= Spree.t('admin.getting_started') %>
+
+ <span class="badge ml-auto badge-info">
+ <%= current_store.setup_tasks_done %><span class="opacity-50">/<%= current_store.setup_tasks_total %></span>
+ </span>
<% end %>
</li>
<% end %>
diff --git a/core/app/models/spree/theme.rb b/core/app/models/spree/theme.rb
index db36409b29..42bc25046d 100644
--- a/core/app/models/spree/theme.rb
+++ b/core/app/models/spree/theme.rb
@@ -98,7 +98,7 @@ module Spree
end
def create_default_pages
- Rails.application.config.spree.pages.each do |page_class|
+ Rails.application.config.spree.pages.map(&:to_s).map(&:constantize).each do |page_class|
next if page_class == Spree::Pages::Custom
page_class.where(pageable: self).first_or_create!
@@ -107,7 +107,7 @@ module Spree
def create_layout_sections
ApplicationRecord.transaction do
- available_layout_sections.each do |section_class|
+ available_layout_sections.map(&:to_s).map(&:constantize).each do |section_class|
section_class.where(pageable: self).first_or_create!
end
end