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
CSV Importer engine 💣 (#13199)
Damian Legawiec63b6ccf1b963
diff --git a/admin/.claude/settings.local.json b/admin/.claude/settings.local.jsonindex bf16b08ec1..1324552343 100644--- a/admin/.claude/settings.local.json+++ b/admin/.claude/settings.local.json@@ -6,9 +6,10 @@"Bash(grep:*)","Bash(bundle install:*)","Bash(bundle exec rails:*)",- "Bash(bundle exec rspec:*)"+ "Bash(bundle exec rspec:*)",+ "WebSearch"],"deny": [],"ask": []}-}\ No newline at end of file+}diff --git a/admin/app/assets/stylesheets/spree/admin/components/_alerts.scss b/admin/app/assets/stylesheets/spree/admin/components/_alerts.scssindex 2290aae22a..9220546463 100644--- a/admin/app/assets/stylesheets/spree/admin/components/_alerts.scss+++ b/admin/app/assets/stylesheets/spree/admin/components/_alerts.scss@@ -5,9 +5,9 @@.alert {background-repeat: no-repeat;background-position: 1rem center;- background-size: 1.5rem 1.5rem;- padding-left: 60px;- min-height: 3rem;+ background-size: 1rem 1rem;+ padding-left: 44px;+ min-height: 2.5rem;display: inline-flex;flex-direction: column;justify-content: center;@@ -16,34 +16,37 @@margin-bottom: 0;}- box-shadow: $box-shadow-xs;+ a {+ font-weight: $font-weight-bold;+ color: theme-color('primary');+ }}.alert-info {background-color: #f7fcff;border-color: rgba($info, 0.1) !important;- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2317a2b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='icon icon-tabler icons-tabler-outline icon-tabler-info-circle'%3E%3Cpath stroke='none' d='M0 0h24v24H0z' fill='none'/%3E%3Cpath d='M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0' /%3E%3Cpath d='M12 9h.01' /%3E%3Cpath d='M11 12h1v4h1' /%3E%3C/svg%3E");+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='icon icon-tabler icons-tabler-outline icon-tabler-info-circle'%3E%3Cpath stroke='none' d='M0 0h24v24H0z' fill='none'/%3E%3Cpath d='M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0' /%3E%3Cpath d='M12 9h.01' /%3E%3Cpath d='M11 12h1v4h1' /%3E%3C/svg%3E");}.alert-warning {border-color: rgba($warning, 0.1) !important;- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23ffc107' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='icon icon-tabler icons-tabler-outline icon-tabler-alert-circle'%3E%3Cpath stroke='none' d='M0 0h24v24H0z' fill='none'/%3E%3Cpath d='M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0' /%3E%3Cpath d='M12 8v4' /%3E%3Cpath d='M12 16h.01' /%3E%3C/svg%3E");+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='icon icon-tabler icons-tabler-outline icon-tabler-alert-circle'%3E%3Cpath stroke='none' d='M0 0h24v24H0z' fill='none'/%3E%3Cpath d='M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0' /%3E%3Cpath d='M12 8v4' /%3E%3Cpath d='M12 16h.01' /%3E%3C/svg%3E");}.alert-danger {background-color: #FEF2F2;border-color: #FBE3E3;color: #450A09;- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23dc2626' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='icon icon-tabler icons-tabler-outline icon-tabler-exclamation-circle'%3E%3Cpath stroke='none' d='M0 0h24v24H0z' fill='none'/%3E%3Cpath d='M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0' /%3E%3Cpath d='M12 9v4' /%3E%3Cpath d='M12 16v.01' /%3E%3C/svg%3E");+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='icon icon-tabler icons-tabler-outline icon-tabler-exclamation-circle'%3E%3Cpath stroke='none' d='M0 0h24v24H0z' fill='none'/%3E%3Cpath d='M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0' /%3E%3Cpath d='M12 9v4' /%3E%3Cpath d='M12 16v.01' /%3E%3C/svg%3E");}.alert-success {background-color: #ECFDF5;color: #092E26;border-color: #D5F9E6;- background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2310b981' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='icon icon-tabler icons-tabler-outline icon-tabler-check-circle'%3E%3Cpath stroke='none' d='M0 0h24v24H0z' fill='none'/%3E%3Cpath d='M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0' /%3E%3Cpath d='M9 12l2 2l4 -4' /%3E%3C/svg%3E");+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='icon icon-tabler icons-tabler-outline icon-tabler-check-circle'%3E%3Cpath stroke='none' d='M0 0h24v24H0z' fill='none'/%3E%3Cpath d='M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0' /%3E%3Cpath d='M9 12l2 2l4 -4' /%3E%3C/svg%3E");}.page-alerts {@@ -51,3 +54,16 @@@extend .rounded-lg;}}++.alerts-container {+ position: fixed;+ width: 100%;+ z-index: 1070;+ top: 1rem;++ .alert {+ border-width: 1px;+ box-shadow: $box-shadow-xs;+ border-radius: $border-radius-lg;+ }+}\ No newline at end of filediff --git a/admin/app/assets/stylesheets/spree/admin/components/_bulk_panel.scss b/admin/app/assets/stylesheets/spree/admin/components/_bulk_panel.scssindex aa8c406092..04cb3726ee 100644--- a/admin/app/assets/stylesheets/spree/admin/components/_bulk_panel.scss+++ b/admin/app/assets/stylesheets/spree/admin/components/_bulk_panel.scss@@ -13,6 +13,12 @@padding-bottom: 0;height: 2.75rem;border-radius: 0;+ background-color: transparent;+ box-shadow: none;++ &:hover {+ background-color: $gray-50;+ }}> * {diff --git a/admin/app/assets/stylesheets/spree/admin/components/_buttons.scss b/admin/app/assets/stylesheets/spree/admin/components/_buttons.scssindex f97f0c843f..3a9a9621ab 100644--- a/admin/app/assets/stylesheets/spree/admin/components/_buttons.scss+++ b/admin/app/assets/stylesheets/spree/admin/components/_buttons.scss@@ -68,13 +68,13 @@ button[disabled] .show-when-enabled { display: none; }.hover-light {&:hover, &:focus {- background-color: $gray-25;+ background-color: rgba($light, 0.5);text-decoration: none;}}.hover-gray {&:hover, &:focus {- background-color: $gray-100;+ background-color: $gray-50;text-decoration: none;}}@@ -91,23 +91,12 @@ button[disabled] .show-when-enabled { display: none; }}}-.btn-link {- color: theme-color('primary') !important;- border-color: $border-color;-- &:hover, &:focus {- text-decoration: none !important;- background-color: theme-color('action') !important;- border-color: theme-color('action-border') !important;- }-}-.btn-secondary {color: $primary;- border-color: transparent;+ border-color: rgba($primary, 0.1);&:hover, &:focus {- border-color: rgba($primary, 0.1) !important;+ border-color: rgba($primary, 0.2) !important;color: $primary !important;}@@ -143,13 +132,13 @@ button[disabled] .show-when-enabled { display: none; }}.btn-light {- background-color: $white;+ background-color: $gray-25;border-color: $border-color;color: $gray-700;&:hover, &:focus {border-color: $border-color;- background-color: $gray-25;+ background-color: $gray-50;color: $gray-900;}diff --git a/admin/app/assets/stylesheets/spree/admin/components/_cards.scss b/admin/app/assets/stylesheets/spree/admin/components/_cards.scssindex aeb21775be..dfe0171d2f 100644--- a/admin/app/assets/stylesheets/spree/admin/components/_cards.scss+++ b/admin/app/assets/stylesheets/spree/admin/components/_cards.scss@@ -63,7 +63,7 @@.card, .card-lg {box-shadow: $card-box-shadow;background-color: $card-bg;- border-radius: $border-radius-lg;+ border-radius: $card-border-radius;}.card-lg {margin-bottom: 1rem;diff --git a/admin/app/assets/stylesheets/spree/admin/components/_dialogs.scss b/admin/app/assets/stylesheets/spree/admin/components/_dialogs.scssindex 1785add8c3..d4fe83e20a 100644--- a/admin/app/assets/stylesheets/spree/admin/components/_dialogs.scss+++ b/admin/app/assets/stylesheets/spree/admin/components/_dialogs.scss@@ -78,6 +78,10 @@ dialog:open {display: flex;}+ .alerts-container {+ position: absolute;+ }+@media (max-width: 991.98px) {max-width: 100vw;min-width: 100vw;@@ -112,8 +116,8 @@ dialog:open {display: flex;justify-content: space-between;align-items: center;- background-color: $gray-25;border-top: 1px solid $gray-50;+ background-color: $gray-25;}}diff --git a/admin/app/assets/stylesheets/spree/admin/components/_dropdowns.scss b/admin/app/assets/stylesheets/spree/admin/components/_dropdowns.scssindex 577692bb22..edf42dbb47 100644--- a/admin/app/assets/stylesheets/spree/admin/components/_dropdowns.scss+++ b/admin/app/assets/stylesheets/spree/admin/components/_dropdowns.scss@@ -47,7 +47,9 @@padding-bottom: 0.4rem;margin-bottom: 0.15rem;- color: $gray-700;+ transition-property: background-color, color;+ transition-duration: 0.01s;+ transition-timing-function: ease;&:hover {background-color: $dropdown-link-hover-bg;diff --git a/admin/app/assets/stylesheets/spree/admin/components/_main.scss b/admin/app/assets/stylesheets/spree/admin/components/_main.scssindex eee2379237..6dc9a7cb10 100644--- a/admin/app/assets/stylesheets/spree/admin/components/_main.scss+++ b/admin/app/assets/stylesheets/spree/admin/components/_main.scss@@ -21,6 +21,24 @@}}+#settings-header {+ height: $header-height;+ background-color: $header-bg;+ z-index: 1000;+ position: sticky;+ top: 0;+ display: flex;+ align-items: center;+ padding: 0 0;++ #page-header {+ margin-bottom: 0;+ height: $header-height;+ padding-left: 1rem;+ padding-right: 1rem;+ }+}+.page-header-title {font-size: 1.25rem;}@@ -56,6 +74,15 @@}}+.admin-settings {+ #page-tabs, #page-alerts {+ margin-top: 0;+ margin-bottom: 0;+ padding-left: 1rem;+ padding-right: 1rem;+ }+}+.store-dropdown {display: flex;align-items: center;@@ -260,6 +287,8 @@font-size: $font-size-sm;padding: 0.5rem 1rem;margin: 0.75rem;+ border-width: 1px;+ box-shadow: $box-shadow-xs;p {margin-bottom: 0.5rem;}diff --git a/admin/app/assets/stylesheets/spree/admin/components/_media_form.scss b/admin/app/assets/stylesheets/spree/admin/components/_media_form.scssindex 4b1abca201..9621824357 100644--- a/admin/app/assets/stylesheets/spree/admin/components/_media_form.scss+++ b/admin/app/assets/stylesheets/spree/admin/components/_media_form.scss@@ -7,15 +7,23 @@overflow: hidden;border-radius: $border-radius-lg;border: 1px dashed $border-color;- background-color: rgba($gray-25, 0.5);+ background-color: $light;padding: 0.5rem;cursor: pointer;color: $gray-500;+ transition-property: background-color, border-color, color;+ transition-duration: 0.5s;+ transition-timing-function: ease;+&:hover {background-color: $action;- border-color: rgba($blue, 0.5);- color: rgba($blue, 0.8);+ border-color: rgba($blue, 0.25);+ color: rgba($primary, 0.75);++ .text-muted {+ color: rgba($primary, 0.5) !important;+ }}&:active {diff --git a/admin/app/assets/stylesheets/spree/admin/components/_tables.scss b/admin/app/assets/stylesheets/spree/admin/components/_tables.scssindex 71154d9a38..3f0f503566 100644--- a/admin/app/assets/stylesheets/spree/admin/components/_tables.scss+++ b/admin/app/assets/stylesheets/spree/admin/components/_tables.scss@@ -33,7 +33,7 @@ table.table {thead {th {- background-color: rgba($gray-25, 0.75);+ background-color: $light;@extend .text-muted;font-size: $font-size-sm;font-weight: $font-weight-normal;diff --git a/admin/app/assets/stylesheets/spree/admin/components/_tooltips.scss b/admin/app/assets/stylesheets/spree/admin/components/_tooltips.scssindex 84639f683f..a26ee337b2 100644--- a/admin/app/assets/stylesheets/spree/admin/components/_tooltips.scss+++ b/admin/app/assets/stylesheets/spree/admin/components/_tooltips.scss@@ -6,8 +6,8 @@z-index: $zindex-tooltip;background-color: $tooltip-bg;color: $tooltip-color;- border: 1px solid $border-color;- box-shadow: $box-shadow-xs;+ border: 0 none;+ box-shadow: 0px 0px 0px 1px $border-color, 0px 3px 6px -1px $gray-50, 0px 3px 6px 0px $gray-50;border-radius: $tooltip-border-radius;padding: $tooltip-padding-y $tooltip-padding-x;font-size: $tooltip-font-size;diff --git a/admin/app/assets/stylesheets/spree/admin/components/_variants_form.scss b/admin/app/assets/stylesheets/spree/admin/components/_variants_form.scssindex 72630bb453..7a1b13d1cb 100644--- a/admin/app/assets/stylesheets/spree/admin/components/_variants_form.scss+++ b/admin/app/assets/stylesheets/spree/admin/components/_variants_form.scss@@ -79,7 +79,7 @@.new_option_button {@extend .btn;- @extend .btn-link;+ @extend .btn-secondary;@extend .py-3;@extend .mt-2;width: 100%;@@ -156,6 +156,7 @@width: 100%;padding: 0 1rem;gap: 0.25rem;+ background-color: rgba($gray-25, 0.5);&__cell {display: inline-block;@@ -163,7 +164,6 @@}&__footer {- background-color: $gray-25;justify-content: center;align-items: center;padding-top: 0.5rem;diff --git a/admin/app/assets/stylesheets/spree/admin/global/_variables.scss b/admin/app/assets/stylesheets/spree/admin/global/_variables.scssindex 5d0e5777ed..5ba00d6fd4 100644--- a/admin/app/assets/stylesheets/spree/admin/global/_variables.scss+++ b/admin/app/assets/stylesheets/spree/admin/global/_variables.scss@@ -1,6 +1,6 @@// https://github.com/twbs/bootstrap/blob/v4.6.2/scss/_variables.scss-$gray-25: #F8F8F9;+$gray-25: #FAFAFB;$gray-50: #F3F3F3;$gray-100: #E3E3E3 !default;$gray-200: #D5D5D5 !default;@@ -12,7 +12,7 @@ $gray-700: #4D4D4D !default;$gray-800: #333333 !default;$gray-900: #1A1A1A !default;-$light: $gray-50 !default;+$light: $gray-25 !default;$primary: #061932 !default;$black: #000000 !default;@@ -27,7 +27,7 @@ $container-max-widths: (sm: 540px,md: 720px,lg: 960px,- xl: 1260px+ xl: 1250px) !default;$grid-gutter-width: 16px !default;@@ -35,7 +35,7 @@ $theme-colors: ("white": $white,"black": $black,"primary": $primary,- "secondary": rgba($blue, 0.1),+ "secondary": rgba($blue, 0.05),"action": $action,"action-border": $action-border,"active": $gray-25,@@ -52,8 +52,7 @@ $theme-colors: ("gray-600": $gray-600,"gray-700": $gray-700,"gray-800": $gray-800,- "gray-900": $gray-900,- "mint": #C7E15A+ "gray-900": $gray-900);$body-color: #333 !default;@@ -66,13 +65,13 @@ $font-size-plus: 0.875rem !default;$font-size-sm: 0.75rem !default;$font-size-lg: 1rem !default;$font-weight-normal: 400 !default;-$font-weight-bold: 600 !default;+$font-weight-bold: 500 !default;$headings-font-family: $font-family-sans-serif;$line-height-base: 1.5 !default;$border-radius: 0.5rem !default;$border-radius-sm: 0.4rem !default;$border-radius-lg: 0.75rem !default;-$border-color: $gray-100 !default;+$border-color: rgba($gray-100, 0.85) !default;$input-border-color: $border-color !default;$list-group-border-color: $border-color !default;$list-group-hover-bg: $gray-25 !default;@@ -91,9 +90,9 @@ $card-spacer-x: 1rem !default;$component-active-bg: $blue !default;$input-placeholder-color: $gray-500;-$input-padding-y: .5rem !default;+$input-padding-y: .55rem !default;$input-disabled-bg: $gray-25 !default;-$input-focus-border-color: $blue !default;+$input-focus-border-color: rgba($blue, 0.75) !default;$custom-select-disabled-bg: $gray-50 !default;$text-muted: $gray-400 !default;@@ -108,11 +107,13 @@ $nav-link-padding-y: .5rem !default;$nav-link-padding-x: .6rem !default;$box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),0 2px 4px -1px rgba(0, 0, 0, 0.06) !default;-$box-shadow-xs: rgba(43, 34, 51, 0.04) 0px 1px 2px !default;+$box-shadow-xs: rgba(43, 34, 51, 0.02) 0px 1px 2px !default;$box-shadow-lg: rgba(0, 5, 13, 0.5) 0px 4px 8px 2px;-$input-box-shadow: none !default;+$input-box-shadow: $box-shadow-xs !default;$btn-box-shadow: $input-box-shadow !default;+$btn-font-weight: 500 !default;+$card-border-width: 0px !default;$card-box-shadow: 0 0 0 1px $card-border-color, 0 1px 2px 0 rgba(0, 0, 0, 0.05) !default;$card-bg: $white !default;@@ -161,10 +162,11 @@ $display2-weight: 400 !default;$display3-weight: 400 !default;$display4-weight: 400 !default;+$dropdown-bg: $white !default;$dropdown-border-width: 0px !default;$dropdown-border-radius: $border-radius-lg !default;-$dropdown-link-hover-bg: $gray-50 !default;-$dropdown-box-shadow: 0px 0px 0px 1px #d1d9e080, 0px 6px 12px -3px #25292e0a, 0px 6px 18px 0px #25292e1f !default;+$dropdown-link-hover-bg: rgba($gray-100, 0.5) !default;+$dropdown-box-shadow: 0px 0px 0px 1px $border-color, 0px 6px 12px -3px $gray-50, 0px 6px 18px 0px $gray-50 !default;$dropdown-padding-x: 0.25rem !default;$dropdown-padding-y: 0.25rem !default;$dropdown-divider-bg: $gray-50 !default;@@ -183,13 +185,14 @@ $modal-show-transform: none !default;$modal-transition: transform .2s ease-out !default;$modal-scale-transform: scale(1.02) !default;$modal-header-border-width: 1px !default;-$modal-content-box-shadow-xs: 0px 0px 0px 1px #d1d9e080, 0px 6px 12px -3px #25292e0a, 0px 6px 18px 0px #25292e1f;+$modal-content-box-shadow-xs: $dropdown-box-shadow;$modal-content-box-shadow-sm-up: $modal-content-box-shadow-xs !default;$modal-footer-margin-between: 0 !default;$alert-padding-y: 0.5rem !default;$alert-padding-x: 1rem !default;-$alert-border-radius: $border-radius-lg;+$alert-border-radius: $border-radius;+$alert-border-width: 0px !default;$breadcrumb-bg: transparent !default;$breadcrumb-padding-y: 0 !default;@@ -205,7 +208,7 @@ $embed-responsive-aspect-ratios: () !default;// tables-$table-cell-padding: 1rem .50rem !default;+$table-cell-padding: 1.15rem .75rem !default;$code-color: $gray-600 !default;$code-bg: $gray-25 !default;@@ -216,6 +219,6 @@ $list-group-item-padding-x: 1rem !default;$header-bg: $body-bg !default;$header-height: 60px !default;$sidebar-width: 220px !default;-$sidebar-bg: $gray-25 !default;+$sidebar-bg: $light !default;-$progress-bar-bg: $blue !default;+$progress-bar-bg: rgba($blue, 0.75) !default;diff --git a/admin/app/assets/stylesheets/spree/admin/plugins/tom-select.scss b/admin/app/assets/stylesheets/spree/admin/plugins/tom-select.scssindex 5e17df6c83..8bfcff83f7 100644--- a/admin/app/assets/stylesheets/spree/admin/plugins/tom-select.scss+++ b/admin/app/assets/stylesheets/spree/admin/plugins/tom-select.scss@@ -87,7 +87,7 @@ $select-spinner-border-color: $select-color-border !default;.#{$select-ns}-wrapper.single{.#{$select-ns}-control {&, input {- cursor: pointer;+ cursor: default;}}}diff --git a/admin/app/assets/stylesheets/spree/admin/plugins/uppy_fixes.scss b/admin/app/assets/stylesheets/spree/admin/plugins/uppy_fixes.scssindex a70b48746f..7f723eca64 100644--- a/admin/app/assets/stylesheets/spree/admin/plugins/uppy_fixes.scss+++ b/admin/app/assets/stylesheets/spree/admin/plugins/uppy_fixes.scss@@ -1,3 +1,25 @@+.uppy-Root {+ font-family: $font-family-base !important;+ font-size: $font-size-base !important;+ color: $body-color !important;+ line-height: $line-height-base !important;+}++.uppy-Dashboard-inner {+ background-color: $light;+ border-color: $border-color;+}++.uppy-Dashboard-innerWrap, .uppy-Dashboard-inner, .uppy-Dashboard-AddFiles {+ border-radius: $border-radius-lg !important;+}++.uppy-Dashboard-Item-previewInnerWrap {+ background-color: transparent !important;+ border-radius: $border-radius-lg !important;+ box-shadow: none !important;+}+.uppy-Dashboard--modal .uppy-Dashboard-overlay {background-color: $modal-backdrop-bg !important;opacity: $modal-backdrop-opacity !important;@@ -9,9 +31,9 @@}.uppy-Dashboard-browse {- color: $blue !important;- text-decoration: none !important;- border-bottom: 0 !important;+ @extend .btn;+ @extend .btn-light;+ @extend .ml-2;}.uppy-Dashboard-close {@@ -23,3 +45,17 @@}}+.uppy-StatusBar-actionBtn {+ @extend .btn;+ @extend .btn-sm;+ @extend .btn-light;+}++.uppy-StatusBar.is-complete .uppy-StatusBar-progress {+ background-color: theme-color('blue') !important;+}++.uppy-Dashboard-AddFiles-title {+ font-weight: $font-weight-base !important;+ font-size: $font-size-base !important;+}\ No newline at end of filediff --git a/admin/app/assets/stylesheets/spree/admin/shared/_base.scss b/admin/app/assets/stylesheets/spree/admin/shared/_base.scssindex 292462f6b7..c4b7a20de3 100644--- a/admin/app/assets/stylesheets/spree/admin/shared/_base.scss+++ b/admin/app/assets/stylesheets/spree/admin/shared/_base.scss@@ -313,13 +313,6 @@ small,font-size: $font-size-sm !important;}-.alerts-container {- position: absolute;- width: 100%;- z-index: 1070;- top: 1rem;-}-// tailwind matchers.gap-1 {@@ -697,8 +690,7 @@ div.uppy-Root {.breadcrumb {gap: 0.5rem;align-items: center;- color: $gray-500;- font-size: $font-size-sm;+i {opacity: 0.5;@@ -708,9 +700,12 @@ div.uppy-Root {a {color: $gray-500;text-decoration: none;+ border-radius: $border-radius;+ padding: 0.35rem 0.5rem;&:hover {color: $primary;+ background-color: $gray-25;}}}diff --git a/admin/app/assets/stylesheets/spree/admin/shared/_forms.scss b/admin/app/assets/stylesheets/spree/admin/shared/_forms.scssindex 0f0c7d4512..92d739ee95 100644--- a/admin/app/assets/stylesheets/spree/admin/shared/_forms.scss+++ b/admin/app/assets/stylesheets/spree/admin/shared/_forms.scss@@ -28,8 +28,9 @@ label {.form-control, .text-input, .trix-container, .ts-control, trix-toolbar .trix-dialog .trix-input, .custom-select, .input-group-text, .custom-file-label {box-shadow: $input-box-shadow;- transition-property: box-shadow;- transition-duration: 0.2s;+ transition-property: box-shadow, border-color;+ transition-duration: 0.25s;+ transition-timing-function: ease;&:disabled, &[readonly] {@extend .shadow-none;@@ -71,7 +72,7 @@ input[type="file"] {}.custom-select, .form-control, .ts-control {&:hover:not(:focus):not(:active):not(.active):not(:focus-visible):not(:focus-within) {- border: 1px solid $gray-200;+ border: 1px solid $gray-100;}}diff --git a/admin/app/controllers/concerns/spree/admin/settings_concern.rb b/admin/app/controllers/concerns/spree/admin/settings_concern.rbnew file mode 100644index 0000000000..a32ec3e21d--- /dev/null+++ b/admin/app/controllers/concerns/spree/admin/settings_concern.rb@@ -0,0 +1,23 @@+module Spree+ module Admin+ module SettingsConcern+ extend ActiveSupport::Concern++ included do+ before_action :set_settings_area_flag+ end++ def choose_layout+ return 'turbo_rails/frame' if turbo_frame_request?++ 'spree/admin_settings'+ end++ private++ def set_settings_area_flag+ @settings_area = true+ end+ end+ end+enddiff --git a/admin/app/controllers/spree/admin/admin_users_controller.rb b/admin/app/controllers/spree/admin/admin_users_controller.rbindex 45e5ef82fa..5ddd0840a5 100644--- a/admin/app/controllers/spree/admin/admin_users_controller.rb+++ b/admin/app/controllers/spree/admin/admin_users_controller.rb@@ -1,7 +1,7 @@module Spreemodule Adminclass AdminUsersController < BaseController- add_breadcrumb Spree.t(:users), :admin_admin_users_path+ include Spree::Admin::SettingsConcernskip_before_action :authorize_admin, only: [:new, :create]before_action :load_parent, except: [:new, :create]@@ -11,8 +11,6 @@ module Spreehelper_method :object_url- layout :choose_layout-# GET /admin/admin_usersdef indexparams[:q] ||= {}@@ -110,7 +108,7 @@ module Spree# for self signup flow, we use the minimal layoutdef choose_layout- @invitation.present? ? 'spree/minimal' : 'spree/admin'+ @invitation.present? ? 'spree/minimal' : 'spree/admin_settings'enddef load_rolesdiff --git a/admin/app/controllers/spree/admin/custom_domains_controller.rb b/admin/app/controllers/spree/admin/custom_domains_controller.rbindex 208cb5e441..47b4144bc9 100644--- a/admin/app/controllers/spree/admin/custom_domains_controller.rb+++ b/admin/app/controllers/spree/admin/custom_domains_controller.rb@@ -1,7 +1,7 @@module Spreemodule Adminclass CustomDomainsController < ResourceController- add_breadcrumb Spree.t(:domains), :admin_custom_domains_path+ include Spree::Admin::SettingsConcernprotecteddiff --git a/admin/app/controllers/spree/admin/import_mappings_controller.rb b/admin/app/controllers/spree/admin/import_mappings_controller.rbnew file mode 100644index 0000000000..8bed45ef34--- /dev/null+++ b/admin/app/controllers/spree/admin/import_mappings_controller.rb@@ -0,0 +1,15 @@+module Spree+ module Admin+ class ImportMappingsController < ResourceController+ belongs_to 'spree/import', find_by: :number++ def update_turbo_stream_enabled?+ true+ end++ def permitted_resource_params+ params.require(:import_mapping).permit(permitted_import_mapping_attributes)+ end+ end+ end+enddiff --git a/admin/app/controllers/spree/admin/import_rows_controller.rb b/admin/app/controllers/spree/admin/import_rows_controller.rbnew file mode 100644index 0000000000..c8d86ec810--- /dev/null+++ b/admin/app/controllers/spree/admin/import_rows_controller.rb@@ -0,0 +1,7 @@+module Spree+ module Admin+ class ImportRowsController < ResourceController+ belongs_to 'spree/import', find_by: :number+ end+ end+enddiff --git a/admin/app/controllers/spree/admin/imports_controller.rb b/admin/app/controllers/spree/admin/imports_controller.rbnew file mode 100644index 0000000000..7f99efdcf4--- /dev/null+++ b/admin/app/controllers/spree/admin/imports_controller.rb@@ -0,0 +1,66 @@+module Spree+ module Admin+ class ImportsController < ResourceController+ include ActiveStorage::SetCurrent # Needed for ActiveStorage to work on development env++ new_action.before :assign_params+ create.before :assign_params+ create.before :set_user+ create.before :set_owner+ create.after :start_mapping++ # GET /admin/imports/:id+ def show+ if @object.status == 'mapping'+ @mappings = @object.mappings+ @mappings_options = @object.unmapped_file_columns.map { |file_column| [file_column, file_column] }+ else+ @rows = @object.rows.processed.includes(:item)+ end+ end++ # PUT /admin/imports/:id/complete_mapping+ def complete_mapping+ @object.complete_mapping! if @object.mapping_done?++ redirect_to spree.admin_import_path(@object)+ end++ protected++ def set_user+ @object.user = try_spree_current_user+ end++ def set_owner+ @object.owner = current_store+ end++ def start_mapping+ @object.start_mapping!+ end++ def location_after_save+ spree.admin_import_path(@object)+ end++ def assign_params+ @object.type = available_types.map(&:to_s).find { |type| type == params.dig(:import, :type) } || available_types.first.to_s+ end++ def available_types+ Spree::Import.available_types+ end++ def permitted_resource_params+ params.require(:import).permit(permitted_import_attributes)+ end++ def choose_layout+ return 'turbo_rails/frame' if turbo_frame_request? && action_name != 'show'++ 'spree/admin_wizard'+ end+ end+ end+enddiff --git a/admin/app/controllers/spree/admin/invitations_controller.rb b/admin/app/controllers/spree/admin/invitations_controller.rbindex 7e88d4e662..7af12e2786 100644--- a/admin/app/controllers/spree/admin/invitations_controller.rb+++ b/admin/app/controllers/spree/admin/invitations_controller.rb@@ -3,9 +3,6 @@ module Spreeclass InvitationsController < BaseControllerskip_before_action :authorize_admin, only: [:show, :accept]- add_breadcrumb Spree.t(:users), :admin_admin_users_path- add_breadcrumb Spree.t(:invitations), :admin_invitations_path-before_action :load_parent, except: [:show]before_action :load_invitation, only: [:destroy]before_action :load_roles, only: [:new, :create]@@ -117,7 +114,7 @@ module Spreeenddef choose_layout- action_name == 'show' ? 'spree/minimal' : 'spree/admin'+ action_name == 'show' ? 'spree/minimal' : 'spree/admin_settings'enddef model_classdiff --git a/admin/app/controllers/spree/admin/metafield_definitions_controller.rb b/admin/app/controllers/spree/admin/metafield_definitions_controller.rbindex 3590e641fe..8d7d3e3718 100644--- a/admin/app/controllers/spree/admin/metafield_definitions_controller.rb+++ b/admin/app/controllers/spree/admin/metafield_definitions_controller.rb@@ -1,7 +1,7 @@module Spreemodule Adminclass MetafieldDefinitionsController < ResourceController- add_breadcrumb Spree.t(:metafield_definitions), :admin_metafield_definitions_path+ include Spree::Admin::SettingsConcernnew_action.before :set_resource_type_from_paramsdiff --git a/admin/app/controllers/spree/admin/oauth_applications_controller.rb b/admin/app/controllers/spree/admin/oauth_applications_controller.rbindex 435b896447..cc46049cc3 100644--- a/admin/app/controllers/spree/admin/oauth_applications_controller.rb+++ b/admin/app/controllers/spree/admin/oauth_applications_controller.rb@@ -1,9 +1,9 @@module Spreemodule Adminclass OauthApplicationsController < ResourceController- before_action :set_default_scopes, only: [:new, :edit]+ include Spree::Admin::SettingsConcern- add_breadcrumb Spree.t(:developers), :admin_oauth_applications_path+ before_action :set_default_scopes, only: [:new, :edit]privatediff --git a/admin/app/controllers/spree/admin/payment_methods_controller.rb b/admin/app/controllers/spree/admin/payment_methods_controller.rbindex e258da8912..b413c81522 100644--- a/admin/app/controllers/spree/admin/payment_methods_controller.rb+++ b/admin/app/controllers/spree/admin/payment_methods_controller.rb@@ -2,7 +2,7 @@ module Spreemodule Adminclass PaymentMethodsController < ResourceControllerinclude Spree::Admin::PreferencesConcern- add_breadcrumb Spree.t(:payment_methods), :admin_payment_methods_path+ include Spree::Admin::SettingsConcernprepend_before_action :require_payment_type, only: [:new, :create]before_action -> { clear_empty_password_preferences(:payment_method) }, only: :updatediff --git a/admin/app/controllers/spree/admin/policies_controller.rb b/admin/app/controllers/spree/admin/policies_controller.rbindex e859dccf92..e0d4724340 100644--- a/admin/app/controllers/spree/admin/policies_controller.rb+++ b/admin/app/controllers/spree/admin/policies_controller.rb@@ -1,7 +1,7 @@module Spreemodule Adminclass PoliciesController < ResourceController- add_breadcrumb Spree.t(:policies), :admin_policies_path+ include Spree::Admin::SettingsConcernbefore_action :set_policy_owner, only: %i[create update]diff --git a/admin/app/controllers/spree/admin/refund_reasons_controller.rb b/admin/app/controllers/spree/admin/refund_reasons_controller.rbindex 696eed50ae..d25de0816b 100644--- a/admin/app/controllers/spree/admin/refund_reasons_controller.rb+++ b/admin/app/controllers/spree/admin/refund_reasons_controller.rb@@ -1,7 +1,7 @@module Spreemodule Adminclass RefundReasonsController < ResourceController- add_breadcrumb Spree.t(:refund_reasons), :admin_refund_reasons_path+ include Spree::Admin::SettingsConcernprivatediff --git a/admin/app/controllers/spree/admin/reimbursement_types_controller.rb b/admin/app/controllers/spree/admin/reimbursement_types_controller.rbindex 36c5fe835f..65ac81869f 100644--- a/admin/app/controllers/spree/admin/reimbursement_types_controller.rb+++ b/admin/app/controllers/spree/admin/reimbursement_types_controller.rb@@ -1,7 +1,7 @@module Spreemodule Adminclass ReimbursementTypesController < ResourceController- add_breadcrumb Spree.t(:reimbursement_types), :admin_reimbursement_types_path+ include Spree::Admin::SettingsConcernprivatediff --git a/admin/app/controllers/spree/admin/return_authorization_reasons_controller.rb b/admin/app/controllers/spree/admin/return_authorization_reasons_controller.rbindex 8a7610afd0..896e1e79eb 100644--- a/admin/app/controllers/spree/admin/return_authorization_reasons_controller.rb+++ b/admin/app/controllers/spree/admin/return_authorization_reasons_controller.rb@@ -1,7 +1,7 @@module Spreemodule Adminclass ReturnAuthorizationReasonsController < ResourceController- add_breadcrumb Spree.t(:return_authorization_reasons), :admin_return_authorization_reasons_path+ include Spree::Admin::SettingsConcernprivatediff --git a/admin/app/controllers/spree/admin/return_authorizations_controller.rb b/admin/app/controllers/spree/admin/return_authorizations_controller.rbindex d9e73324be..14cffbde34 100644--- a/admin/app/controllers/spree/admin/return_authorizations_controller.rb+++ b/admin/app/controllers/spree/admin/return_authorizations_controller.rb@@ -1,8 +1,7 @@module Spreemodule Adminclass ReturnAuthorizationsController < ResourceController- add_breadcrumb_icon 'receipt-refund'- add_breadcrumb Spree.t(:returns), :admin_customer_returns_path+ include Spree::Admin::SettingsConcerndef index; enddiff --git a/admin/app/controllers/spree/admin/roles_controller.rb b/admin/app/controllers/spree/admin/roles_controller.rbindex 91a73b1954..482ad6748a 100644--- a/admin/app/controllers/spree/admin/roles_controller.rb+++ b/admin/app/controllers/spree/admin/roles_controller.rb@@ -1,8 +1,7 @@module Spreemodule Adminclass RolesController < ResourceController- add_breadcrumb Spree.t(:users), :admin_admin_users_path- add_breadcrumb Spree.t(:roles), :admin_roles_path+ include Spree::Admin::SettingsConcernprivatediff --git a/admin/app/controllers/spree/admin/shipping_categories_controller.rb b/admin/app/controllers/spree/admin/shipping_categories_controller.rbindex 30cd1de8b9..dd6be4f023 100644--- a/admin/app/controllers/spree/admin/shipping_categories_controller.rb+++ b/admin/app/controllers/spree/admin/shipping_categories_controller.rb@@ -1,7 +1,7 @@module Spreemodule Adminclass ShippingCategoriesController < ResourceController- add_breadcrumb Spree.t(:shipping_categories), :admin_shipping_categories_path+ include Spree::Admin::SettingsConcernprivatediff --git a/admin/app/controllers/spree/admin/shipping_methods_controller.rb b/admin/app/controllers/spree/admin/shipping_methods_controller.rbindex bc5d9c07a6..cfa14237b0 100644--- a/admin/app/controllers/spree/admin/shipping_methods_controller.rb+++ b/admin/app/controllers/spree/admin/shipping_methods_controller.rb@@ -1,11 +1,11 @@module Spreemodule Adminclass ShippingMethodsController < ResourceController+ include Spree::Admin::SettingsConcern+before_action :load_data, except: :indexbefore_action :set_default_values, only: :new- add_breadcrumb Spree.t(:shipping_methods), :admin_shipping_methods_path-privatedef set_default_valuesdiff --git a/admin/app/controllers/spree/admin/stock_locations_controller.rb b/admin/app/controllers/spree/admin/stock_locations_controller.rbindex 5cddc62602..418ff0a725 100644--- a/admin/app/controllers/spree/admin/stock_locations_controller.rb+++ b/admin/app/controllers/spree/admin/stock_locations_controller.rb@@ -1,9 +1,9 @@module Spreemodule Adminclass StockLocationsController < ResourceController- before_action :set_country, only: :new+ include Spree::Admin::SettingsConcern- add_breadcrumb Spree.t(:stock_locations), :admin_stock_locations_path+ before_action :set_country, only: :new# PUT /admin/stock_locations/:id/mark_as_defaultdef mark_as_defaultdiff --git a/admin/app/controllers/spree/admin/stores_controller.rb b/admin/app/controllers/spree/admin/stores_controller.rbindex cf5c1756c5..d0eec590b0 100644--- a/admin/app/controllers/spree/admin/stores_controller.rb+++ b/admin/app/controllers/spree/admin/stores_controller.rb@@ -1,6 +1,8 @@module Spreemodule Adminclass StoresController < Spree::Admin::BaseController+ include Spree::Admin::SettingsConcern+before_action :load_store, only: [:edit, :update]before_action :normalize_supported_currencies, only: [:update]before_action :normalize_supported_locales, only: [:update]diff --git a/admin/app/controllers/spree/admin/tax_categories_controller.rb b/admin/app/controllers/spree/admin/tax_categories_controller.rbindex b6f6f6985e..65eabc424e 100644--- a/admin/app/controllers/spree/admin/tax_categories_controller.rb+++ b/admin/app/controllers/spree/admin/tax_categories_controller.rb@@ -1,7 +1,7 @@module Spreemodule Adminclass TaxCategoriesController < ResourceController- add_breadcrumb Spree.t(:tax_categories), :admin_tax_categories_path+ include Spree::Admin::SettingsConcernprivatediff --git a/admin/app/controllers/spree/admin/tax_rates_controller.rb b/admin/app/controllers/spree/admin/tax_rates_controller.rbindex 7d180c64e5..20b276e94f 100644--- a/admin/app/controllers/spree/admin/tax_rates_controller.rb+++ b/admin/app/controllers/spree/admin/tax_rates_controller.rb@@ -1,11 +1,11 @@module Spreemodule Adminclass TaxRatesController < ResourceController+ include Spree::Admin::SettingsConcern+before_action :load_databefore_action :set_defaults, only: :new- add_breadcrumb Spree.t(:tax_rates), :admin_tax_rates_path-privatedef set_defaultsdiff --git a/admin/app/controllers/spree/admin/webhooks_subscribers_controller.rb b/admin/app/controllers/spree/admin/webhooks_subscribers_controller.rbindex 0805d48dbd..5d7fd286ad 100644--- a/admin/app/controllers/spree/admin/webhooks_subscribers_controller.rb+++ b/admin/app/controllers/spree/admin/webhooks_subscribers_controller.rb@@ -1,14 +1,13 @@module Spreemodule Adminclass WebhooksSubscribersController < ResourceController+ include Spree::Admin::SettingsConcern+before_action :set_supported_events, except: [:index, :show]create.before :process_subscriptionsupdate.before :process_subscriptions- add_breadcrumb Spree.t(:developers), :admin_oauth_applications_path- add_breadcrumb Spree.t(:webhooks), :admin_webhooks_subscribers_path-def show@webhooks_subscriber = Webhooks::Subscriber.find(params[:id])@events = @webhooks_subscriber.events.order(created_at: :desc).page(params[:page]).per(params[:per_page])diff --git a/admin/app/controllers/spree/admin/zones_controller.rb b/admin/app/controllers/spree/admin/zones_controller.rbindex bfe9d467be..e7d99e567c 100644--- a/admin/app/controllers/spree/admin/zones_controller.rb+++ b/admin/app/controllers/spree/admin/zones_controller.rb@@ -1,7 +1,7 @@module Spreemodule Adminclass ZonesController < ResourceController- add_breadcrumb Spree.t(:zones), :admin_zones_path+ include Spree::Admin::SettingsConcernbefore_action :load_data, except: :indexdef newdiff --git a/admin/app/helpers/spree/admin/base_helper.rb b/admin/app/helpers/spree/admin/base_helper.rbindex ce1a00b0c0..760eca0ed8 100644--- a/admin/app/helpers/spree/admin/base_helper.rb+++ b/admin/app/helpers/spree/admin/base_helper.rb@@ -34,11 +34,16 @@ module Spree# check if the current controller is a settings controller# this is used to display different sidebar navigation for settings pages# @return [Boolean]+ def settings_area?+ @settings_area.present?+ end+def settings_active?- @settings_active || %w[admin_users audits custom_domains exports imports invitations oauth_applications+ Spree::Deprecation.warn('settings_active? is deprecated and will be removed in Spree 6.0. Please use settings_area? instead')+ @settings_active || %w[admin_users audits custom_domains exports invitations oauth_applicationspayment_methods refund_reasons reimbursement_types return_authorization_reasons rolesshipping_categories shipping_methods stock_locations store_credit_categories- stores tax_categories tax_rates webhooks webhooks_subscribers zones policies metafield_definitions].include?(controller_name)+ stores tax_categories tax_rates webhooks webhooks_subscribers zones policies metafield_definitions].include?(controller_name) || settings_area?end# @return [Array<String>] the available countries for checkoutdiff --git a/admin/app/helpers/spree/admin/navigation_helper.rb b/admin/app/helpers/spree/admin/navigation_helper.rbindex a349117122..c76dec54b2 100644--- a/admin/app/helpers/spree/admin/navigation_helper.rb+++ b/admin/app/helpers/spree/admin/navigation_helper.rb@@ -303,7 +303,7 @@ module Spreeenddef render_breadcrumb_icon- if settings_active?+ if settings_area?icon('settings')elsif @breadcrumb_iconicon(@breadcrumb_icon)diff --git a/admin/app/javascript/spree/admin/application.js b/admin/app/javascript/spree/admin/application.jsindex 50643bf90a..e3da1b1101 100644--- a/admin/app/javascript/spree/admin/application.js+++ b/admin/app/javascript/spree/admin/application.js@@ -42,11 +42,11 @@ import PasswordVisibility from 'stimulus-password-visibility'import RailsNestedForm from '@stimulus-components/rails-nested-form'import Reveal from 'stimulus-reveal-controller'import Sortable from 'stimulus-sortable'-import { Tabs } from 'tailwindcss-stimulus-components'import ActiveStorageUpload from 'spree/admin/controllers/active_storage_upload_controller'import AdminController from 'spree/admin/controllers/admin_controller'import AssetUploaderController from 'spree/admin/controllers/asset_uploader_controller'import AutocompleteSelectController from 'spree/admin/controllers/autocomplete_select_controller'+import AutoScrollController from 'spree/admin/controllers/auto_scroll_controller'import BetterSliderController from 'spree/admin/controllers/better_slider_controller'import BlockFormController from 'spree/admin/controllers/block_form_controller'import BootstrapTabs from 'spree/admin/controllers/bootstrap_tabs_controller'@@ -61,6 +61,7 @@ import DrawerController from 'spree/admin/controllers/drawer_controller'import FiltersController from 'spree/admin/controllers/filters_controller'import FontPickerController from 'spree/admin/controllers/font_picker_controller'import HighlightController from 'spree/admin/controllers/highlight_controller'+import ImportFormController from 'spree/admin/controllers/import_form_controller'import MediaFormController from 'spree/admin/controllers/media_form_controller'import MultiInputController from 'spree/admin/controllers/multi_input_controller'import MultiTomSelectController from 'spree/admin/controllers/multi_tom_select_controller'@@ -83,6 +84,7 @@ import SortableAutoSubmit from 'spree/admin/controllers/sortable_auto_submit_conimport SortableTree from 'spree/admin/controllers/sortable_tree_controller'import StockTransferController from 'spree/admin/controllers/stock_transfer_controller'import StoreFormController from 'spree/admin/controllers/store_form_controller'+import TabsController from 'spree/admin/controllers/tabs_controller'import TooltipController from 'spree/admin/controllers/tooltip_controller'import UnitSystemController from 'spree/admin/controllers/unit_system_controller'import VariantsFormController from 'spree/admin/controllers/variants_form_controller'@@ -96,6 +98,7 @@ application.register('address-autocomplete', AddressAutocompleteController)application.register('address-form', AddressFormController)application.register('admin', AdminController)application.register('asset-uploader', AssetUploaderController)+application.register('auto-scroll', AutoScrollController)application.register('auto-submit', AutoSubmit)application.register('autocomplete-select', AutocompleteSelectController)application.register('better-slider', BetterSliderController)@@ -117,6 +120,7 @@ application.register('enable-button', EnableButtonController)application.register('filters', FiltersController)application.register('font-picker', FontPickerController)application.register('highlight', HighlightController)+application.register('import-form', ImportFormController)application.register('media-form', MediaFormController)application.register('multi-input', MultiInputController)application.register('multi-tom-select', MultiTomSelectController)@@ -144,7 +148,7 @@ application.register('sortable-auto-submit', SortableAutoSubmit)application.register('sortable-tree', SortableTree)application.register('stock-transfer', StockTransferController)application.register('store-form', StoreFormController)-application.register('tabs', Tabs)+application.register('tabs', TabsController)application.register('tooltip', TooltipController)application.register('textarea-autogrow', TextareaAutogrow)application.register('unit-system', UnitSystemController)diff --git a/admin/app/javascript/spree/admin/controllers/active_storage_upload_controller.js b/admin/app/javascript/spree/admin/controllers/active_storage_upload_controller.jsindex f8d57752fe..6eaa8913d7 100644--- a/admin/app/javascript/spree/admin/controllers/active_storage_upload_controller.js+++ b/admin/app/javascript/spree/admin/controllers/active_storage_upload_controller.js@@ -15,7 +15,12 @@ export default class extends Controller {autoSubmit: Boolean,multiple: { type: Boolean, default: false },crop: { type: Boolean, default: false },- allowedFileTypes: { type: Array, default: [] }+ allowedFileTypes: { type: Array, default: [] },+ closeAfterFinish: { type: Boolean, default: true },+ inline: { type: Boolean, default: false },+ height: Number,+ hideCancelButton: { type: Boolean, default: false },+ disableThumbnailGenerator: { type: Boolean, default: false }}connect() {@@ -36,14 +41,24 @@ export default class extends Controller {let dashboardOptions = {}if (this.cropValue == true) {dashboardOptions = {- autoOpen: 'imageEditor'+ autoOpen: 'imageEditor',+ closeAfterFinish: this.closeAfterFinishValue}- } else {- dashboardOptions = {- closeAfterFinish: true+ }++ if (this.inlineValue == true) {+ dashboardOptions.inline = true+ dashboardOptions.closeAfterFinish = false+ dashboardOptions.target = this.element+ if (this.heightValue) {+ dashboardOptions.height = this.heightValue}+ dashboardOptions.doneButtonHandler = null}+ dashboardOptions.hideCancelButton = this.hideCancelButtonValue+ dashboardOptions.disableThumbnailGenerator = this.disableThumbnailGeneratorValue+this.uppy.use(Dashboard, dashboardOptions)if (this.cropValue == true) {@@ -110,7 +125,13 @@ export default class extends Controller {}handleUI(file, response = null) {- this.placeholderTarget.style = 'display: none !important'+ if (this.hasPlaceholderTarget) {+ this.placeholderTarget.style = 'display: none !important'+ }++ if (this.hasToolbarTarget) {+ this.toolbarTarget.style = 'display: none !important'+ }const signedId = response?.signed_id || file.response?.signed_id@@ -141,6 +162,17 @@ export default class extends Controller {}this.element.appendChild(hiddenField)++ // Propagate a custom 'active-storage-upload:success' event when upload completes and field updated+ const event = new CustomEvent('active-storage-upload:success', {+ detail: {+ file: file,+ signedId: signedId,+ controller: this+ },+ bubbles: true+ })+ this.element.dispatchEvent(event)}// show toolbar if attacheddiff --git a/admin/app/javascript/spree/admin/controllers/admin_controller.js b/admin/app/javascript/spree/admin/controllers/admin_controller.jsindex a048bf6b3f..e3ec65c507 100644--- a/admin/app/javascript/spree/admin/controllers/admin_controller.js+++ b/admin/app/javascript/spree/admin/controllers/admin_controller.js@@ -3,15 +3,6 @@ import { Controller } from '@hotwired/stimulus'export default class extends Controller {static targets = ['close', 'save']- close(event) {- // https://github.com/hotwired/stimulus/issues/743- if (event.type == "keydown" && !(event instanceof KeyboardEvent)) return-- if (this.hasCloseTarget) {- window.Turbo.visit(this.closeTarget.href)- }- }-save(event) {// https://github.com/hotwired/stimulus/issues/743if (event.type == "keydown" && !(event instanceof KeyboardEvent)) returndiff --git a/admin/app/javascript/spree/admin/controllers/auto_scroll_controller.js b/admin/app/javascript/spree/admin/controllers/auto_scroll_controller.jsnew file mode 100644index 0000000000..8c2c10ce7e--- /dev/null+++ b/admin/app/javascript/spree/admin/controllers/auto_scroll_controller.js@@ -0,0 +1,33 @@+import { Controller } from "@hotwired/stimulus"++export default class extends Controller {+ connect() {+ // Watch for new elements being added to this element+ const observer = new MutationObserver(this.handleMutations.bind(this))+ observer.observe(this.element, { childList: true })+ this.observer = observer+ }++ disconnect() {+ this.observer?.disconnect()+ }++ handleMutations(mutations) {+ for (const mutation of mutations) {+ if (mutation.addedNodes.length > 0) {+ // Find the first added node that is not a HTML comment node+ // Rails injects a HTML comments when rendering partials+ const newNode = Array.from(mutation.addedNodes).find(+ node => node.nodeType !== Node.COMMENT_NODE && node.nodeType !== Node.TEXT_NODE+ )+ if (newNode) {+ this.scrollToElement(newNode)+ }+ }+ }+ }++ scrollToElement(element) {+ element.scrollIntoView({ behavior: "smooth", block: "end" })+ }+}\ No newline at end of filediff --git a/admin/app/javascript/spree/admin/controllers/enable_button_controller.js b/admin/app/javascript/spree/admin/controllers/enable_button_controller.jsdeleted file mode 100644index 8522acc76a..0000000000--- a/admin/app/javascript/spree/admin/controllers/enable_button_controller.js+++ /dev/null@@ -1,29 +0,0 @@-import { Controller } from "@hotwired/stimulus"--export default class extends Controller {- static targets = ["input", "button"];- static values = {- allowBlank: { type: Boolean, default: false },- disableWhenNotChanged: { type: Boolean, default: false },- }-- connect() {- this.buttonTarget.setAttribute("disabled", true);-- if (this.inputTargets.every((input) => input.value || input.checked || this.allowBlankValue) && !this.disableWhenNotChangedValue) {- this.buttonTarget.removeAttribute("disabled");- }-- this.inputTargets.forEach((input) => {- input.addEventListener("input", (event) => this.handleChange(event));- });- }-- handleChange(event) {- if (this.inputTargets.every((input) => event.target.value || event.target.checked || this.allowBlankValue)) {- this.buttonTarget.removeAttribute("disabled");- } else {- this.buttonTarget.setAttribute("disabled", true);- }- }-}diff --git a/admin/app/javascript/spree/admin/controllers/import_form_controller.js b/admin/app/javascript/spree/admin/controllers/import_form_controller.jsnew file mode 100644index 0000000000..782ee8ee1d--- /dev/null+++ b/admin/app/javascript/spree/admin/controllers/import_form_controller.js@@ -0,0 +1,27 @@+import { Controller } from "@hotwired/stimulus"++export default class extends Controller {+ static targets = ["button"]++ connect() {+ this.element.addEventListener('active-storage-upload:success', this.enableButton.bind(this))+ this.element.addEventListener('active-storage-upload:error', this.disableButton.bind(this))+ }++ disconnect() {+ this.element.removeEventListener('active-storage-upload:success', this.enableButton.bind(this))+ this.element.removeEventListener('active-storage-upload:error', this.disableButton.bind(this))+ }++ enableButton(event) {+ if (this.hasButtonTarget) {+ this.buttonTarget.disabled = false+ }+ }++ disableButton(event) {+ if (this.hasButtonTarget) {+ this.buttonTarget.disabled = true+ }+ }+}\ No newline at end of filediff --git a/admin/app/javascript/spree/admin/controllers/tabs_controller.js b/admin/app/javascript/spree/admin/controllers/tabs_controller.jsnew file mode 100644index 0000000000..a934429fd8--- /dev/null+++ b/admin/app/javascript/spree/admin/controllers/tabs_controller.js@@ -0,0 +1,21 @@+import { Controller } from '@hotwired/stimulus'++export default class extends Controller {+ static targets = ["tab", "panel"]+ static values = {+ activeTabClass: { type: String, default: "active" }+ }++ select(event) {+ const index = this.tabTargets.indexOf(event.currentTarget);+ this.showTab(index);+ }++ showTab(index) {+ this.tabTargets.forEach((tab, i) => {+ const active = i === index;+ tab.classList.toggle(this.activeTabClassValue, active);+ this.panelTargets[i].hidden = !active;+ });+ }+}\ No newline at end of filediff --git a/admin/app/views/layouts/spree/admin.html.erb b/admin/app/views/layouts/spree/admin.html.erbindex 6db3e1c6c0..cea4dbd028 100644--- a/admin/app/views/layouts/spree/admin.html.erb+++ b/admin/app/views/layouts/spree/admin.html.erb@@ -7,7 +7,7 @@<body class="admin min-vh-100 <%= controller_name %> <%= action_name %>"data-controller="admin"- data-action="keydown.esc->admin#close keydown.ctrl+s->admin#save keydown.meta+s->admin#save"+ data-action="keydown.ctrl+s->admin#save keydown.meta+s->admin#save"><%= render_admin_partials(:body_start_partials) %>@@ -15,6 +15,8 @@<%= render "spree/admin/shared/sidebar" %><main id="content" data-controller="drawer"><%= render "spree/admin/shared/content_header" %>+ <%= render "spree/admin/shared/page_tabs" %>+ <%= render "spree/admin/shared/page_alerts" %><div class="container"><%= yield %></div>diff --git a/admin/app/views/layouts/spree/admin_settings.html.erb b/admin/app/views/layouts/spree/admin_settings.html.erbnew file mode 100644index 0000000000..7031f5f274--- /dev/null+++ b/admin/app/views/layouts/spree/admin_settings.html.erb@@ -0,0 +1,35 @@+<!DOCTYPE html>+<html lang="<%= I18n.locale %>">+ <head>+ <%= render "spree/admin/shared/head" %>+ </head>++ <body class="admin admin-settings min-vh-100 <%= controller_name %> <%= action_name %>"+ data-controller="admin drawer"+ data-action="keydown.ctrl+s->admin#save keydown.meta+s->admin#save"+ >+ <%= render_admin_partials(:body_start_partials) %>++ <header id="settings-header">+ <%= render 'spree/admin/shared/back_to_dashboard' %>+ <div class="flex-grow-1">+ <%= render 'spree/admin/shared/content_header' %>+ </div>+ </header>++ <%= render "spree/admin/shared/sidebar" %>+ <main id="content">+ <%= render "spree/admin/shared/page_tabs" %>+ <div class="container pt-4">+ <%= yield(:page_alerts) %>+ <%= yield %>+ </div>+ <%= render "spree/admin/shared/footer" %>+ <%= render 'spree/admin/shared/drawer' %>+ </main>+ <%= render "spree/admin/shared/modal" %>+ <%= render "spree/admin/shared/alerts" %>++ <%= render_admin_partials(:body_end_partials) %>+ </body>+</html>diff --git a/admin/app/views/layouts/spree/admin_wizard.html.erb b/admin/app/views/layouts/spree/admin_wizard.html.erbnew file mode 100644index 0000000000..a3b843249f--- /dev/null+++ b/admin/app/views/layouts/spree/admin_wizard.html.erb@@ -0,0 +1,33 @@+<!DOCTYPE html>+<html lang="<%= I18n.locale %>">+ <head>+ <%= render "spree/admin/shared/head" %>+ </head>++ <body class="admin min-vh-100 <%= controller_name %> <%= action_name %>"+ data-controller="admin drawer"+ data-action="keydown.ctrl+s->admin#save keydown.meta+s->admin#save"+ >+ <%= render_admin_partials(:body_start_partials) %>++ <header id="header" class="d-flex align-items-center p-0">+ <%= render 'spree/admin/shared/back_to_dashboard' %>++ <% if content_for?(:steps) %>+ <ol class="d-flex align-items-center list-unstyled flex-grow-1 justify-content-between align-items-center m-0" style="height: 60px;" id="steps">+ <%= yield :steps %>+ </ol>+ <% end %>+ </header>++ <main class="pb-5">+ <%= yield %>+ </main>++ <%= render 'spree/admin/shared/drawer' %>+ <%= render "spree/admin/shared/modal" %>+ <%= render "spree/admin/shared/alerts" %>++ <%= render_admin_partials(:body_end_partials) %>+ </body>+</html>diff --git a/admin/app/views/spree/admin/classifications/index.html.erb b/admin/app/views/spree/admin/classifications/index.html.erbindex 1f6b1275fb..68992bf1b2 100644--- a/admin/app/views/spree/admin/classifications/index.html.erb+++ b/admin/app/views/spree/admin/classifications/index.html.erb@@ -14,7 +14,7 @@</p><p class="text-center" data-toggle="modal" data-target="#modal"><% if can?(:create, Spree::Classification) && @taxon.manual? %>- <%= link_to_with_icon 'plus', Spree.t(:add_products), spree.new_admin_taxon_classification_path(@taxon.id), class: 'btn btn-link', data: { turbo_frame: 'dialog_modal' } %>+ <%= link_to_with_icon 'plus', Spree.t(:add_products), spree.new_admin_taxon_classification_path(@taxon.id), class: 'btn btn-secondary', data: { turbo_frame: 'dialog_modal' } %><% end %><% end %><% end %>diff --git a/admin/app/views/spree/admin/coupon_codes/_filters.html.erb b/admin/app/views/spree/admin/coupon_codes/_filters.html.erbindex 26a340cf2e..aa52136e67 100644--- a/admin/app/views/spree/admin/coupon_codes/_filters.html.erb+++ b/admin/app/views/spree/admin/coupon_codes/_filters.html.erb@@ -28,7 +28,7 @@</div><div data-controller="tooltip">- <%= link_to spree.admin_promotion_coupon_codes_path(@promotion, format: :csv), class: 'btn btn-light bg-transparent' do %>+ <%= link_to spree.admin_promotion_coupon_codes_path(@promotion, format: :csv), class: 'btn btn-light' do %><%= icon 'download' %><%= Spree.t(:download) %><% end %>diff --git a/admin/app/views/spree/admin/dashboard/_store_preview.html.erb b/admin/app/views/spree/admin/dashboard/_store_preview.html.erbindex ce36bbe2f1..b44e796b40 100644--- a/admin/app/views/spree/admin/dashboard/_store_preview.html.erb+++ b/admin/app/views/spree/admin/dashboard/_store_preview.html.erb@@ -32,7 +32,7 @@</div><% unless current_store.default_custom_domain&.active? %><div class="card-footer border-top p-2">- <%= link_to_with_icon 'world-www', 'Connect your own domain', spree.admin_custom_domains_path, class: 'btn btn-link w-100 py-2' %>+ <%= link_to_with_icon 'world-www', 'Connect your own domain', spree.admin_custom_domains_path, class: 'btn btn-secondary w-100 py-2' %></div><% end %></div>diff --git a/admin/app/views/spree/admin/dashboard/_updater.html.erb b/admin/app/views/spree/admin/dashboard/_updater.html.erbindex 1f9bc123d2..36e236c56d 100644--- a/admin/app/views/spree/admin/dashboard/_updater.html.erb+++ b/admin/app/views/spree/admin/dashboard/_updater.html.erb@@ -9,7 +9,7 @@<% if spree_updater.latest_release['url'] %><div>- <%= external_link_to "View release notes", spree_updater.latest_release['url'], target: '_blank', class: 'btn btn-sm btn-link' %>+ <%= external_link_to "View release notes", spree_updater.latest_release['url'], target: '_blank', class: 'btn btn-sm btn-secondary' %></div><% end %></div>diff --git a/admin/app/views/spree/admin/dashboard/analytics.html.erb b/admin/app/views/spree/admin/dashboard/analytics.html.erbindex 4942a645b0..4361f43c83 100644--- a/admin/app/views/spree/admin/dashboard/analytics.html.erb+++ b/admin/app/views/spree/admin/dashboard/analytics.html.erb@@ -5,11 +5,11 @@<%= turbo_frame_tag :analytics do %><div class="card mb-4"data-controller="tabs"- data-tabs-active-tab-class="active">+ data-tabs-active-tab-class-value="active"><div class="card-header d-block border-0 h-auto p-2"><div class="row"><div class="col-6 col-lg-4 pr-2">- <div class="analytics-card-tab active" data-tabs-target="tab" data-action="click->tabs#change">+ <div class="analytics-card-tab active" data-tabs-target="tab" data-action="click->tabs#select"><div class="d-flex justify-content-center flex-column mb-3 mb-lg-0"><span class="font-size-sm text-muted">Total Sales</span><span class="font-size-lg text-dark font-weight-bold mt-1">@@ -23,7 +23,7 @@</div><div class="col-6 col-lg-2 pl-0 pr-2">- <div class="analytics-card-tab" data-tabs-target="tab" data-action="click->tabs#change">+ <div class="analytics-card-tab" data-tabs-target="tab" data-action="click->tabs#select"><div class="d-flex justify-content-center flex-column mb-3 mb-lg-0"><span class="font-size-sm text-muted">Avg. Order Value</span><span class="font-size-lg text-dark font-weight-bold mt-1 me-3"><%= @orders_average %></span>@@ -35,7 +35,7 @@</div><div class="col-6 col-lg-2 pl-0 pr-2">- <div class="analytics-card-tab" data-tabs-target="tab" data-action="click->tabs#change">+ <div class="analytics-card-tab" data-tabs-target="tab" data-action="click->tabs#select"><div class="d-flex justify-content-center flex-column mb-3 mb-lg-0"><span class="font-size-sm text-muted">Total Orders</span><span class="font-size-lg text-dark font-weight-bold mt-1 me-3"><%= @orders_total %></span>@@ -47,7 +47,7 @@</div><% if @visits_total && @visits_growth_rate %><div class="col-6 col-lg-2 pl-0 pr-2">- <div class="analytics-card-tab" data-tabs-target="tab" data-action="click->tabs#change">+ <div class="analytics-card-tab" data-tabs-target="tab" data-action="click->tabs#select"><div class="d-flex justify-content-center flex-column"><span class="font-size-sm text-muted">Visits</span><span class="font-size-lg text-dark font-weight-bold mt-1 me-3"><%= @visits_total %></span>@@ -61,7 +61,7 @@<% if @audience_total && @audience_growth_rate %><div class="col-6 col-lg-2 pl-0">- <div class="analytics-card-tab" data-tabs-target="tab" data-action="click->tabs#change">+ <div class="analytics-card-tab" data-tabs-target="tab" data-action="click->tabs#select"><div class="d-flex justify-content-center flex-column"><span class="font-size-sm text-muted">Sign-ups</span><span class="font-size-lg text-dark font-weight-bold mt-1 me-3"><%= @audience_total %></span>@@ -75,41 +75,39 @@</div></div><div class="card-body p-2">- <div class="tab-content">- <div data-tabs-target="panel" data-index="1" class="animate__animated animate__fadeIn">- <% if currency_money(current_currency).symbol_first? %>- <%= line_chart @grouped_orders_scope.sum(:total), prefix: currency_money(current_currency).symbol, zeros: true, points: false, library: {- animation: {- duration: 300,- easing: "linear"- }- } %>- <% else %>- <%= line_chart @grouped_orders_scope.sum(:total), suffix: currency_money(current_currency).symbol, zeros: true, points: false, library: {- animation: {- duration: 300,- easing: "linear"- }- } %>- <% end %>- </div>- <div data-tabs-target="panel" data-index="2" class="animate__animated animate__fadeIn">- <%= line_chart @grouped_orders_scope.average(:total), suffix: currency_money(current_currency).symbol, zeros: true, points: false %>- </div>- <div data-tabs-target="panel" data-index="3" class="animate__animated animate__fadeIn">- <%= line_chart @grouped_orders_scope.count, points: false %>- </div>- <% if @visits %>- <div data-tabs-target="panel" data-index="4" class="animate__animated animate__fadeIn">- <%= line_chart @visits.count, points: false %>- </div>- <% end %>- <% if @audience %>- <div data-tabs-target="panel" data-index="5" class="animate__animated animate__fadeIn">- <%= line_chart @audience.count, points: false %>- </div>+ <div data-tabs-target="panel" class="animate__animated animate__fadeIn">+ <% if currency_money(current_currency).symbol_first? %>+ <%= line_chart @grouped_orders_scope.sum(:total), prefix: currency_money(current_currency).symbol, zeros: true, points: false, library: {+ animation: {+ duration: 300,+ easing: "linear"+ }+ } %>+ <% else %>+ <%= line_chart @grouped_orders_scope.sum(:total), suffix: currency_money(current_currency).symbol, zeros: true, points: false, library: {+ animation: {+ duration: 300,+ easing: "linear"+ }+ } %><% end %></div>+ <div data-tabs-target="panel" class="animate__animated animate__fadeIn" hidden>+ <%= line_chart @grouped_orders_scope.average(:total), suffix: currency_money(current_currency).symbol, zeros: true, points: false %>+ </div>+ <div data-tabs-target="panel" class="animate__animated animate__fadeIn" hidden>+ <%= line_chart @grouped_orders_scope.count, points: false %>+ </div>+ <% if @visits %>+ <div data-tabs-target="panel" class="animate__animated animate__fadeIn" hidden>+ <%= line_chart @visits.count, points: false %>+ </div>+ <% end %>+ <% if @audience %>+ <div data-tabs-target="panel" class="animate__animated animate__fadeIn" hidden>+ <%= line_chart @audience.count, points: false %>+ </div>+ <% end %></div></div>diff --git a/admin/app/views/spree/admin/import_mappings/update.turbo_stream.erb b/admin/app/views/spree/admin/import_mappings/update.turbo_stream.erbnew file mode 100644index 0000000000..37784af1b3--- /dev/null+++ b/admin/app/views/spree/admin/import_mappings/update.turbo_stream.erb@@ -0,0 +1,15 @@+<%= turbo_stream.replace 'footer' do %>+ <%= render 'spree/admin/imports/mapping_footer', import: @import_mapping.import %>+<% end %>++<%= turbo_stream.replace "#{spree_dom_id(@import_mapping)}-icon" do %>+ <%= render 'spree/admin/imports/mapping_icon', mapping: @import_mapping %>+<% end %>++<% options = @import.unmapped_file_columns.map { |file_column| [file_column, file_column] } %>++<% @import.mappings.where.not(id: @import_mapping.id).each do |mapping| %>+ <%= turbo_stream.replace spree_dom_id(mapping) + '_form' do %>+ <%= render 'spree/admin/imports/mapping_form', import: @import, mapping: mapping, options: options %>+ <% end %>+<% end %>\ No newline at end of filediff --git a/admin/app/views/spree/admin/import_rows/_variant.html.erb b/admin/app/views/spree/admin/import_rows/_variant.html.erbnew file mode 100644index 0000000000..cf5848b82f--- /dev/null+++ b/admin/app/views/spree/admin/import_rows/_variant.html.erb@@ -0,0 +1 @@+<%= render "spree/admin/variants/variant", variant: item %>\ No newline at end of filediff --git a/admin/app/views/spree/admin/import_rows/show.html.erb b/admin/app/views/spree/admin/import_rows/show.html.erbnew file mode 100644index 0000000000..1b7efcfadf--- /dev/null+++ b/admin/app/views/spree/admin/import_rows/show.html.erb@@ -0,0 +1,32 @@+<%= turbo_frame_tag :drawer do %>+ <%= drawer_header(Spree.t(:row) + ' ' + @import_row.row_number.to_s) %>++ <div class="drawer-body" data-controller="highlight tabs">+ <ul class="nav nav-pills mb-3">+ <li class="nav-item">+ <a class="nav-link active" data-tabs-target="tab" data-action="click->tabs#select">JSON</a>+ </li>+ <li class="nav-item">+ <a class="nav-link" data-tabs-target="tab" data-action="click->tabs#select">Schema</a>+ </li>+ </ul>++ <div data-tabs-target="panel" class="animate__animated animate__fadeIn">+ <pre class="m-0"><code data-highlight-target="code" class="language-json d-block overflow-auto" style="height: calc(100dvh - 11rem);"><%= JSON.pretty_generate(@import_row.data_json) %></code></pre>+ </div>+ <div data-tabs-target="panel" class="animate__animated animate__fadeIn" hidden>+ <dl class="row rounded border p-2 overflow-auto" style="height: calc(100dvh - 11rem);">+ <% @import_row.to_schema_hash.each do |field_name, value| %>+ <dt class="col-sm-3"><%= field_name.humanize %></dt>+ <dd class="col-sm-9">+ <% if value.present? %>+ <%= h(value) %>+ <% else %>+ <span class="text-muted">—</span>+ <% end %>+ </dd>+ <% end %>+ </dl>+ </div>+ </div>+<% end %>\ No newline at end of filediff --git a/admin/app/views/spree/admin/imports/_footer.html.erb b/admin/app/views/spree/admin/imports/_footer.html.erbnew file mode 100644index 0000000000..eff310ae8a--- /dev/null+++ b/admin/app/views/spree/admin/imports/_footer.html.erb@@ -0,0 +1,15 @@+<footer class="position-fixed bottom-0 start-0 w-100 border-top px-4 py-3 bg-light d-flex align-items-center justify-content-between gap-3" style="z-index: 9999;" id="footer">+ <% if import.rows.any? %>+ <div class="flex-grow-1 d-flex flex-column">+ <%= progress_bar_component(import.rows.processed.count, min: 0, max: import.rows_count) %>+ </div>++ <div>+ <%= import.rows.processed.count %> / <%= import.rows_count %> rows processed+ </div>+ <% elsif import.status != 'failed' %>+ <div>+ <%= Spree.t('admin.imports.waiting_for_file_to_be_processed') %>+ </div>+ <% end %>+</footer>\ No newline at end of filediff --git a/admin/app/views/spree/admin/imports/_loader.html.erb b/admin/app/views/spree/admin/imports/_loader.html.erbnew file mode 100644index 0000000000..175280e6ea--- /dev/null+++ b/admin/app/views/spree/admin/imports/_loader.html.erb@@ -0,0 +1,14 @@+<% if import.completed? %>+ <div class="d-flex justify-content-center align-items-center my-5 flex-column pb-5">+ <%= icon('check', class: 'text-success', style: 'font-size: 4rem;') %>+ <p class="text-success"><%= Spree.t('admin.imports.import_done') %>!</p>+ <%= link_to_with_icon 'arrow-back-up', Spree.t('admin.back_to_dashboard'), spree.admin_path, class: 'btn btn-light mb-5' %>+ </div>+<% else %>+ <div class="d-flex justify-content-center align-items-center my-5 flex-column" style="height: 200px;">+ <div class="spinner-border mb-3 text-muted" role="status" style="width: 4rem; height: 4rem;">+ <span class="sr-only"><%= Spree.t(:processing) %>...</span>+ </div>+ <p class="text-muted"><%= Spree.t(:processing) %>...</p>+ </div>+<% end %>\ No newline at end of filediff --git a/admin/app/views/spree/admin/imports/_mapping.html.erb b/admin/app/views/spree/admin/imports/_mapping.html.erbnew file mode 100644index 0000000000..60861c9076--- /dev/null+++ b/admin/app/views/spree/admin/imports/_mapping.html.erb@@ -0,0 +1,13 @@+<div class="d-flex justify-content-between align-items-center border-bottom hover-light" id="<%= spree_dom_id(mapping) %>">+ <div class="text-center w-10">+ <%= render 'spree/admin/imports/mapping_icon', mapping: mapping %>+ </div>+ <div class="text-wrap w-40 px-2 py-3">+ <%= @import.import_schema.fields.find { |field| field[:name] == mapping.schema_field }[:label] %>++ <code class="ml-2"><%= mapping.schema_field %></code>+ </div>+ <div class="w-50 px-2 py-3">+ <%= render 'spree/admin/imports/mapping_form', import: @import, mapping: mapping, options: options %>+ </div>+</div>\ No newline at end of filediff --git a/admin/app/views/spree/admin/imports/_mapping_footer.html.erb b/admin/app/views/spree/admin/imports/_mapping_footer.html.erbnew file mode 100644index 0000000000..a8ca42ded6--- /dev/null+++ b/admin/app/views/spree/admin/imports/_mapping_footer.html.erb@@ -0,0 +1,20 @@+<footer class="position-fixed bottom-0 start-0 w-100 border-top px-4 py-3 bg-light d-flex align-items-center justify-content-between gap-3" id="footer" style="z-index: 9999;">+ <div class="flex-grow-1 d-flex flex-column">+ <% if import.mapping_done? %>+ <p>+ <%= icon('check', class: 'text-success') %>+ <%= Spree.t('admin.imports.all_required_columns_mapped') %>+ </p>+ <% else %>+ <p>+ <%= Spree.t('admin.imports.please_map_all_required_fields') %>+ </p>+ <% end %>+ <%= progress_bar_component(import.mapped_fields.count, min: 0, max: import.required_fields.count) %>+ </div>++ <span <% unless import.mapping_done? %>data-controller="tooltip"<% end %>>+ <%= button_to Spree.t('actions.continue'), spree.complete_mapping_admin_import_path(import), method: :put, class: 'btn btn-primary btn-lg', disabled: !import.mapping_done? %>+ <%= tooltip(Spree.t('admin.imports.please_map_all_required_fields')) unless import.mapping_done? %>+ </span>+</footer>\ No newline at end of filediff --git a/admin/app/views/spree/admin/imports/_mapping_form.html.erb b/admin/app/views/spree/admin/imports/_mapping_form.html.erbnew file mode 100644index 0000000000..05642a9f1b--- /dev/null+++ b/admin/app/views/spree/admin/imports/_mapping_form.html.erb@@ -0,0 +1,11 @@+<% options ||= import.unmapped_file_columns.map { |file_column| [file_column, file_column] } %>++<%= turbo_frame_tag spree_dom_id(mapping) + '_form' do %>+ <%= form_for mapping, url: spree.admin_import_mapping_path(import, mapping), method: :put, data: { controller: 'auto-submit' } do |f| %>+ <% select_options = options.dup %>+ <% if mapping.file_column.present? %>+ <% select_options.prepend([mapping.file_column, mapping.file_column]) %>+ <% end %>+ <%= f.select :file_column, options_for_select(select_options, mapping.file_column), { include_blank: 'Please select a column' }, { data: { action: 'auto-submit#submit', controller: 'autocomplete-select' }, id: "import_mapping_file_column_#{mapping.id}" } %>+ <% end %>+<% end %>\ No newline at end of filediff --git a/admin/app/views/spree/admin/imports/_mapping_icon.html.erb b/admin/app/views/spree/admin/imports/_mapping_icon.html.erbnew file mode 100644index 0000000000..7e26befcc4--- /dev/null+++ b/admin/app/views/spree/admin/imports/_mapping_icon.html.erb@@ -0,0 +1,6 @@+<% if mapping.required? %>+ <div id="<%= spree_dom_id(mapping) %>-icon" data-controller="tooltip">+ <%= icon('checklist', class: mapping.mapped? ? 'text-success' : 'text-muted') %>+ <%= tooltip(Spree.t('admin.imports.mapping_required')) %>+ </div>+<% end %>\ No newline at end of filediff --git a/admin/app/views/spree/admin/imports/_row.html.erb b/admin/app/views/spree/admin/imports/_row.html.erbnew file mode 100644index 0000000000..08c71e6f08--- /dev/null+++ b/admin/app/views/spree/admin/imports/_row.html.erb@@ -0,0 +1,35 @@+<div class="import_row d-flex justify-content-between align-items-center border-bottom hover-light" id="<%= dom_id(row) %>">+ <div class="text-center w-10">+ <%= row.row_number %>+ </div>+ <div class="text-wrap w-20 px-2 py-3">+ <% badge_class = case row.status+ when 'completed'+ 'success'+ when 'failed'+ 'danger'+ else+ 'light'+ end %>+ <span class="badge badge-pill badge-<%= badge_class %>">+ <%= Spree.t(row.status) %>+ </span>+ </div>+ <div class="w-60 px-2 py-3">+ <% if row.status == 'failed' %>+ <div class="text-danger"><%= row.validation_errors %></div>+ <% elsif row.status == 'completed' && row.item.present? %>+ <%= render "spree/admin/import_rows/#{row.item_type.demodulize.underscore}", item: row.item %>+ <% else %>+ <div class="d-flex align-items-center gap-2">+ <div class="spinner-border text-muted" role="status">+ <span class="sr-only"><%= Spree.t(:processing) %>...</span>+ </div>+ <%= Spree.t(:processing) %>...+ </div>+ <% end %>+ </div>+ <div class="w-10 px-2 py-3">+ <%= link_to_with_icon 'eye', Spree.t(:details), spree.admin_import_row_path(import, row), class: 'btn btn-sm btn-light', data: { action: 'drawer#open', turbo_frame: :drawer }, no_text: true %>+ </div>+</div>\ No newline at end of filediff --git a/admin/app/views/spree/admin/imports/new.html.erb b/admin/app/views/spree/admin/imports/new.html.erbnew file mode 100644index 0000000000..35dd73036a--- /dev/null+++ b/admin/app/views/spree/admin/imports/new.html.erb@@ -0,0 +1,26 @@+<%= turbo_frame_tag :drawer do %>+ <%= drawer_header(Spree.t(:import) + ' ' + Spree.t(@import.type.demodulize.pluralize.downcase)) %>+ <%= form_for @import, url: spree.admin_imports_path, data: { controller: 'import-form' } do |f| %>+ <div class="drawer-body">+ <%= f.hidden_field :type %>++ <div data-controller="active-storage-upload"+ data-active-storage-upload-auto-submit-value="false"+ data-active-storage-upload-field-name-value="<%= f.object_name %>[attachment]"+ data-active-storage-upload-allowed-file-types-value="<%= ["text/csv"].to_json %>"+ data-active-storage-upload-height-value="200"+ data-active-storage-upload-inline-value="true"+ data-active-storage-upload-hide-cancel-button-value="true"+ data-active-storage-upload-disable-thumbnail-generator-value="true"+ class="d-flex flex-column justify-content-center w-100 position-relative mb-4">+ </div>++ <%= f.spree_select :preferred_delimiter, options_for_select([',', ';', '|', '\t'], @import.preferred_delimiter) %>+ </div>++ <div class="drawer-footer">+ <%= turbo_save_button_tag Spree.t('actions.create'), data: { import_form_target: 'button' }, disabled: true %>+ <%= drawer_discard_button %>+ </div>+ <% end %>+<% end %>\ No newline at end of filediff --git a/admin/app/views/spree/admin/imports/show.html.erb b/admin/app/views/spree/admin/imports/show.html.erbnew file mode 100644index 0000000000..8fc7b6ed0a--- /dev/null+++ b/admin/app/views/spree/admin/imports/show.html.erb@@ -0,0 +1,57 @@+<% content_for :head do %>+ <%= turbo_page_requires_reload_tag %>+<% end %>++<% content_for :steps do %>+ <li class="border-right flex-grow-1 h-100 d-flex align-items-center justify-content-center <% if @import.mapping? %>active bg-white font-weight-bold<% end %>">1. Map fields</li>+ <li class="border-right flex-grow-1 h-100 d-flex align-items-center justify-content-center <% if @import.processing? %>active bg-white font-weight-bold<% end %>">2. Process rows</li>+ <li class="flex-grow-1 h-100 d-flex align-items-center justify-content-center <% if @import.complete? %>active bg-white font-weight-bold<% end %>">3. Complete</li>+<% end %>++<% if @import.status == 'mapping' %>+ <div class="d-flex justify-content-between align-items-center bg-light border-top border-bottom text-muted mt-3 sticky-top font-size-sm">+ <div class="w-10 p-2 text-center">+ <%= Spree.t('admin.imports.field_required') %>+ </div>+ <div class="w-40 p-2">+ <%= I18n.t('activerecord.attributes.spree/import_mapping.file_column') %>+ </div>+ <div class="w-50 p-2">+ <%= I18n.t('activerecord.attributes.spree/import_mapping.schema_field') %>+ </div>+ </div>+ <div id="mappings" class="mb-5">+ <%= render collection: @mappings, partial: 'spree/admin/imports/mapping', locals: { options: @mappings_options } %>+ </div>++ <%= render 'spree/admin/imports/mapping_footer', import: @import %>+<% else %>+ <%= turbo_stream_from "import_#{@import.id}_rows" %>+ <%= turbo_stream_from "import_#{@import.id}_footer" %>+ <%= turbo_stream_from "import_#{@import.id}_loader" %>++ <div class="d-flex justify-content-between align-items-center bg-light border-top border-bottom text-muted mt-3 sticky-top font-size-sm">+ <div class="w-10 p-2 text-center">+ <%= I18n.t('activerecord.attributes.spree/import_row.row_number') %>+ </div>+ <div class="w-20 p-2">+ <%= Spree.t(:status) %>+ </div>+ <div class="w-60 p-2">+ <%= Spree.t(:item) %>+ </div>+ <div class="w-10 p-2">+ <%= Spree.t(:details) %>+ </div>+ </div>++ <div id="rows" data-controller="auto-scroll">+ <%= render collection: @rows, partial: 'spree/admin/imports/row', cached: spree_base_cache_scope, locals: { import: @import } %>+ </div>++ <div id="loader" data-controller="auto-scroll">+ <%= render 'spree/admin/imports/loader', import: @import %>+ </div>++ <%= render 'spree/admin/imports/footer', import: @import %>+<% end %>\ No newline at end of filediff --git a/admin/app/views/spree/admin/option_types/_form.html.erb b/admin/app/views/spree/admin/option_types/_form.html.erbindex f1533ba7cb..feb7ffa38f 100644--- a/admin/app/views/spree/admin/option_types/_form.html.erb+++ b/admin/app/views/spree/admin/option_types/_form.html.erb@@ -52,7 +52,7 @@<tr class="hover-none"><td colspan="4" class="text-center p-2">- <button type="button" data-action="nested-form#add" class="btn btn-link py-3 w-100" id="add_option_value_button">+ <button type="button" data-action="nested-form#add" class="btn btn-secondary py-3 w-100" id="add_option_value_button"><%= icon('plus') %><%= Spree.t(:add_one) %></button>diff --git a/admin/app/views/spree/admin/orders/_customer.html.erb b/admin/app/views/spree/admin/orders/_customer.html.erbindex 0356a5608e..a7bcc9d1f4 100644--- a/admin/app/views/spree/admin/orders/_customer.html.erb+++ b/admin/app/views/spree/admin/orders/_customer.html.erb@@ -47,7 +47,7 @@</span><% end %><% if [email protected]? && can?(:update_customer, @order) %>- <%= link_to_with_icon 'plus', Spree.t('admin.orders.add_user_to_this_order'), spree.new_admin_order_user_path(@order), class: "btn btn-link mt-3" %>+ <%= link_to_with_icon 'plus', Spree.t('admin.orders.add_user_to_this_order'), spree.new_admin_order_user_path(@order), class: "btn btn-secondary mt-3" %><% end %></div><% end %>@@ -57,7 +57,7 @@<%= render 'spree/admin/shared/address', address: @order.ship_address %><% elsif can?(:update_addresses, @order) %><div data-toggle="modal" data-target="#modal">- <%= link_to_with_icon 'plus', Spree.t(:new_shipping_address), spree.new_admin_order_shipping_address_path(@order), class: "btn btn-link w-100", data: { turbo_frame: 'dialog_modal' } %>+ <%= link_to_with_icon 'plus', Spree.t(:new_shipping_address), spree.new_admin_order_shipping_address_path(@order), class: "btn btn-secondary w-100", data: { turbo_frame: 'dialog_modal' } %></div><% else %><span class="text-muted"><%= Spree.t(:no_shipping_address_available) %></span>@@ -71,7 +71,7 @@<%= render 'spree/admin/shared/address', address: @order.bill_address %><% elsif can?(:update_addresses, @order) %><div data-toggle="modal" data-target="#modal">- <%= link_to_with_icon 'plus', Spree.t(:new_billing_address), spree.new_admin_order_billing_address_path(@order), class: "btn btn-link w-100", data: { turbo_frame: 'dialog_modal' } %>+ <%= link_to_with_icon 'plus', Spree.t(:new_billing_address), spree.new_admin_order_billing_address_path(@order), class: "btn btn-secondary w-100", data: { turbo_frame: 'dialog_modal' } %></div><% else %><span class="text-muted"><%= Spree.t(:no_billing_address_available) %></span>diff --git a/admin/app/views/spree/admin/orders/_line_items.html.erb b/admin/app/views/spree/admin/orders/_line_items.html.erbindex 2b2ff64b30..528c612fa9 100644--- a/admin/app/views/spree/admin/orders/_line_items.html.erb+++ b/admin/app/views/spree/admin/orders/_line_items.html.erb@@ -10,7 +10,7 @@<div class="d-flex gap-2"><% if can?(:create, Spree::LineItem.new(order: @order)) %><div data-toggle="modal" data-target="#modal">- <%= link_to_with_icon 'plus', Spree.t(:new_line_item), spree.new_admin_order_line_item_path(@order), data: { turbo_frame: :dialog_modal }, class: "btn btn-link btn-sm" %>+ <%= link_to_with_icon 'plus', Spree.t(:new_line_item), spree.new_admin_order_line_item_path(@order), data: { turbo_frame: :dialog_modal }, class: "btn btn-secondary btn-sm" %></div><% end %><% if @order.completed? %>@@ -60,7 +60,7 @@</div><div class="card-body"><div data-toggle="modal" data-target="#modal">- <%= link_to_with_icon 'plus', Spree.t(:new_line_item), spree.new_admin_order_line_item_path(@order), data: { turbo_frame: :dialog_modal }, class: "btn btn-link w-100 py-3" %>+ <%= link_to_with_icon 'plus', Spree.t(:new_line_item), spree.new_admin_order_line_item_path(@order), data: { turbo_frame: :dialog_modal }, class: "btn btn-secondary w-100 py-3" %></div></div><% end %>diff --git a/admin/app/views/spree/admin/orders/_payments.html.erb b/admin/app/views/spree/admin/orders/_payments.html.erbindex 5b2ad17095..05080c0de4 100644--- a/admin/app/views/spree/admin/orders/_payments.html.erb+++ b/admin/app/views/spree/admin/orders/_payments.html.erb@@ -1,5 +1,5 @@<% if can?(:read, Spree::Payment) && (@order.payment_required? && @order.bill_address.present?) || @payments.any? %>- <div class="card mb-4 bg-transparent">+ <div class="card mb-4"><div class="card-header d-flex align-items-center border-0"><h6 class="card-title"><%= icon('credit-card-pay', class: 'mr-2') %>diff --git a/admin/app/views/spree/admin/orders/_shipment.html.erb b/admin/app/views/spree/admin/orders/_shipment.html.erbindex d8cf66b207..12ef924d95 100644--- a/admin/app/views/spree/admin/orders/_shipment.html.erb+++ b/admin/app/views/spree/admin/orders/_shipment.html.erb@@ -85,7 +85,7 @@<% end %><% if can_ship?(shipment) %>- <div class="card-footer d-flex justify-content-end border-top bg-gray-25">+ <div class="card-footer d-flex justify-content-end border-top bg-light"><% if shipment.tracked? %><%= link_to_with_icon 'send.svg', Spree.t(:ship), spree.ship_admin_order_shipment_path(order, shipment), class: 'ml-auto btn btn-primary mb-0', data: {turbo_method: :post, turbo_confirm: Spree.t(:are_you_sure)} %><% elsif !shipment.digital? %>diff --git a/admin/app/views/spree/admin/orders/_shipments.html.erb b/admin/app/views/spree/admin/orders/_shipments.html.erbindex 3cdd8b691e..01a369e8c3 100644--- a/admin/app/views/spree/admin/orders/_shipments.html.erb+++ b/admin/app/views/spree/admin/orders/_shipments.html.erb@@ -1,4 +1,4 @@-<div class="card mb-4 bg-transparent">+<div class="card mb-4"><div class="card-header d-flex align-items-center border-0"><h6 class="card-title"><%= icon('truck', class: 'mr-2') %>diff --git a/admin/app/views/spree/admin/orders/_summary.html.erb b/admin/app/views/spree/admin/orders/_summary.html.erbindex 507d5d1b3a..56d43bf1e6 100644--- a/admin/app/views/spree/admin/orders/_summary.html.erb+++ b/admin/app/views/spree/admin/orders/_summary.html.erb@@ -90,14 +90,14 @@</span></li>- <li class="list-group-item d-flex justify-content-between align-items-center border-top bg-gray-25">+ <li class="list-group-item d-flex justify-content-between align-items-center border-top bg-light"><span data-hook='admin_order_tab_payment_total_title'><%= Spree.t(:payment_total) %></span><span id='payment_total'><%= @order.display_payment_total.to_html %></span></li>- <li class="list-group-item d-flex justify-content-between align-items-center bg-gray-25">+ <li class="list-group-item d-flex justify-content-between align-items-center bg-light"><span data-hook='admin_order_tab_outstanding_balance_title'><%= Spree.t(:outstanding_balance) %></span><span id='outstanding_balance'><%= @order.display_outstanding_balance.to_html %>diff --git a/admin/app/views/spree/admin/orders/user/new.html.erb b/admin/app/views/spree/admin/orders/user/new.html.erbindex 8d157f4702..9aeaa90d35 100644--- a/admin/app/views/spree/admin/orders/user/new.html.erb+++ b/admin/app/views/spree/admin/orders/user/new.html.erb@@ -23,7 +23,7 @@<%= tom_select_tag :user_id, { include_blank: Spree.t(:select_user), options: users_for_select_options, select_data: {action: 'auto-submit#submit'}, disable_with: "<span class='spinner-border spinner-border-sm' role='status'></span>" } %><% end %><span class="d-flex w-100 justify-content-center align-items-center"><%= Spree.t(:or) %></span>- <%= link_to Spree.t(:create_new), spree.new_admin_order_user_path(@order, show_form: true), class: "btn btn-light w-100" %>+ <%= link_to Spree.t(:create_new), spree.new_admin_order_user_path(@order, show_form: true), class: "btn btn-secondary w-100" %></div><% end %></div>diff --git a/admin/app/views/spree/admin/page_builder/_add_block.html.erb b/admin/app/views/spree/admin/page_builder/_add_block.html.erbindex f0a2051bd1..f935993a31 100644--- a/admin/app/views/spree/admin/page_builder/_add_block.html.erb+++ b/admin/app/views/spree/admin/page_builder/_add_block.html.erb@@ -1,7 +1,7 @@<%= form_for section.blocks.new, url: spree.admin_page_section_blocks_path(section), html: { class: 'list-group-item sidebar-page-block px-0 py-1 border-0 rounded'}, data: { controller: 'block-form', block_form_target: :form } do |f| %><%= f.hidden_field :type, data: { block_form_target: 'type' } %>- <button class="btn btn-sm btn-link d-flex-inline" data-toggle="dropdown">+ <button class="btn btn-sm btn-secondary d-flex-inline" data-toggle="dropdown"><%= icon("circle-plus") %>Add block</button>diff --git a/admin/app/views/spree/admin/payments/_payment.html.erb b/admin/app/views/spree/admin/payments/_payment.html.erbindex 909fd74b46..aed10b9fd9 100644--- a/admin/app/views/spree/admin/payments/_payment.html.erb+++ b/admin/app/views/spree/admin/payments/_payment.html.erb@@ -65,7 +65,7 @@<% if payment.source.present? %><div class="w-50"><p class="mb-2"><%= Spree.t(:payment_source) %>:</p>- <div class="rounded-lg bg-gray-25 border shadow-xs p-3">+ <div class="rounded-lg bg-light border shadow-xs p-3"><%= render 'spree/shared/payment', payment: payment %></div></div>diff --git a/admin/app/views/spree/admin/products/index.html.erb b/admin/app/views/spree/admin/products/index.html.erbindex 68d03e40bc..74890e49a3 100644--- a/admin/app/views/spree/admin/products/index.html.erb+++ b/admin/app/views/spree/admin/products/index.html.erb@@ -4,6 +4,7 @@<% content_for :page_actions do %><%= render_admin_partials(:products_actions_partials) %>+ <%= link_to_with_icon 'table-import', Spree.t(:import), spree.new_admin_import_path(type: 'Spree::Imports::Products'), class: 'btn btn-light', data: { action: 'drawer#open',turbo_frame: :drawer } if can?(:create, Spree::Import) %><%= link_to_export_modal %><%= link_to_with_icon 'plus', Spree.t(:new_product), new_object_url, class: 'btn btn-primary' if can?(:create, Spree::Product) %><% end %>diff --git a/admin/app/views/spree/admin/promotion_actions/forms/_create_line_items.html.erb b/admin/app/views/spree/admin/promotion_actions/forms/_create_line_items.html.erbindex 0b6dce3955..12710a97a5 100644--- a/admin/app/views/spree/admin/promotion_actions/forms/_create_line_items.html.erb+++ b/admin/app/views/spree/admin/promotion_actions/forms/_create_line_items.html.erb@@ -23,7 +23,7 @@<!-- Inserted elements will be injected before that target. --><tr data-nested-form-target="target"><td colspan="3">- <button type="button" class="btn btn-link" data-action="nested-form#add">+ <button type="button" class="btn btn-secondary" data-action="nested-form#add"><%= icon('plus', class: 'mr-2') %><%= Spree.t(:add_one)%></button>diff --git a/admin/app/views/spree/admin/promotions/_actions.html.erb b/admin/app/views/spree/admin/promotions/_actions.html.erbindex 896b42a17e..035d16390e 100644--- a/admin/app/views/spree/admin/promotions/_actions.html.erb+++ b/admin/app/views/spree/admin/promotions/_actions.html.erb@@ -1,4 +1,4 @@-<div class="card mb-4 bg-transparent">+<div class="card mb-4"><div class="card-header d-flex justify-content-between border-0 px-2"><h5 class="card-title"><%= icon('bolt', class: 'mr-2') %>diff --git a/admin/app/views/spree/admin/promotions/_rules.html.erb b/admin/app/views/spree/admin/promotions/_rules.html.erbindex e31636e7d1..ab7ba94555 100644--- a/admin/app/views/spree/admin/promotions/_rules.html.erb+++ b/admin/app/views/spree/admin/promotions/_rules.html.erb@@ -1,4 +1,4 @@-<div class="card mb-4 bg-transparent">+<div class="card mb-4"><div class="card-header d-flex justify-content-between px-2"><h5 class="card-title"><%= icon('checklist', class: 'mr-2') %>diff --git a/admin/app/views/spree/admin/promotions/form/_kind.html.erb b/admin/app/views/spree/admin/promotions/form/_kind.html.erbindex 6f8d019180..db72aec366 100644--- a/admin/app/views/spree/admin/promotions/form/_kind.html.erb+++ b/admin/app/views/spree/admin/promotions/form/_kind.html.erb@@ -2,7 +2,7 @@<%= f.radio_button :kind, :coupon_code, data: { toggle: :collapse, target: '#coupon-code' }, class: 'custom-control-input' %><%= f.label :kind_coupon_code, Spree.t(:coupon_code), class: 'custom-control-label' %>- <div id="coupon-code" class="rounded p-3 bg-gray-25 mt-3 collapse <% unless @promotion.automatic? %>show<% end %>">+ <div id="coupon-code" class="rounded p-3 bg-light mt-3 collapse <% unless @promotion.automatic? %>show<% end %>"><div class="d-flex align-items-start custom-control custom-radio"><%= f.radio_button :multi_codes, false, data: { toggle: :collapse, target: '#single-code' }, class: 'custom-control-input' %><%= f.label :multi_codes_false, class: 'custom-control-label' do %>diff --git a/admin/app/views/spree/admin/shared/_back_to_dashboard.html.erb b/admin/app/views/spree/admin/shared/_back_to_dashboard.html.erbnew file mode 100644index 0000000000..ff7086a9ac--- /dev/null+++ b/admin/app/views/spree/admin/shared/_back_to_dashboard.html.erb@@ -0,0 +1 @@+<%= link_to_with_icon 'arrow-back', Spree.t('admin.back_to_dashboard'), spree.admin_path, class: 'store-dropdown hover-gray justify-content-start gap-2 px-4' %>\ No newline at end of filediff --git a/admin/app/views/spree/admin/shared/_breadcrumbs.html.erb b/admin/app/views/spree/admin/shared/_breadcrumbs.html.erbindex 72d39550bd..42289a11c5 100644--- a/admin/app/views/spree/admin/shared/_breadcrumbs.html.erb+++ b/admin/app/views/spree/admin/shared/_breadcrumbs.html.erb@@ -1,7 +1,7 @@<nav aria-label="breadcrumb"><ol class="breadcrumb"><%= render_breadcrumb_icon %>- <% if settings_active? %>+ <% if settings_area? %><li><%= active_link_to Spree.t(:settings), spree.edit_admin_store_path %></li>diff --git a/admin/app/views/spree/admin/shared/_content_header.html.erb b/admin/app/views/spree/admin/shared/_content_header.html.erbindex 37fcb599ae..0ae7e954e5 100644--- a/admin/app/views/spree/admin/shared/_content_header.html.erb+++ b/admin/app/views/spree/admin/shared/_content_header.html.erb@@ -23,7 +23,7 @@<% if show_record_subtitle || content_for(:page_actions_dropdown) %><div class="dropdown h-100" id="page_actions_dropdown">- <%= link_to '#', class: 'btn btn-light bg-transparent h-100 p-2', data: { toggle: 'dropdown' }, id: 'more-actions-link' do %>+ <%= link_to '#', class: 'btn btn-light h-100 p-2', data: { toggle: 'dropdown' }, id: 'more-actions-link' do %><%= icon 'dots-vertical', class: 'mr-0' %><% end %><div class="dropdown-menu dropdown-menu-right">@@ -67,18 +67,3 @@</div></header><% end %>--<% if content_for?(:page_tabs) %>- <div class="container-fluid" id="page-tabs">- <ul class="nav">- <%= yield :page_tabs %>- </ul>- </div>-<% end %>-<% if content_for(:page_alerts) %>- <div class="container">- <div class="page-alerts">- <%= yield(:page_alerts) %>- </div>- </div>-<% end %>diff --git a/admin/app/views/spree/admin/shared/_drawer.html.erb b/admin/app/views/spree/admin/shared/_drawer.html.erbindex 7fd896766d..866946aadf 100644--- a/admin/app/views/spree/admin/shared/_drawer.html.erb+++ b/admin/app/views/spree/admin/shared/_drawer.html.erb@@ -1,4 +1,4 @@-<dialog class="drawer" data-drawer-target="dialog" id="drawer-dialog">+<dialog class="drawer" data-drawer-target="dialog" id="drawer-dialog" data-action="keydown.ctrl+s->drawer#close"><%= turbo_frame_tag :drawer_alerts %><%= turbo_frame_tag :drawer %></dialog>\ No newline at end of filediff --git a/admin/app/views/spree/admin/shared/_head.html.erb b/admin/app/views/spree/admin/shared/_head.html.erbindex ccf8e9c9fd..4f3fe3c5f2 100644--- a/admin/app/views/spree/admin/shared/_head.html.erb+++ b/admin/app/views/spree/admin/shared/_head.html.erb@@ -8,7 +8,7 @@<% if content_for? :title %><%= yield :title %><% else %>- <% if @object.present? && @object.persisted? %><%= @object.try(:name) || @object.try(:title) %> - <% end %>+ <% if @object.present? && @object.persisted? %><%= @object.try(:name) || @object.try(:title) || @object.try(:display_name) || @object.try(:number) %> - <% end %><% if @order.present? && @order.persisted? %><%= @order.number %> - <% end %><%= Spree.t(controller_name, default: controller_name.titleize) %><% end %>diff --git a/admin/app/views/spree/admin/shared/_header.html.erb b/admin/app/views/spree/admin/shared/_header.html.erbindex b8b467a512..5507d7b8de 100644--- a/admin/app/views/spree/admin/shared/_header.html.erb+++ b/admin/app/views/spree/admin/shared/_header.html.erb@@ -10,12 +10,8 @@</button></div>- <% if settings_active? %>- <%= link_to spree.admin_path, class: 'store-dropdown text-decoration-none px-2 justify-content-start', data: { admin_target: 'close', controller: 'tooltip', tooltip_placement_value: 'bottom', tooltip_offset_value: -10 } do %>- <%= icon 'x', class: 'mx-2' %>- <%= tooltip(Spree.t('admin.back_to_dashboard')) %>- <kbd>ESC</kbd>- <% end %>+ <% if settings_area? %>+ <%= render 'spree/admin/shared/back_to_dashboard' %><% else %><% if defined?(current_vendor) && current_vendor.present? %><%= render 'spree/admin/shared/sidebar/vendor_dropdown' %>diff --git a/admin/app/views/spree/admin/shared/_new_item_dropdown.html.erb b/admin/app/views/spree/admin/shared/_new_item_dropdown.html.erbindex eef38f0804..75989df5b1 100644--- a/admin/app/views/spree/admin/shared/_new_item_dropdown.html.erb+++ b/admin/app/views/spree/admin/shared/_new_item_dropdown.html.erb@@ -1,9 +1,9 @@<div class="dropdown">- <button type="button" class="btn btn-sm btn-light shadow-xs px-1" data-toggle="dropdown" aria-expanded="false">+ <button type="button" class="btn btn-sm btn-light px-1" data-toggle="dropdown" aria-expanded="false"><%= icon 'plus', class: 'mr-0' %></button><div class="dropdown-menu">- <%= link_to_with_icon 'shopping-bag-plus', Spree.t(:new_order), spree.admin_orders_path, class: "dropdown-item", data: { turbo_method: :post } if can?(:manage, Spree::Order) %>+ <%= link_to_with_icon 'shopping-bag-plus', Spree.t(:new_order), spree.new_admin_order_path, class: "dropdown-item" if can?(:manage, Spree::Order) %><%= link_to spree.new_admin_product_path, class: 'dropdown-item' do %><%= icon 'cube-plus' %>diff --git a/admin/app/views/spree/admin/shared/_no_resource_found.html.erb b/admin/app/views/spree/admin/shared/_no_resource_found.html.erbindex 19d1efe924..73721c2ac7 100644--- a/admin/app/views/spree/admin/shared/_no_resource_found.html.erb+++ b/admin/app/views/spree/admin/shared/_no_resource_found.html.erb@@ -5,5 +5,5 @@<p><%= Spree.t(:no_resource_found, resource: resource_name) %></p>- <%= link_to_with_icon 'plus', Spree.t(:add_one), new_object_url, class: 'btn btn-link btn-sm ml-3', data: { 'turbo-frame': '_top' } if can?(:create, model_class) && defined?(new_object_url) && new_object_url.present? %>+ <%= link_to_with_icon 'plus', Spree.t(:add_one), new_object_url, class: 'btn btn-secondary btn-sm ml-3', data: { 'turbo-frame': '_top' } if can?(:create, model_class) && defined?(new_object_url) && new_object_url.present? %></div>\ No newline at end of filediff --git a/admin/app/views/spree/admin/shared/_page_alerts.html.erb b/admin/app/views/spree/admin/shared/_page_alerts.html.erbnew file mode 100644index 0000000000..f0e50856e7--- /dev/null+++ b/admin/app/views/spree/admin/shared/_page_alerts.html.erb@@ -0,0 +1,7 @@+<% if content_for(:page_alerts) %>+ <div class="container" id="page-alerts">+ <div class="page-alerts">+ <%= yield(:page_alerts) %>+ </div>+ </div>+<% end %>\ No newline at end of filediff --git a/admin/app/views/spree/admin/shared/_page_tabs.html.erb b/admin/app/views/spree/admin/shared/_page_tabs.html.erbnew file mode 100644index 0000000000..50769a73b6--- /dev/null+++ b/admin/app/views/spree/admin/shared/_page_tabs.html.erb@@ -0,0 +1,7 @@+<% if content_for?(:page_tabs) %>+ <div class="container-fluid" id="page-tabs">+ <ul class="nav">+ <%= yield :page_tabs %>+ </ul>+ </div>+<% end %>\ No newline at end of filediff --git a/admin/app/views/spree/admin/shared/_user_dropdown.html.erb b/admin/app/views/spree/admin/shared/_user_dropdown.html.erbindex 81118b6c6a..a838275e6b 100644--- a/admin/app/views/spree/admin/shared/_user_dropdown.html.erb+++ b/admin/app/views/spree/admin/shared/_user_dropdown.html.erb@@ -6,7 +6,7 @@<%= render_avatar(try_spree_current_user, width: 32, height: 32) %></button><div class="dropdown-menu dropdown-menu-right" style="min-width: 250px;">- <div class="d-flex align-items-center p-2 bg-gray-25 rounded-lg">+ <div class="d-flex align-items-center p-2 bg-light rounded-lg"><%= render_avatar(try_spree_current_user, width: 34, height: 34) %><span class="d-none d-lg-inline ml-lg-2"><% if try_spree_current_user.name.present? %>diff --git a/admin/app/views/spree/admin/shared/sidebar/_enterprise_edition_notice.html.erb b/admin/app/views/spree/admin/shared/sidebar/_enterprise_edition_notice.html.erbindex 901eb36e1f..607fbdb35f 100644--- a/admin/app/views/spree/admin/shared/sidebar/_enterprise_edition_notice.html.erb+++ b/admin/app/views/spree/admin/shared/sidebar/_enterprise_edition_notice.html.erb@@ -5,7 +5,7 @@<%= link_to '', spree.admin_dismiss_enterprise_edition_notice_path, data: { turbo_method: :patch }, class: 'btn-close' %><p>You're using Spree Community Edition. To get access to all features, please upgrade to Enterprise Edition.</p>- <%= external_link_to 'Upgrade', 'https://spreecommerce.org/pricing', target: '_blank', class: 'btn btn-link btn-sm shadow-xs' %>+ <%= external_link_to 'Upgrade', 'https://spreecommerce.org/pricing', target: '_blank', class: 'btn btn-secondary btn-sm shadow-xs' %></div></section><% end %>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.erbindex b11efa5d1e..4a154b369d 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@@ -1,4 +1,4 @@-<% if settings_active? %>+<% if settings_area? %><ul class="nav flex-column"><% if can?(:manage, current_store) %><%= nav_item(Spree.t(:store_details), spree.edit_admin_store_path(section: 'general-settings'), icon: 'building-store', active: params[:section] == 'general-settings') %>diff --git a/admin/app/views/spree/admin/stock_transfers/new.html.erb b/admin/app/views/spree/admin/stock_transfers/new.html.erbindex a9cf0bbef4..cff85c2203 100644--- a/admin/app/views/spree/admin/stock_transfers/new.html.erb+++ b/admin/app/views/spree/admin/stock_transfers/new.html.erb@@ -52,7 +52,7 @@<%= Spree.t(:products) %></h5><span data-toggle="modal" data-target="#stock_transfer_modal">- <%= button_tag type: 'button', class: 'btn btn-light btn-sm', disabled: @stock_transfer.destination_location_id.blank?, data: { stock_transfer_target: :newVariantAddButton } do %>+ <%= button_tag type: 'button', class: 'btn btn-secondary btn-sm', disabled: @stock_transfer.destination_location_id.blank?, data: { stock_transfer_target: :newVariantAddButton } do %><span data-controller="tooltip"><%= icon('plus', class: 'icon icon-plus') %><%= Spree.t(:add_products) %>diff --git a/admin/app/views/spree/admin/taxons/_form.html.erb b/admin/app/views/spree/admin/taxons/_form.html.erbindex 834c79680e..cb6d844161 100644--- a/admin/app/views/spree/admin/taxons/_form.html.erb+++ b/admin/app/views/spree/admin/taxons/_form.html.erb@@ -55,7 +55,7 @@<% if @taxon.manual? && can?(:create, Spree::Classification) %><span data-toggle="modal" data-target="#modal">- <%= link_to_with_icon 'plus', Spree.t(:add_products), spree.new_admin_taxon_classification_path(@taxon.id), class: 'btn btn-light btn-sm', data: { turbo_frame: 'dialog_modal' } %>+ <%= link_to_with_icon 'plus', Spree.t(:add_products), spree.new_admin_taxon_classification_path(@taxon.id), class: 'btn btn-secondary btn-sm', data: { turbo_frame: 'dialog_modal' } %></span><% end %></div>diff --git a/admin/app/views/spree/admin/taxons/_rules_form.html.erb b/admin/app/views/spree/admin/taxons/_rules_form.html.erbindex 4035b4428f..eeda7153ca 100644--- a/admin/app/views/spree/admin/taxons/_rules_form.html.erb+++ b/admin/app/views/spree/admin/taxons/_rules_form.html.erb@@ -26,7 +26,7 @@<!-- Inserted elements will be injected before that target. --><div data-nested-form-target="target" class="mb-2"></div>- <button type="button" class="btn btn-link w-100 py-3" data-action="nested-form#add">+ <button type="button" class="btn btn-secondary w-100 py-3" data-action="nested-form#add"><%= icon('plus', class: 'mr-2') %><%= Spree.t(:add_one)%></button>diff --git a/admin/app/views/spree/admin/themes/index.html.erb b/admin/app/views/spree/admin/themes/index.html.erbindex 6b2c5ef4c9..74ba576213 100644--- a/admin/app/views/spree/admin/themes/index.html.erb+++ b/admin/app/views/spree/admin/themes/index.html.erb@@ -4,7 +4,7 @@<%= content_for :page_actions do %><%= render_admin_partials(:themes_actions_partials) %>- <%= link_to_with_icon 'eye', Spree.t(:view_your_store), current_store.formatted_url_or_custom_domain, class: 'btn btn-light bg-transparent', target: '_blank' %>+ <%= link_to_with_icon 'eye', Spree.t(:view_your_store), current_store.formatted_url_or_custom_domain, class: 'btn btn-light', target: '_blank' %><% end %><%= content_for :page_alerts do %>@@ -21,7 +21,7 @@<span>You don't have domain connected to your store</span>- <%= link_to 'Connect your own domain', spree.admin_custom_domains_path, class: 'btn btn-link ml-3' %>+ <%= link_to 'Connect your own domain', spree.admin_custom_domains_path, class: 'btn btn-secondary ml-3' %></div></div><% end %>diff --git a/admin/app/views/spree/admin/variants/_variant.html.erb b/admin/app/views/spree/admin/variants/_variant.html.erbindex 130862696e..95cd24dd90 100644--- a/admin/app/views/spree/admin/variants/_variant.html.erb+++ b/admin/app/views/spree/admin/variants/_variant.html.erb@@ -9,7 +9,7 @@<%= render "spree/admin/shared/product_image", object: variant %><div class="ml-3"><strong><%= variant.name %></strong>- <% if variant.options_text.present? %>+ <% if !variant.is_master? && variant.options_text.present? %><p class="text-muted my-1 font-size-sm"><%= variant.options_text %></p>diff --git a/admin/app/views/spree/admin/variants/form/_inventory.html.erb b/admin/app/views/spree/admin/variants/form/_inventory.html.erbindex f37a478497..cdec6f739f 100644--- a/admin/app/views/spree/admin/variants/form/_inventory.html.erb+++ b/admin/app/views/spree/admin/variants/form/_inventory.html.erb@@ -42,7 +42,7 @@<% end %></tbody></table>- <div class="card-footer border-top text-center bg-gray-25 text-muted">+ <div class="card-footer border-top text-center bg-light text-muted"><%= Spree.t('admin.variants_form.stock_locations_link', link: spree.admin_stock_locations_path).html_safe %></div></div>diff --git a/admin/config/locales/en.yml b/admin/config/locales/en.ymlindex d97d50cc0e..8ef508f916 100644--- a/admin/config/locales/en.yml+++ b/admin/config/locales/en.yml@@ -5,7 +5,7 @@ en:amount_spent: Amount spentaudit_log: Audit Logavg_order_value: Avg. Order Value- back_to_dashboard: Back to Dashboard+ back_to_dashboard: Back to dashboardbulk_ops:products:body:@@ -91,6 +91,13 @@ en:code_help_text: If you leave it blank, we will generate code for youredeemed: Redeemedusage: Usage+ imports:+ all_required_columns_mapped: Good job, all required columns are mapped!+ field_required: Field required+ import_done: All done!+ mapping_required: This field is required+ please_map_all_required_fields: Please map all the required fields to continue.+ waiting_for_file_to_be_processed: Waiting for file to be processed...integrations:invalid_integration_type: This integration is not allowedpage_subtitle: Connect your store to third-party services to enhance customer experience.diff --git a/admin/config/routes.rb b/admin/config/routes.rbindex 15e9bc8c9b..25c9aaefca 100644--- a/admin/config/routes.rb+++ b/admin/config/routes.rb@@ -143,6 +143,16 @@ Spree::Core::Engine.add_routes do# json previewresources :json_previews, only: [:show], path: '/json_preview/:resource_type', as: :json_preview_resource+ # imports+ resources :imports, only: [:new, :create, :show] do+ resources :mappings, only: [:edit, :update], controller: 'import_mappings'+ resources :rows, only: :show, controller: 'import_rows'++ member do+ put :complete_mapping+ end+ end+# audit logresources :exports, only: [:index, :new, :create, :show]diff --git a/admin/spec/controllers/spree/admin/import_rows_controller_spec.rb b/admin/spec/controllers/spree/admin/import_rows_controller_spec.rbnew file mode 100644index 0000000000..dc6c134a6b--- /dev/null+++ b/admin/spec/controllers/spree/admin/import_rows_controller_spec.rb@@ -0,0 +1,19 @@+require 'spec_helper'++RSpec.describe Spree::Admin::ImportRowsController, type: :controller do+ stub_authorization!+ render_views++ let(:store) { Spree::Store.default }+ let(:import) { create(:product_import, owner: store) }+ let(:import_row) { create(:import_row, import: import) }++ describe 'GET #show' do+ it 'renders the show template' do+ get :show, params: { import_id: import.number, id: import_row.id }+ expect(response).to render_template(:show)+ expect(assigns(:import)).to eq(import)+ expect(assigns(:import_row)).to eq(import_row)+ end+ end+enddiff --git a/admin/spec/controllers/spree/admin/imports_controller_spec.rb b/admin/spec/controllers/spree/admin/imports_controller_spec.rbnew file mode 100644index 0000000000..12b72b6868--- /dev/null+++ b/admin/spec/controllers/spree/admin/imports_controller_spec.rb@@ -0,0 +1,124 @@+require 'spec_helper'++RSpec.describe Spree::Admin::ImportsController, type: :controller do+ stub_authorization!+ render_views++ let(:store) { @default_store }+ let(:admin_user) { create(:admin_user) }+ let(:attachment) { Rack::Test::UploadedFile.new(File.join(Spree::Core::Engine.root, 'spec/fixtures/files', 'products_import.csv'), 'text/csv') }+ let(:csv_content) { File.read(File.join(Spree::Core::Engine.root, 'spec/fixtures/files', 'products_import.csv')) }++ before do+ # Stub the file content reading since ActiveStorage doesn't persist files properly in transactional tests+ allow_any_instance_of(Spree::Import).to receive(:attachment_file_content).and_return(csv_content)+ end++ describe 'GET #new' do+ it 'assigns a new import and renders the new template' do+ get :new+ expect(response).to render_template(:new)+ expect(assigns(:import)).to be_a(Spree::Import)+ expect(assigns(:import)).to be_new_record+ expect(assigns(:import).type).to eq(Spree::Import.available_types.first.to_s)+ end++ context 'when type parameter is present' do+ it 'assigns the type' do+ get :new, params: { import: { type: 'Spree::Imports::Products' } }+ expect(assigns(:import).type).to eq('Spree::Imports::Products')+ end+ end+ end++ describe 'POST #create' do+ let(:import_params) { { type: Spree::Import.available_types.first.to_s, attachment: attachment } }++ it 'creates a new import and redirects to show' do+ expect {+ post :create, params: { import: import_params }+ }.to change(Spree::Import, :count).by(1)++ import = Spree::Import.last+ expect(response).to redirect_to(spree.admin_import_path(import))+ expect(import.user).to eq(admin_user)+ expect(import.owner).to eq(store)+ expect(import.type).to eq(Spree::Import.available_types.first.to_s)+ expect(import.attachment).to be_attached+ expect(import.attachment.filename.to_s).to eq('products_import.csv')+ end++ context 'when type parameter is present' do+ it 'assigns the type' do+ post :create, params: { import: import_params }+ expect(assigns(:import).type).to eq('Spree::Imports::Products')+ end+ end++ context 'when attachment is not a CSV file' do+ let(:attachment) { Rack::Test::UploadedFile.new(File.join(Spree::Admin::Engine.root, 'spec/fixtures/files', 'logo.png'), 'image/png') }++ it 'does not create an import and redirects to new' do+ expect {+ post :create, params: { import: import_params }+ }.not_to change(Spree::Import, :count)++ expect(response).to have_http_status(:unprocessable_entity)+ end+ end+ end++ describe 'GET #show' do+ let(:import) { create(:product_import, status: :mapping) }+ let!(:mapping) { create(:import_mapping, import: import) }++ it 'renders the show template' do+ get :show, params: { id: import.id }+ expect(response).to render_template(:show)+ expect(assigns(:import)).to eq(import)+ expect(assigns(:mappings)).to eq([mapping])+ end++ context 'when mapping is done' do+ let(:import) { create(:product_import, status: :completed_mapping) }+ let!(:row) { create(:import_row, import: import, status: :completed) }+ let!(:incomplete_row) { create(:import_row, import: import, status: :pending) }++ it 'renders the show template' do+ get :show, params: { id: import.id }+ expect(response).to render_template(:show)+ expect(assigns(:import)).to eq(import)+ expect(assigns(:rows)).to eq([row])+ end+ end+ end++ describe 'PUT #complete_mapping' do+ let(:import) { create(:product_import, status: :mapping) }++ context 'when mapping is done' do+ before do+ allow_any_instance_of(Spree::Import).to receive(:mapping_done?).and_return(true)+ allow_any_instance_of(Spree::Import).to receive(:complete_mapping!).and_call_original+ end++ it 'marks import as completed and redirects to show' do+ expect_any_instance_of(Spree::Import).to receive(:complete_mapping!)+ put :complete_mapping, params: { id: import.id }+ expect(response).to redirect_to(spree.admin_import_path(import))+ end+ end++ context 'when mapping is not done' do+ before do+ allow_any_instance_of(Spree::Import).to receive(:mapping_done?).and_return(false)+ end++ it 'does not mark import as completed but still redirects to show' do+ expect_any_instance_of(Spree::Import).not_to receive(:complete_mapping!)+ put :complete_mapping, params: { id: import.id }+ expect(response).to redirect_to(spree.admin_import_path(import))+ end+ end+ end+enddiff --git a/bin/sandbox.sh b/bin/sandbox.shindex eba4f924cc..9ea451f59e 100755--- a/bin/sandbox.sh+++ b/bin/sandbox.sh@@ -50,6 +50,7 @@ ficd ./sandboxcat <<RUBY >> Gemfile+gem 'redis'gem 'devise'gem 'spree', path: '..'gem 'spree_emails', path: '../emails'@@ -80,6 +81,15 @@ if Rails.env.development? && defined?(Bullet)endRUBY+# configure actioncable to use redis+rm -rf config/cable.yml+touch config/cable.yml+cat <<RUBY >> config/cable.yml+development:+ adapter: redis+ url: redis://localhost:6379/0+RUBY+bundle updatebundle install --gemfile Gemfile --path ../vendor/bundlediff --git a/core/app/jobs/spree/images/save_from_url_job.rb b/core/app/jobs/spree/images/save_from_url_job.rbnew file mode 100644index 0000000000..2f030e17d4--- /dev/null+++ b/core/app/jobs/spree/images/save_from_url_job.rb@@ -0,0 +1,51 @@+require 'open-uri'++module Spree+ module Images+ class SaveFromUrlJob < ::Spree::BaseJob+ queue_as Spree.queues.images+ retry_on ActiveRecord::RecordInvalid, OpenURI::HTTPError, URI::InvalidURIError, wait: :polynomially_longer, attempts: 2++ def perform(viewable_id, viewable_type, external_url, position = nil)+ viewable = viewable_type.safe_constantize.find(viewable_id)++ Spree::Image.ensure_metafield_definition_exists!(Spree::Image::EXTERNAL_URL_METAFIELD_KEY)++ external_url = external_url.downcase.strip++ image_scope = if Spree::Image.respond_to?(:with_deleted)+ viewable.images.with_deleted+ else+ viewable.images+ end++ image = image_scope.with_external_url(external_url).first || viewable.images.new++ image.restore if image.respond_to?(:deleted?) && image.deleted?+ image.position = position if position.present?++ # don't re-download the image if it's already been downloaded+ # still trigger save! if position has changed+ image.save! and return if image_already_saved?(image, external_url)++ uri = URI.parse(external_url)+ unless %w[http https].include?(uri.scheme)+ raise URI::InvalidURIError, "Invalid URL scheme: #{uri.scheme}. Only http and https are allowed."+ end++ file = uri.open+ filename = uri.path.split('/').last++ image.attachment.attach(io: file, filename: filename)+ image.external_url = external_url+ image.save!+ end++ private++ def image_already_saved?(image, external_url)+ image.persisted? && image.attachment.attached? && image.external_url.present? && external_url == image.external_url+ end+ end+ end+enddiff --git a/core/app/jobs/spree/imports/create_rows_job.rb b/core/app/jobs/spree/imports/create_rows_job.rbnew file mode 100644index 0000000000..ff8ae63b15--- /dev/null+++ b/core/app/jobs/spree/imports/create_rows_job.rb@@ -0,0 +1,72 @@+module Spree+ module Imports+ class CreateRowsJob < Spree::BaseJob+ queue_as Spree.queues.imports++ discard_on ::CSV::MalformedCSVError, EncodingError do |job, error|+ import = Spree::Import.find(job.arguments.first)+ import.update_columns(processing_errors: error.message, status: :failed, updated_at: Time.current)+ Rails.error.report error+ end++ BATCH_SIZE = 1000++ def perform(import_id)+ import = Spree::Import.find(import_id)+ import.start_processing! if import.status != 'processing'++ create_rows_sequentially(import)++ # enqueue processing rows job after creating rows in a separate job+ import.process_rows_async+ end++ private++ def create_rows_sequentially(import)+ rows_to_insert = []+ row_number = 1++ created_at = updated_at = Time.current++ upsert_options = {}+ if %w[PostgreSQL SQLite].include?(ActiveRecord::Base.connection.adapter_name)+ upsert_options[:unique_by] = %i[import_id row_number]+ end+ # NOTE: Ensure a DB-level unique index on [:import_id, :row_number] for all adapters.++ # Stream CSV to avoid loading entire file in memory+ # This maintains order by processing sequentially+ ::CSV.foreach(StringIO.new(import.attachment_file_content),+ headers: true,+ col_sep: import.preferred_delimiter,+ encoding: 'UTF-8') do |csv_row|++ rows_to_insert << {+ import_id: import.id,+ row_number: row_number,+ data: csv_row.to_h.to_json,+ status: 'pending',+ created_at: created_at,+ updated_at: updated_at+ }++ row_number += 1++ # Bulk upsert when we reach batch size+ if rows_to_insert.size >= BATCH_SIZE+ Spree::ImportRow.upsert_all(rows_to_insert, **upsert_options)+ rows_to_insert.clear+ end+ end++ # Upsert any remaining rows+ if rows_to_insert.any?+ Spree::ImportRow.upsert_all(rows_to_insert, **upsert_options)+ end++ Spree::Import.reset_counters(import.id, :rows)+ end+ end+ end+enddiff --git a/core/app/jobs/spree/imports/process_rows_job.rb b/core/app/jobs/spree/imports/process_rows_job.rbnew file mode 100644index 0000000000..dc9566ba06--- /dev/null+++ b/core/app/jobs/spree/imports/process_rows_job.rb@@ -0,0 +1,19 @@+module Spree+ module Imports+ class ProcessRowsJob < Spree::BaseJob+ queue_as Spree.queues.imports++ def perform(import_id)+ import = Spree::Import.find(import_id)++ # process all rows in sequential order+ import.rows.pending_and_failed.find_each(batch_size: 100) do |row|+ row.process!+ end++ # mark as complete+ import.complete!+ end+ end+ end+enddiff --git a/core/app/models/concerns/spree/metafields.rb b/core/app/models/concerns/spree/metafields.rbindex 62f7628328..58d0d8e1ec 100644--- a/core/app/models/concerns/spree/metafields.rb+++ b/core/app/models/concerns/spree/metafields.rb@@ -2,6 +2,19 @@ module Spreemodule Metafieldsextend ActiveSupport::Concern+ module ClassMethods+ def ensure_metafield_definition_exists!(key_with_namespace)+ namespace, key = extract_namespace_and_key(key_with_namespace)+ Spree::MetafieldDefinition.find_or_create_by!(namespace: namespace, key: key, resource_type: self.name)+ end++ def extract_namespace_and_key(key_with_namespace)+ namespace = key_with_namespace.to_s.split('.').first+ key = key_with_namespace.to_s.split('.').last+ [namespace, key]+ end+ end+included dohas_many :metafields, -> { includes(:metafield_definition) }, as: :resource, class_name: 'Spree::Metafield', dependent: :destroyhas_many :public_metafields, -> { includes(:metafield_definition).available_on_front_end }, as: :resource, class_name: 'Spree::Metafield'@@ -11,16 +24,24 @@ module Spreemf[:metafield_definition_id].blank? || (mf[:id].blank? && mf[:value].blank?)}- scope :with_metafield_key, ->(namespace, key) { joins(metafields: :metafield_definition).where(spree_metafield_definitions: { namespace: namespace, key: key }) }- scope :with_metafield_key_value, ->(namespace, key, value) {+ scope :with_metafield_key, ->(key_with_namespace) {+ namespace, key = extract_namespace_and_key(key_with_namespace)+ joins(metafields: :metafield_definition).where(spree_metafield_definitions: { namespace: namespace, key: key })+ }+ scope :with_metafield_key_value, ->(key_with_namespace, value) {+ namespace, key = extract_namespace_and_key(key_with_namespace)+joins(metafields: :metafield_definition).where(spree_metafield_definitions: { namespace: namespace, key: key }).where(spree_metafields: { value: value })}+ def extract_namespace_and_key(key_with_namespace)+ self.class.extract_namespace_and_key(key_with_namespace)+ end+def set_metafield(key_with_namespace, value)- namespace = key_with_namespace.to_s.split('.').first- key = key_with_namespace.to_s.split('.').last+ namespace, key = extract_namespace_and_key(key_with_namespace)metafield_definition = Spree::MetafieldDefinition.find_or_create_by!(namespace: namespace, key: key, resource_type: self.class.name)metafield = metafields.find_or_initialize_by(metafield_definition: metafield_definition)@@ -30,8 +51,7 @@ module Spreeenddef get_metafield(key_with_namespace)- namespace = key_with_namespace.to_s.split('.').first- key = key_with_namespace.to_s.split('.').last+ namespace, key = extract_namespace_and_key(key_with_namespace)metafields.with_key(namespace, key).firstend@@ -40,8 +60,7 @@ module Spreenamespace = key_with_namespace.namespacekey = key_with_namespace.keyelsif key_with_namespace.is_a?(String)- namespace = key_with_namespace.to_s.split('.').first- key = key_with_namespace.to_s.split('.').last+ namespace, key = extract_namespace_and_key(key_with_namespace)elseraise ArgumentError, "Invalid key_with_namespace: #{key_with_namespace.inspect}"enddiff --git a/core/app/models/spree/asset.rb b/core/app/models/spree/asset.rbindex 5914ad451c..47b705266b 100644--- a/core/app/models/spree/asset.rb+++ b/core/app/models/spree/asset.rb@@ -7,6 +7,8 @@ module Spreeinclude Spree::Webhooks::HasWebhooksend+ EXTERNAL_URL_METAFIELD_KEY = 'external.url'+belongs_to :viewable, polymorphic: true, touch: trueacts_as_list scope: [:viewable_id, :viewable_type]@@ -20,9 +22,18 @@ module Spreescope :with_session_uploaded_assets_uuid, lambda { |uuid|where(session_id: uuid)}+ scope :with_external_url, ->(url) { url.present? ? with_metafield_key_value(EXTERNAL_URL_METAFIELD_KEY, url.downcase.strip) : none }def product@product ||= viewable_type == 'Spree::Variant' ? viewable&.product : nilend++ def external_url+ get_metafield(EXTERNAL_URL_METAFIELD_KEY)&.value+ end++ def external_url=(url)+ set_metafield(EXTERNAL_URL_METAFIELD_KEY, url.downcase.strip)+ endendenddiff --git a/core/app/models/spree/export.rb b/core/app/models/spree/export.rbindex 88af682520..55a55dd991 100644--- a/core/app/models/spree/export.rb+++ b/core/app/models/spree/export.rb@@ -188,7 +188,11 @@ module Spree# eg. Spree::Exports::Products => Spree::Productdef model_class- "Spree::#{to_s.demodulize.singularize}".constantize+ klass = "Spree::#{to_s.demodulize.singularize}".safe_constantize++ raise NameError, "Missing model class for #{to_s}" unless klass++ klassendenddiff --git a/core/app/models/spree/import.rb b/core/app/models/spree/import.rbnew file mode 100644index 0000000000..eff4f371cc--- /dev/null+++ b/core/app/models/spree/import.rb@@ -0,0 +1,213 @@+require 'csv'++module Spree+ class Import < Spree.base_class+ include Spree::NumberIdentifier+ include Spree::NumberAsParam++ include Spree::Core::NumberGenerator.new(prefix: 'IM')++ #+ # Associations+ #+ belongs_to :owner, polymorphic: true # Store, Vendor, etc.+ belongs_to :user, class_name: Spree.admin_user_class.to_s, optional: true+ has_many :mappings, class_name: 'Spree::ImportMapping', dependent: :destroy, inverse_of: :import+ alias import_mappings mappings+ has_many :rows, class_name: 'Spree::ImportRow', dependent: :destroy_async, inverse_of: :import+ alias import_rows rows++ #+ # Validations+ #+ validates :owner, :user, :type, presence: true+ validates :attachment, presence: true, unless: -> { Rails.env.test? }+ validate :ensure_whitelisted_type+ validate :ensure_attachment_content_type++ #+ # Ransack configuration+ #+ self.whitelisted_ransackable_attributes = %w[number type]++ #+ # Attachments+ #+ has_one_attached :attachment, service: Spree.private_storage_service_name++ #+ # State machine+ #+ state_machine initial: :pending, attribute: :status do+ event :start_mapping do+ transition to: :mapping+ end+ before_transition to: :mapping, do: :create_mappings++ event :complete_mapping do+ transition from: :mapping, to: :completed_mapping+ end+ after_transition to: :completed_mapping, do: :create_rows_async++ event :start_processing do+ transition from: :completed_mapping, to: :processing+ end++ event :complete do+ transition from: :processing, to: :completed+ end+ after_transition to: :completed, do: :send_import_completed_email+ after_transition to: :completed, do: :update_loader_in_import_view++ event :fail do+ transition to: :failed+ end+ end++ #+ # Preferences+ #+ preference :delimiter, :string, default: ','++ def mapping?+ status == 'mapping'+ end++ def processing?+ ['processing', 'completed_mapping'].include?(status)+ end++ def complete?+ status == 'completed'+ end++ # eg. Spree::Exports::Products => Spree::Product+ def model_class+ if type == 'Spree::Imports::Customers'+ Spree.user_class+ else+ "Spree::#{type.demodulize.singularize}".safe_constantize+ end+ end++ def import_schema+ "Spree::ImportSchemas::#{type.demodulize}".safe_constantize.new+ end++ def row_processor_class+ "Spree::ImportRowProcessors::#{type.demodulize.singularize}".safe_constantize+ end++ def schema_fields+ import_schema.fields+ end++ def unmapped_file_columns+ csv_headers.reject { |header| mappings.mapped.exists?(file_column: header) }+ end++ def required_fields+ import_schema.required_fields+ end++ def mapped_fields+ @mapped_fields ||= mappings.mapped.where(schema_field: required_fields)+ end++ def mapping_done?+ mapped_fields.count == required_fields.count+ end++ def display_name+ "#{Spree.t(type.demodulize.pluralize.downcase)} #{number}"+ end++ def send_import_completed_email+ # Spree::ImportMailer.import_done(self).deliver_later+ end++ # Returns the headers of the csv file+ # @return [Array<String>]+ def csv_headers+ return [] if attachment_file_content.blank?++ @csv_headers ||= ::CSV.parse_line(+ attachment_file_content,+ col_sep: preferred_delimiter+ )+ end++ # Returns the content of the attachment file+ # @return [String]+ def attachment_file_content+ @attachment_file_content ||= attachment.attached? ? attachment.blob.download&.force_encoding('UTF-8') : nil+ end++ # Creates mappings from the schema fields+ # TODO: get mappings from the previous import if it exists, so user won't have to map the same columns again+ def create_mappings+ schema_fields.each do |schema_field|+ mapping = mappings.find_or_create_by!(schema_field: schema_field[:name])+ mapping.try_to_auto_assign_file_column(csv_headers)+ mapping.save!+ end+ end++ def create_rows_async+ Spree::Imports::CreateRowsJob.set(wait: 2.seconds).perform_later(id)+ end++ def process_rows_async+ Spree::Imports::ProcessRowsJob.perform_later(id)+ end++ # Returns the store for the import+ # @return [Spree::Store]+ def store+ owner.is_a?(Spree::Store) ? owner : owner.respond_to?(:store) ? owner.store : Spree::Store.default+ end++ def update_loader_in_import_view+ return unless defined?(broadcast_update_to)++ broadcast_update_to "import_#{id}_loader", target: 'loader', partial: 'spree/admin/imports/loader', locals: { import: self }+ end+ class << self+ def available_types+ Rails.application.config.spree.import_types+ end++ def available_models+ available_types.map(&:model_class)+ end++ def type_for_model(model)+ available_types.find { |type| type.model_class.to_s == model.to_s }+ end++ # eg. Spree::Imports::Orders => Spree::Order+ def model_class+ klass = "Spree::#{to_s.demodulize.singularize}".safe_constantize++ raise NameError, "Missing model class for #{to_s}" unless klass++ klass+ end+ end++ private++ def ensure_whitelisted_type+ return if type.blank?++ allowed = self.class.available_types.map(&:to_s)+ errors.add(:type, :inclusion) unless allowed.include?(type)+ end++ def ensure_attachment_content_type+ return if attachment.blank?++ errors.add(:attachment, :content_type) unless attachment.content_type.in?(%w[text/csv])+ end+ end+enddiff --git a/core/app/models/spree/import_mapping.rb b/core/app/models/spree/import_mapping.rbnew file mode 100644index 0000000000..dcc9a99f54--- /dev/null+++ b/core/app/models/spree/import_mapping.rb@@ -0,0 +1,33 @@+module Spree+ class ImportMapping < Spree.base_class+ #+ # Associations+ #+ belongs_to :import++ #+ # Validations+ #+ validates :import, :schema_field, presence: true+ validates :schema_field, uniqueness: { scope: [:import_id] }+ validates :file_column, uniqueness: { scope: [:import_id] }, allow_blank: true++ #+ # Scopes+ #+ scope :required, -> { where(schema_field: import.required_fields) }+ scope :mapped, -> { where.not(file_column: [nil, '']) }++ def required?+ import.required_fields.include?(schema_field)+ end++ def mapped?+ file_column.present?+ end++ def try_to_auto_assign_file_column(csv_headers)+ self.file_column = csv_headers.find { |header| header.parameterize.downcase.strip == schema_field.parameterize.downcase.strip }+ end+ end+enddiff --git a/core/app/models/spree/import_row.rb b/core/app/models/spree/import_row.rbnew file mode 100644index 0000000000..aca272b1bf--- /dev/null+++ b/core/app/models/spree/import_row.rb@@ -0,0 +1,108 @@+module Spree+ class ImportRow < Spree.base_class+ #+ # Associations+ #+ belongs_to :import, class_name: 'Spree::Import', counter_cache: :rows_count+ belongs_to :item, polymorphic: true, optional: true # eg. Spree::Variant, Spree::Order, etc.+ delegate :store, to: :import++ #+ # Validations+ #+ validates :import, :data, presence: true+ validates :row_number, uniqueness: { scope: :import_id }, numericality: { only_integer: true, greater_than: 0 }, presence: true++ #+ # State machine+ #+ state_machine initial: :pending, attribute: :status do+ event :start_processing do+ transition to: :processing+ end++ event :fail do+ transition to: :failed+ end+ after_transition to: :failed, do: :add_row_to_import_view+ after_transition to: :failed, do: :update_footer_in_import_view++ event :complete do+ transition to: :completed+ end++ after_transition to: :completed, do: :add_row_to_import_view+ after_transition to: :completed, do: :update_footer_in_import_view+ end++ #+ # Scopes+ #+ scope :pending_and_failed, -> { where(status: %i[pending failed]) }+ scope :completed, -> { where(status: :completed) }+ scope :failed, -> { where(status: :failed) }+ scope :processed, -> { where(status: %i[completed failed]) }++ def data_json+ @data_json ||= JSON.parse(data)+ rescue JSON::ParserError+ {}+ end++ def to_schema_hash+ @to_schema_hash ||= begin+ mappings = import.mappings.mapped+ schema_fields = import.schema_fields++ attributes = {}+ schema_fields.each do |field|+ attributes[field[:name]] = attribute_by_schema_field(field[:name], mappings)+ end+ attributes+ end+ end++ def attribute_by_schema_field(schema_field, mappings = nil)+ mappings ||= import.mappings.mapped++ mapping = mappings.find { |m| m.schema_field == schema_field }+ return unless mapping&.mapped?++ data_json[mapping.file_column]+ end++ def process!+ start_processing!+ self.item = import.row_processor_class.new(self).process!+ complete!+ rescue StandardError => e+ self.validation_errors = e.message+ fail!+ end++ def add_row_to_import_view+ return unless defined?(broadcast_append_to)++ # we need to render this partial with store context to properly generate image URLs+ with_store_context do+ broadcast_append_to "import_#{import.id}_rows", target: 'rows', partial: 'spree/admin/imports/row', locals: { row: self, import: import }+ end+ end++ def update_footer_in_import_view+ return unless defined?(broadcast_replace_to)++ broadcast_replace_to "import_#{import_id}_footer", target: 'footer', partial: 'spree/admin/imports/footer', locals: { import: import }+ end++ private++ def with_store_context+ Spree::Current.store = store+ Rails.application.routes.default_url_options[:host] = store.url_or_custom_domain+ yield+ ensure+ Spree::Current.reset if defined?(Spree::Current)+ end+ end+enddiff --git a/core/app/models/spree/import_schema.rb b/core/app/models/spree/import_schema.rbnew file mode 100644index 0000000000..26ca342a49--- /dev/null+++ b/core/app/models/spree/import_schema.rb@@ -0,0 +1,25 @@+module Spree+ class ImportSchema+ FIELDS = []++ def fields+ self.class::FIELDS+ end++ def label_for_field(field_name)+ fields.find { |f| f[:name] == field_name }[:label]+ end++ def required_fields+ self.class::FIELDS.select { |f| f[:required] }.map { |f| f[:name] }+ end++ def optional_fields+ self.class::FIELDS.reject { |f| f[:required] }.map { |f| f[:name] }+ end++ def headers+ self.class::FIELDS.map { |f| f[:name] }+ end+ end+enddiff --git a/core/app/models/spree/import_schemas/products.rb b/core/app/models/spree/import_schemas/products.rbnew file mode 100644index 0000000000..011ad8309d--- /dev/null+++ b/core/app/models/spree/import_schemas/products.rb@@ -0,0 +1,45 @@+module Spree+ module ImportSchemas+ class Products < Spree::ImportSchema+ FIELDS = [+ { name: 'slug', label: 'Slug', required: true },+ { name: 'sku', label: 'SKU', required: true },+ { name: 'name', label: 'Name', required: true },+ { name: 'price', label: 'Price', required: true },+ { name: 'status', label: 'Status' },+ { name: 'description', label: 'Description' },+ { name: 'meta_title', label: 'Meta Title' },+ { name: 'meta_description', label: 'Meta Description' },+ { name: 'meta_keywords', label: 'Meta Keywords' },+ { name: 'tags', label: 'Tags' },+ { name: 'compare_at_price', label: 'Compare at Price' },+ { name: 'currency', label: 'Currency' },+ { name: 'width', label: 'Width' },+ { name: 'height', label: 'Height' },+ { name: 'depth', label: 'Depth' },+ { name: 'dimensions_unit', label: 'Dimensions Unit' },+ { name: 'weight', label: 'Weight' },+ { name: 'weight_unit', label: 'Weight Unit' },+ { name: 'available_on', label: 'Available On' },+ { name: 'discontinue_on', label: 'Discontinue On' },+ { name: 'track_inventory', label: 'Track Inventory' },+ { name: 'inventory_count', label: 'Inventory Count' },+ { name: 'inventory_backorderable', label: 'Inventory Backorderable' },+ { name: 'tax_category', label: 'Tax Category' },+ { name: 'digital', label: 'Digital' },+ { name: 'image1_src', label: 'Image 1 URL' },+ { name: 'image2_src', label: 'Image 2 URL' },+ { name: 'image3_src', label: 'Image 3 URL' },+ { name: 'option1_name', label: 'Option 1 Name' },+ { name: 'option1_value', label: 'Option 1 Value' },+ { name: 'option2_name', label: 'Option 2 Name' },+ { name: 'option2_value', label: 'Option 2 Value' },+ { name: 'option3_name', label: 'Option 3 Name' },+ { name: 'option3_value', label: 'Option 3 Value' },+ { name: 'category1', label: 'Category 1' },+ { name: 'category2', label: 'Category 2' },+ { name: 'category3', label: 'Category 3' }+ ].freeze+ end+ end+enddiff --git a/core/app/models/spree/imports/products.rb b/core/app/models/spree/imports/products.rbnew file mode 100644index 0000000000..e6dd5eb6b7--- /dev/null+++ b/core/app/models/spree/imports/products.rb@@ -0,0 +1,9 @@+module Spree+ module Imports+ class Products < Spree::Import+ def row_processor_class+ Spree::Imports::RowProcessors::ProductVariant+ end+ end+ end+enddiff --git a/core/app/models/spree/option_type.rb b/core/app/models/spree/option_type.rbindex 8647f47f73..ec28746be6 100644--- a/core/app/models/spree/option_type.rb+++ b/core/app/models/spree/option_type.rb@@ -62,6 +62,7 @@ module Spree# legacy, name itself is now parameterized before savingdef filter_param+ Spree::Deprecation.warn('Spree::OptionType#filter_param is deprecated and will be removed in Spree 6. Please use Spree::OptionType#name instead.')name.parameterizeenddiff --git a/core/app/models/spree/variant.rb b/core/app/models/spree/variant.rbindex ea98fb58a2..9487f3404e 100644--- a/core/app/models/spree/variant.rb+++ b/core/app/models/spree/variant.rb@@ -394,6 +394,23 @@ module Spreeprice_in(currency).try(:compare_at_amount)end+ def set_price(currency, amount, compare_at_amount = nil)+ prices.find_or_initialize_by(currency: currency) do |price|+ price.amount = amount+ price.compare_at_amount = compare_at_amount if compare_at_amount.present?+ price.save!+ end+ end++ def set_stock(count_on_hand, backorderable = nil, stock_location = nil)+ stock_location ||= Spree::Store.current.default_stock_location+ stock_items.find_or_initialize_by(stock_location: stock_location) do |stock_item|+ stock_item.count_on_hand = count_on_hand+ stock_item.backorderable = backorderable if backorderable.present?+ stock_item.save!+ end+ end+def price_modifier_amount_in(currency, options = {})return 0 unless options.present?diff --git a/core/app/presenters/spree/csv/product_presenter.rb b/core/app/presenters/spree/csv/product_presenter.rbdeleted file mode 100644index 24beea3948..0000000000--- a/core/app/presenters/spree/csv/product_presenter.rb+++ /dev/null@@ -1,63 +0,0 @@-require 'csv'--module Spree- module CSV- class ProductPresenter- def initialize(product, properties = [], store = nil)- @product = product- @properties = properties- @store = store || product.stores.first- @currency = @store.default_currency- end-- attr_accessor :product, :properties, :store, :currency-- def call- [- product.id,- product.try(:vendor_name),- product.try(:brand_name),- product.name,- product.description&.html_safe,- product.amount_in(currency).to_f,- product.meta_title,- product.meta_description,- product.meta_keywords,- product.tag_list.to_s,- product.label_list.to_s,- product.width,- product.height,- product.depth,- product.weight,- product.available_on&.strftime('%Y-%m-%d %H:%M:%S'),- product.discontinue_on&.strftime('%Y-%m-%d %H:%M:%S'),- product.status,- *map_categories(product),- product.total_on_hand == BigDecimal::INFINITY ? '∞' : product.total_on_hand,- *present_properties- ]- end-- private-- def map_categories(product)- categories = [nil, nil, nil]-- product.taxons.reorder(depth: :desc).first(3).pluck(:pretty_name).each_with_index do |category_name, index|- categories[index] = category_name- end-- categories- end-- def present_properties- properties.flat_map do |property|- [- property.name,- product.property(property.name)- ]- end- end- end- end-enddiff --git a/core/app/presenters/spree/csv/product_variant_presenter.rb b/core/app/presenters/spree/csv/product_variant_presenter.rbindex a9139775af..dcd0b52d1f 100644--- a/core/app/presenters/spree/csv/product_variant_presenter.rb+++ b/core/app/presenters/spree/csv/product_variant_presenter.rb@@ -78,7 +78,7 @@ module Spreeproduct.id,variant.sku,index.zero? ? product.name : nil,- index.zero? ? product.slug : nil,+ product.slug,index.zero? ? product.status : nil,index.zero? ? product.try(:vendor_name) : nil,index.zero? ? product.try(:brand_name) : nil,diff --git a/core/app/services/spree/imports/row_processors/base.rb b/core/app/services/spree/imports/row_processors/base.rbnew file mode 100644index 0000000000..1e109d3ad0--- /dev/null+++ b/core/app/services/spree/imports/row_processors/base.rb@@ -0,0 +1,19 @@+module Spree+ module Imports+ module RowProcessors+ class Base+ def initialize(row)+ @row = row+ @import = row.import+ @attributes = row.to_schema_hash+ end++ attr_reader :row, :import, :attributes++ def process!+ raise NotImplementedError, 'Subclasses must implement the process! method'+ end+ end+ end+ end+enddiff --git a/core/app/services/spree/imports/row_processors/product_variant.rb b/core/app/services/spree/imports/row_processors/product_variant.rbnew file mode 100644index 0000000000..f1dd764a02--- /dev/null+++ b/core/app/services/spree/imports/row_processors/product_variant.rb@@ -0,0 +1,141 @@+module Spree+ module Imports+ module RowProcessors+ class ProductVariant < Base+ OPTION_TYPES_COUNT = 3++ def initialize(row)+ super+ @store = row.store+ @product = ensure_product_exists+ end++ attr_reader :product, :store++ def process!+ variant_scope = options.empty? ? product.variants_including_master : product.variants++ variant = if attributes['sku'].present?+ variant_scope.where(+ Spree::Variant.arel_table[:sku].lower.eq(attributes['sku'].strip.downcase)+ ).first || product.variants.new+ elsif options.empty?+ product.master+ else+ product.variants.new+ end++ variant.sku = attributes['sku'] if attributes['sku'].present?+ variant.cost_price = attributes['cost_price'] if attributes['cost_price'].present?+ variant.weight = attributes['weight'] if attributes['weight'].present?+ variant.height = attributes['height'] if attributes['height'].present?+ variant.width = attributes['width'] if attributes['width'].present?+ variant.depth = attributes['depth'] if attributes['depth'].present?+ variant.track_inventory = attributes['track_inventory'] if attributes['track_inventory'].present?+ variant.option_value_variants = prepare_option_value_variants+ variant.save!++ if attributes['price'].present?+ currency = (attributes['currency'].presence || store.default_currency).to_s.strip.upcase+ variant.set_price(currency, attributes['price'], attributes['compare_at_price'])+ end++ if attributes['inventory_count'].present?+ variant.set_stock(attributes['inventory_count'].to_i, attributes['inventory_backorderable']&.to_b, store.default_stock_location)+ end++ handle_images(variant)++ variant+ end++ private++ def ensure_product_exists+ product = Spree::Product.new+ if attributes['slug'].present?+ existing_product = Spree::Product.find_by(slug: attributes['slug'].strip.downcase)+ product = existing_product if existing_product.present?+ end++ # setting SKU for master variant so it will be picked up in process! and won't try to create a non-master variant+ if product.new_record?+ product.slug = attributes['slug']+ product.sku = attributes['sku'] if attributes['sku'].present? && options.empty?+ end++ product.stores << store if product.stores.exclude?(store)+ product.name = attributes['name'] if attributes['name'].present?+ product.description = attributes['description'] if attributes['description'].present?+ product.meta_title = attributes['meta_title'] if attributes['meta_title'].present?+ product.meta_description = attributes['meta_description'] if attributes['meta_description'].present?+ product.meta_keywords = attributes['meta_keywords'] if attributes['meta_keywords'].present?+ product.status = to_spree_status(attributes['status']) if attributes['status'].present?+ product.tag_list = attributes['tags'] if attributes['tags'].present?+ product.save!+ product+ end++ def prepare_option_value_variants+ return [] if options.empty?++ options.map do |option|+ option_type = Spree::OptionType.search_by_name(option[:option_name]).first || Spree::OptionType.create!(presentation: option[:option_name])+ option_value = option_type.option_values.search_by_name(option[:option_value]).first || option_type.option_values.create!(presentation: option[:option_value])++ # ensure product option types include new option type+ Spree::ProductOptionType.find_or_create_by!(product: product, option_type: option_type)++ Spree::OptionValueVariant.new(option_value: option_value)+ end+ end++ def handle_images(variant)+ image_urls = [+ attributes['image1_src'],+ attributes['image2_src'],+ attributes['image3_src'],+ ].compact.map(&:strip).compact_blank.uniq++ return if image_urls.empty?++ image_urls.each do |image_url|+ Spree::Images::SaveFromUrlJob.perform_later(variant.id, 'Spree::Variant', image_url)+ end+ end++ def options+ @options ||= begin+ options = []++ OPTION_TYPES_COUNT.times.map do |index|+ next if attributes["option#{index + 1}_name"].blank?+ next if attributes["option#{index + 1}_value"].blank?++ options << {+ index: index + 1,+ option_name: attributes["option#{index + 1}_name"],+ option_value: attributes["option#{index + 1}_value"]+ }+ end++ options+ end+ end++ def to_spree_status(status)+ case status.strip.downcase+ when 'active'+ 'active'+ when 'draft'+ 'draft'+ when 'archived'+ 'archived'+ else+ 'draft'+ end+ end+ end+ end+ end+enddiff --git a/core/config/locales/en.yml b/core/config/locales/en.ymlindex 8e527fe7db..899ab9676a 100644--- a/core/config/locales/en.yml+++ b/core/config/locales/en.yml@@ -53,6 +53,13 @@ en:spree/gift_card:amount_used: Amount usedexpires_at: Expires at+ spree/import:+ preferred_delimiter: Delimiter+ spree/import_mapping:+ file_column: File Column+ schema_field: Schema Field+ spree/import_row:+ row_number: Numberspree/inventory_unit:state: Statespree/invitation:@@ -249,6 +256,12 @@ en:attachment:attachment_must_be_present: must be presentnot_allowed_content_type: has not allowed content type+ spree/import:+ attributes:+ attachment:+ content_type: has not allowed content type+ type:+ inclusion: is not included in the list of allowed typesspree/legacy_user:attributes:bill_address_id:@@ -1156,6 +1169,7 @@ en:images: Imagesimplement_eligible_for_return: 'Must implement #eligible_for_return? for your EligibilityValidator.'implement_requires_manual_intervention: 'Must implement #requires_manual_intervention? for your EligibilityValidator.'+ import: Importimport_payment_methods_from: Import payment methods fromimport_products_from: Import products fromin_stock: In Stock@@ -1842,6 +1856,7 @@ en:rma_value: RMA Valuerole_id: Role IDroles: Roles+ row: Rowrules: Rulessafe: Safesale: Salediff --git a/core/db/migrate/20250923141845_create_spree_imports.rb b/core/db/migrate/20250923141845_create_spree_imports.rbnew file mode 100644index 0000000000..f87870cc36--- /dev/null+++ b/core/db/migrate/20250923141845_create_spree_imports.rb@@ -0,0 +1,47 @@+class CreateSpreeImports < ActiveRecord::Migration[7.2]+ def change+ create_table :spree_imports do |t|+ t.belongs_to :user, null: false+ t.belongs_to :owner, polymorphic: true, null: false++ t.string :status, null: false, index: true++ t.string :number, limit: 32, null: false, index: { unique: true }+ t.string :type, null: false, index: true++ t.text :processing_errors++ t.text :preferences++ t.integer :rows_count, null: false, default: 0++ t.timestamps+ end++ create_table :spree_import_rows do |t|+ t.belongs_to :import, null: false+ t.belongs_to :item, polymorphic: true++ t.string :status, null: false, index: true+ t.integer :row_number, null: false++ t.text :data, null: false+ t.text :validation_errors++ t.timestamps+ end++ add_index :spree_import_rows, [:import_id, :row_number], unique: true++ create_table :spree_import_mappings do |t|+ t.belongs_to :import, null: false++ t.string :schema_field, null: false+ t.string :file_column, index: true++ t.timestamps+ end++ add_index :spree_import_mappings, [:import_id, :schema_field], unique: true+ end+enddiff --git a/core/lib/spree/core.rb b/core/lib/spree/core.rbindex dadce8a358..5d8d30b4b0 100644--- a/core/lib/spree/core.rb+++ b/core/lib/spree/core.rb@@ -6,6 +6,7 @@ require 'active_model/railtie'require 'active_record/railtie'require 'active_storage/engine'require 'action_text/engine'+require 'action_cable/engine'require 'mail'require 'action_mailer/railtie'@@ -98,6 +99,8 @@ module Spree@@queues ||= OpenStruct.new(default: :default,exports: :default,+ images: :default,+ imports: :default,reports: :default,variants: :default,taxons: :default,diff --git a/core/lib/spree/core/engine.rb b/core/lib/spree/core/engine.rbindex effc87e8a0..c6ef8fd9b3 100644--- a/core/lib/spree/core/engine.rb+++ b/core/lib/spree/core/engine.rb@@ -15,6 +15,7 @@ module Spree:line_item_comparison_hooks,:data_feed_types,:export_types,+ :import_types,:taxon_rules,:themes,:theme_layout_sections,@@ -158,6 +159,10 @@ module SpreeSpree::Exports::NewsletterSubscribers]+ Rails.application.config.spree.import_types = [+ Spree::Imports::Products,+ ]+Rails.application.config.spree.taxon_rules = [Spree::TaxonRules::Tag,Spree::TaxonRules::AvailableOn,@@ -271,6 +276,7 @@ module SpreeSpree::CustomDomain,Spree::CustomerReturn,Spree::GiftCard,+ Spree::Image,Spree::LineItem,Spree::NewsletterSubscriber,Spree::OptionType,diff --git a/core/lib/spree/permitted_attributes.rb b/core/lib/spree/permitted_attributes.rbindex 42f0880dbc..568b2b0ede 100644--- a/core/lib/spree/permitted_attributes.rb+++ b/core/lib/spree/permitted_attributes.rb@@ -15,6 +15,8 @@ module Spree:gift_card_attributes,:gift_card_batch_attributes,:image_attributes,+ :import_attributes,+ :import_mapping_attributes,:integration_attributes,:inventory_unit_attributes,:invitation_attributes,@@ -116,6 +118,10 @@ module Spree@@image_attributes = [:alt, :attachment, :position, :viewable_type, :viewable_id]+ @@import_attributes = [:type, :attachment, :delimiter]++ @@import_mapping_attributes = [:file_column]+@@integration_attributes = [:type, :active]@@inventory_unit_attributes = [:shipment, :shipment_id, :variant_id]diff --git a/core/lib/spree/testing_support/factories/export_factory.rb b/core/lib/spree/testing_support/factories/export_factory.rbindex da5afad794..15d41a1eab 100644--- a/core/lib/spree/testing_support/factories/export_factory.rb+++ b/core/lib/spree/testing_support/factories/export_factory.rb@@ -1,19 +1,3 @@-# == Schema Information-#-# Table name: spree_exports-#-# id :uuid not null, primary key-# format :integer not null-# number :string(32) not null-# search_params :jsonb-# type :string not null-# created_at :datetime not null-# updated_at :datetime not null-# project_id :uuid not null-# store_id :uuid not null-# user_id :uuid-# vendor_id :uuid-#FactoryBot.define dofactory :export, class: 'Spree::Export' dostore { create(:store) }diff --git a/core/lib/spree/testing_support/factories/import_factory.rb b/core/lib/spree/testing_support/factories/import_factory.rbnew file mode 100644index 0000000000..b0dc1d5630--- /dev/null+++ b/core/lib/spree/testing_support/factories/import_factory.rb@@ -0,0 +1,20 @@+FactoryBot.define do+ factory :import, class: 'Spree::Import' do+ owner { Spree::Store.default || create(:store) }+ user { create(:admin_user) }+ type { 'Spree::Imports::Products' }++ factory :product_import, class: 'Spree::Imports::Products', parent: :import do+ type { 'Spree::Imports::Products' }+ # attachment { Rack::Test::UploadedFile.new(Spree::Core::Engine.root.join('spec', 'fixtures', 'files', 'products_import.csv'), 'text/csv') }++ after(:create) do |import|+ import.attachment.attach(+ io: File.open(Spree::Core::Engine.root.join('spec', 'fixtures', 'files', 'products_import.csv')),+ filename: 'products_import.csv',+ content_type: 'text/csv'+ )+ end+ end+ end+enddiff --git a/core/lib/spree/testing_support/factories/import_mapping_factory.rb b/core/lib/spree/testing_support/factories/import_mapping_factory.rbnew file mode 100644index 0000000000..dd678ef60f--- /dev/null+++ b/core/lib/spree/testing_support/factories/import_mapping_factory.rb@@ -0,0 +1,7 @@+FactoryBot.define do+ factory :import_mapping, class: 'Spree::ImportMapping' do+ import { create(:product_import) }+ schema_field { 'name' }+ file_column { 'name' }+ end+enddiff --git a/core/lib/spree/testing_support/factories/import_row_factory.rb b/core/lib/spree/testing_support/factories/import_row_factory.rbnew file mode 100644index 0000000000..fb31f18352--- /dev/null+++ b/core/lib/spree/testing_support/factories/import_row_factory.rb@@ -0,0 +1,7 @@+FactoryBot.define do+ factory :import_row, class: 'Spree::ImportRow' do+ import { create(:product_import) }+ data { { 'slug' => 'test-product', 'name' => 'Test Product', 'price' => '10.00' }.to_json }+ row_number { import.rows_count + 1 }+ end+enddiff --git a/core/spec/fixtures/files/products_import.csv b/core/spec/fixtures/files/products_import.csvnew file mode 100644index 0000000000..a436f88c0d--- /dev/null+++ b/core/spec/fixtures/files/products_import.csv@@ -0,0 +1,18 @@+slug,sku,name,status,vendor_name,brand_name,description,meta_title,meta_description,meta_keywords,tags,labels,price,compare_at_price,currency,width,height,depth,dimensions_unit,weight,weight_unit,available_on,discontinue_on,track_inventory,inventory_count,inventory_backorderable,tax_category,digital,image1_src,image2_src,image3_src,option1_name,option1_value,option2_name,option2_value,option3_name,option3_value,category1,category2,category3,metafield.properties.fit,metafield.properties.manufacturer,metafield.properties.material+denim-shirt,"",Denim Shirt,draft,,,Adipisci sapiente velit nihil ullam. Placeat cumque ipsa cupiditate velit magni sapiente mollitia dolorum. Veritatis esse illo eos perferendis. Perspiciatis vel iusto odio eveniet quam officia quidem. Fugiat a ipsum tempore optio accusantium autem in fugit.,,,,"","",0.0,0.0,USD,,,,,0.0,lb,2025-10-09 14:35:53,,true,100,true,Default,false,,,,,,,,,,Categories -> Men -> Shirts,Categories -> Women,Categories -> Sportswear,Lose,Wannabe,90% Cotton 10% Elastan+denim-shirt,DENIM-SHIRT-XS-BLUE,,,,,,,,,,,62.99,0.0,USD,,,,,0.0,lb,2025-10-09 14:35:53,,true,100,true,Clothing,false,,,,Color,Blue,Size,XS,,+denim-shirt,DENIM-SHIRT-S-BLUE,,,,,,,,,,,62.99,0.0,USD,,,,,0.0,lb,2025-10-09 14:35:53,,true,100,true,Clothing,false,,,,Color,Blue,Size,S,,+denim-shirt,DENIM-SHIRT-M-BLUE,,,,,,,,,,,62.99,0.0,USD,,,,,0.0,lb,2025-10-09 14:35:53,,true,100,true,Clothing,false,,,,Color,Blue,Size,M,,+denim-shirt,DENIM-SHIRT-L-BLUE,,,,,,,,,,,62.99,0.0,USD,,,,,0.0,lb,2025-10-09 14:35:53,,true,100,true,Clothing,false,,,,Color,Blue,Size,L,,+denim-shirt,DENIM-SHIRT-XL-BLUE,,,,,,,,,,,62.99,0.0,USD,,,,,0.0,lb,2025-10-09 14:35:53,,true,100,true,Clothing,false,,,,Color,Blue,Size,XL,,+denim-shirt,DENIM-SHIRT-XS-LIGHT-BLUE,,,,,,,,,,,62.99,0.0,USD,,,,,0.0,lb,2025-10-09 14:35:53,,true,100,true,Clothing,false,,,,Color,Light Blue,Size,XS,,+denim-shirt,DENIM-SHIRT-S-LIGHT-BLUE,,,,,,,,,,,62.99,0.0,USD,,,,,0.0,lb,2025-10-09 14:35:53,,true,100,true,Clothing,false,,,,Color,Light Blue,Size,S,,+denim-shirt,DENIM-SHIRT-M-LIGHT-BLUE,,,,,,,,,,,62.99,0.0,USD,,,,,0.0,lb,2025-10-09 14:35:53,,true,100,true,Clothing,false,,,,Color,Light Blue,Size,M,,+denim-shirt,DENIM-SHIRT-L-LIGHT-BLUE,,,,,,,,,,,62.99,0.0,USD,,,,,0.0,lb,2025-10-09 14:35:53,,true,100,true,Clothing,false,,,,Color,Light Blue,Size,L,,+denim-shirt,DENIM-SHIRT-XL-LIGHT-BLUE,,,,,,,,,,,62.99,0.0,USD,,,,,0.0,lb,2025-10-09 14:35:53,,true,100,true,Clothing,false,,,,Color,Light Blue,Size,XL,,+checked-shirt,"",Checked Shirt,draft,,,Et ipsam repudiandae itaque tenetur laborum. Cupiditate nulla blanditiis quia tenetur doloremque possimus explicabo asperiores. Facere adipisci veniam aut nemo magnam.,,,,"","",0.0,0.0,USD,,,,,0.0,lb,2025-10-09 14:35:54,,true,100,true,Default,false,,,,,,,,,,Categories -> Men -> Shirts,Categories -> Women,Categories -> Sportswear,Lose,Wannabe,10% Cotton 90% Elastan+checked-shirt,CHECKED-SHIRT-XS-RED,,,,,,,,,,,22.99,0.0,USD,,,,,0.0,lb,2025-10-09 14:35:54,,true,100,true,Clothing,false,,,,Color,Red,Size,XS,,+checked-shirt,CHECKED-SHIRT-S-RED,,,,,,,,,,,22.99,0.0,USD,,,,,0.0,lb,2025-10-09 14:35:54,,true,100,true,Clothing,false,,,,Color,Red,Size,S,,+checked-shirt,CHECKED-SHIRT-M-RED,,,,,,,,,,,22.99,0.0,USD,,,,,0.0,lb,2025-10-09 14:35:54,,true,100,true,Clothing,false,,,,Color,Red,Size,M,,+checked-shirt,CHECKED-SHIRT-L-RED,,,,,,,,,,,22.99,0.0,USD,,,,,0.0,lb,2025-10-09 14:35:54,,true,100,true,Clothing,false,,,,Color,Red,Size,L,,+checked-shirt,CHECKED-SHIRT-XL-RED,,,,,,,,,,,22.99,0.0,USD,,,,,0.0,lb,2025-10-09 14:35:54,,true,100,true,Clothing,false,,,,Color,Red,Size,XL,,\ No newline at end of filediff --git a/core/spec/jobs/spree/images/save_from_url_job_spec.rb b/core/spec/jobs/spree/images/save_from_url_job_spec.rbnew file mode 100644index 0000000000..c5a722bf7c--- /dev/null+++ b/core/spec/jobs/spree/images/save_from_url_job_spec.rb@@ -0,0 +1,70 @@+require 'spec_helper'++RSpec.describe Spree::Images::SaveFromUrlJob, type: :job do+ let!(:variant) { create(:variant) }+ let(:external_url) { "https://cdn.example.com/foo/bar_image.png" }+ let(:position) { nil }+ let(:viewable_id) { variant.id }+ let(:viewable_type) { 'Spree::Variant' }+ let(:queue_name) { Spree.queues.images }++ subject(:job) { described_class.new(viewable_id, viewable_type, external_url, position).perform_now }++ it "is queued in the correct queue" do+ expect(described_class.queue_name).to eq(queue_name.to_s)+ end++ it "can be enqueued" do+ expect {+ described_class.perform_later(viewable_id, viewable_type, external_url, position)+ }.to have_enqueued_job(described_class)+ .with(viewable_id, viewable_type, external_url, position)+ .on_queue(queue_name)+ end++ context "when performing the job" do+ let(:image_scope) { double('image_scope') }+ let(:image) { variant.images.last }+ let(:file_double) { StringIO.new("imagecontent") }+ let(:filename) { "bar_image.png" }+ let(:uri_double) {+ instance_double(URI::HTTPS, path: "/foo/bar_image.png", open: file_double)+ }++ before do+ allow(URI).to receive(:parse).with(external_url.downcase.strip).and_return(uri_double)+ allow(uri_double).to receive(:scheme).and_return('https')+ end++ it "downloads and attaches image from the URL" do+ expect { subject }.to change(Spree::Image, :count).by(1)+ expect(image.attachment).to be_attached+ expect(image.external_url).to eq(external_url.downcase.strip)+ expect(image.position).to eq(1)+ end++ context 'with position' do+ let(:position) { 2 }++ it "sets the position if provided" do+ subject+ expect(image.position).to eq(position)+ end+ end++ context "when image already exists with the given external_url" do+ let!(:image) { create(:image, viewable: variant) }++ before do+ image.external_url = external_url.downcase.strip+ image.save!+ end++ it "does not re-download but triggers save!" do+ expect(URI).not_to receive(:parse)+ expect(URI).not_to receive(:open)+ expect { subject }.not_to change(image, :attachment)+ end+ end+ end+enddiff --git a/core/spec/jobs/spree/imports/create_rows_job_spec.rb b/core/spec/jobs/spree/imports/create_rows_job_spec.rbnew file mode 100644index 0000000000..d743cc8b0e--- /dev/null+++ b/core/spec/jobs/spree/imports/create_rows_job_spec.rb@@ -0,0 +1,71 @@+require 'spec_helper'++RSpec.describe Spree::Imports::CreateRowsJob, type: :job do+ let(:user) { create(:admin_user) }+ let(:store) { @default_store }++ let(:csv_content) do+ <<~CSV+ slug,sku,name,price,option1_name,option1_value+ denim-shirt,SKU1,Denim Shirt,9.99+ denim-shirt,SKU2,,19.99,Color,Red+ CSV+ end++ let!(:import) do+ create(+ :import,+ user: user,+ owner: store,+ type: 'Spree::Imports::Products',+ status: :completed_mapping+ )+ end++ before do+ # Attach CSV as import attachment+ import.attachment.attach(+ io: StringIO.new(csv_content),+ filename: 'products.csv',+ content_type: 'text/csv'+ )+ end++ it 'creates import rows from the CSV file' do+ expect {+ described_class.perform_now(import.id)+ }.to change { Spree::ImportRow.where(import: import).count }.by(2)++ first_row = import.rows.find_by(row_number: 1)+ expect(first_row.data).to eq({ 'slug' => 'denim-shirt', 'sku' => 'SKU1', 'name' => 'Denim Shirt', 'price' => '9.99', 'option1_name' => nil, 'option1_value' => nil }.to_json)+ expect(first_row.status).to eq('pending')++ second_row = import.rows.find_by(row_number: 2)+ expect(second_row.data).to eq({ 'slug' => 'denim-shirt', 'sku' => 'SKU2', 'name' => nil, 'price' => '19.99', 'option1_name' => 'Color', 'option1_value' => 'Red' }.to_json)+ expect(second_row.status).to eq('pending')+ end++ it 'transitions import to processing if not already processing' do+ expect { described_class.perform_now(import.id) }.to change { import.reload.status }.from('completed_mapping').to('processing')+ end++ it 'persists rows count' do+ expect { described_class.perform_now(import.id) }.to change { import.reload.rows_count }.from(0).to(2)+ end++ it 'enqueues process_rows_async after rows creation' do+ expect_any_instance_of(Spree::Import).to receive(:process_rows_async).once+ described_class.perform_now(import.id)+ end++ context 'when CSV is malformed' do+ let(:csv_content) { "bad data \x80" }++ it 'sets processing_errors and fails the import' do+ described_class.perform_now(import.id)+ import.reload+ expect(import.status).to eq('failed')+ expect(import.processing_errors).to be_present+ end+ end+enddiff --git a/core/spec/jobs/spree/imports/process_rows_job_spec.rb b/core/spec/jobs/spree/imports/process_rows_job_spec.rbnew file mode 100644index 0000000000..bec0e617ed--- /dev/null+++ b/core/spec/jobs/spree/imports/process_rows_job_spec.rb@@ -0,0 +1,61 @@+require 'spec_helper'++RSpec.describe Spree::Imports::ProcessRowsJob, type: :job do+ let(:store) { @default_store }++ let!(:import) do+ create(+ :import,+ owner: store,+ type: 'Spree::Imports::Products',+ status: :processing+ )+ end++ let!(:pending_row) do+ create(+ :import_row,+ import: import,+ row_number: 1,+ status: :pending,+ data: { 'slug' => 'test-product', 'sku' => 'SKU1', 'name' => 'Test Product', 'price' => '9.99' }.to_json+ )+ end++ let!(:failed_row) do+ create(+ :import_row,+ import: import,+ row_number: 2,+ status: :failed,+ data: { 'slug' => 'failed-product', 'sku' => 'SKU2', 'name' => 'Failed Product', 'price' => '19.99' }.to_json+ )+ end++ let!(:processed_row) do+ create(+ :import_row,+ import: import,+ row_number: 3,+ status: :completed,+ data: { 'slug' => 'processed-product', 'sku' => 'SKU3', 'name' => 'Processed Product', 'price' => '29.99' }.to_json+ )+ end++ before do+ allow(import).to receive(:csv_headers).and_return(['slug', 'sku', 'name', 'price'])+ import.create_mappings+ end++ it 'processes pending and failed rows' do+ expect {+ described_class.perform_now(import.id)+ }.to change { pending_row.reload.status }.from('pending').to('completed').and change { failed_row.reload.status }.from('failed').to('completed')+ end++ it 'marks import as complete after processing all rows' do+ expect {+ described_class.perform_now(import.id)+ }.to change { import.reload.status }.from('processing').to('completed')+ end+enddiff --git a/core/spec/models/concerns/spree/metafields_spec.rb b/core/spec/models/concerns/spree/metafields_spec.rbindex d5bbcf0812..779d325d02 100644--- a/core/spec/models/concerns/spree/metafields_spec.rb+++ b/core/spec/models/concerns/spree/metafields_spec.rb@@ -22,12 +22,12 @@ RSpec.describe Spree::Metafields, type: :concern dolet!(:metafield) { create(:metafield, resource: product, metafield_definition: definition) }it 'returns products with the given metafield key' do- expect(Spree::Product.with_metafield_key('custom', 'foo')).to include(product)+ expect(Spree::Product.with_metafield_key('custom.foo')).to include(product)endit 'does not return products without the given metafield key' doother_product = create(:product)- expect(Spree::Product.with_metafield_key('custom', 'foo')).not_to include(other_product)+ expect(Spree::Product.with_metafield_key('custom.foo')).not_to include(other_product)endend@@ -36,11 +36,11 @@ RSpec.describe Spree::Metafields, type: :concern dolet!(:metafield) { create(:metafield, resource: product, metafield_definition: definition, value: 'baz') }it 'returns products with the given metafield key and value' do- expect(Spree::Product.with_metafield_key_value('custom', 'bar', 'baz')).to include(product)+ expect(Spree::Product.with_metafield_key_value('custom.bar', 'baz')).to include(product)endit 'does not return products with the key but different value' do- expect(Spree::Product.with_metafield_key_value('custom', 'bar', 'other')).not_to include(product)+ expect(Spree::Product.with_metafield_key_value('custom.bar', 'other')).not_to include(product)endenddiff --git a/core/spec/models/spree/asset_spec.rb b/core/spec/models/spree/asset_spec.rbindex 5a3a082b72..106965179e 100644--- a/core/spec/models/spree/asset_spec.rb+++ b/core/spec/models/spree/asset_spec.rb@@ -62,4 +62,43 @@ describe Spree::Asset, type: :model doexpect(subject).to contain_exactly(*assets)endend++ context 'external URL' do+ before do+ create(:metafield_definition, namespace: 'external', key: 'url', resource_type: 'Spree::Asset')+ end++ describe '.with_external_url' do+ it 'returns assets with the given external URL' do+ asset = create(:asset)+ asset.set_metafield('external.url', 'https://example.com')+ expect(described_class.with_external_url('https://example.com')).to include(asset)+ end++ it 'returns no assets if the external URL is blank' do+ expect(described_class.with_external_url(nil)).to be_empty+ end+ end++ describe '#external_url' do+ it 'returns the external URL' do+ asset = create(:asset)+ asset.set_metafield('external.url', 'https://example.com')+ expect(asset.external_url).to eq('https://example.com')+ end++ it 'returns nil if the external URL is blank' do+ asset = create(:asset)+ expect(asset.external_url).to be_nil+ end+ end++ describe '#external_url=' do+ it 'sets the external URL' do+ asset = create(:asset)+ asset.external_url = 'https://example.com'+ expect(asset.external_url).to eq('https://example.com')+ end+ end+ endenddiff --git a/core/spec/models/spree/import_row_spec.rb b/core/spec/models/spree/import_row_spec.rbnew file mode 100644index 0000000000..8460ed53db--- /dev/null+++ b/core/spec/models/spree/import_row_spec.rb@@ -0,0 +1,218 @@+require 'spec_helper'++RSpec.describe Spree::ImportRow, :job, type: :model do+ let(:store) { @default_store }+ let(:import) { create(:product_import, owner: store) }+ let(:import_row) { build(:import_row, import: import, row_number: 1, data: '{"slug": "test-product", "name": "Test Product", "price": "10.00"}') }++ let(:csv_content) { File.read(File.join(Spree::Core::Engine.root, 'spec/fixtures/files', 'products_import.csv')) }++ before do+ # Stub the file content reading since ActiveStorage doesn't persist files properly in transactional tests+ allow(import).to receive(:attachment_file_content).and_return(csv_content)+ end++ describe 'Associations' do+ describe '#store' do+ it 'delegates to import' do+ import_row.save!+ expect(import_row.store).to eq(store)+ end+ end+ end++ describe 'Validations' do+ context 'row_number uniqueness' do+ before { import_row.save! }++ it 'validates uniqueness scoped to import_id' do+ duplicate_row = build(:import_row, import: import, row_number: 1)+ expect(duplicate_row).not_to be_valid+ expect(duplicate_row.errors[:row_number]).to include('has already been taken')+ end++ it 'allows same row_number for different imports' do+ other_import = create(:product_import, owner: store)+ other_row = build(:import_row, import: other_import, row_number: 1)+ expect(other_row).to be_valid+ end+ end+ end++ describe 'State machine' do+ before { import_row.save! }++ describe 'initial state' do+ it 'starts in pending state' do+ expect(import_row.status).to eq('pending')+ end+ end++ describe 'start_processing event' do+ it 'transitions from pending to processing' do+ expect { import_row.start_processing! }.to change(import_row, :status).from('pending').to('processing')+ end+ end++ describe 'fail event' do+ before { import_row.start_processing! }++ it 'transitions from processing to failed' do+ expect { import_row.fail! }.to change(import_row, :status).from('processing').to('failed')+ end++ it 'adds row to import view after transition' do+ expect(import_row).to receive(:add_row_to_import_view)+ import_row.fail!+ end++ it 'updates footer in import view after transition' do+ expect(import_row).to receive(:update_footer_in_import_view)+ import_row.fail!+ end+ end++ describe 'complete event' do+ before { import_row.start_processing! }++ it 'transitions from processing to completed' do+ expect { import_row.complete! }.to change(import_row, :status).from('processing').to('completed')+ end++ it 'adds row to import view after transition' do+ expect(import_row).to receive(:add_row_to_import_view)+ import_row.complete!+ end++ it 'updates footer in import view after transition' do+ expect(import_row).to receive(:update_footer_in_import_view)+ import_row.complete!+ end+ end+ end++ describe 'Scopes' do+ let!(:pending_row) { create(:import_row, import: import, status: 'pending') }+ let!(:failed_row) { create(:import_row, import: import, status: 'failed') }+ let!(:completed_row) { create(:import_row, import: import, status: 'completed') }+ let!(:processing_row) { create(:import_row, import: import, status: 'processing') }++ describe '.pending_and_failed' do+ it 'returns pending and failed rows' do+ expect(described_class.pending_and_failed).to include(pending_row, failed_row)+ expect(described_class.pending_and_failed).not_to include(completed_row, processing_row)+ end+ end++ describe '.completed' do+ it 'returns only completed rows' do+ expect(described_class.completed).to include(completed_row)+ expect(described_class.completed).not_to include(pending_row, failed_row, processing_row)+ end+ end++ describe '.failed' do+ it 'returns only failed rows' do+ expect(described_class.failed).to include(failed_row)+ expect(described_class.failed).not_to include(pending_row, completed_row, processing_row)+ end+ end++ describe '.processed' do+ it 'returns completed and failed rows' do+ expect(described_class.processed).to include(completed_row, failed_row)+ expect(described_class.processed).not_to include(pending_row, processing_row)+ end+ end+ end++ describe '#data_json' do+ context 'with valid JSON data' do+ it 'returns parsed JSON' do+ expect(import_row.data_json).to eq({+ 'slug' => 'test-product',+ 'name' => 'Test Product',+ 'price' => '10.00'+ })+ end++ it 'memoizes the result' do+ expect(JSON).to receive(:parse).once.and_call_original+ 2.times { import_row.data_json }+ end+ end++ context 'with invalid JSON data' do+ before { import_row.data = 'invalid json' }++ it 'returns empty hash' do+ expect(import_row.data_json).to eq({})+ end+ end+ end++ describe '#to_schema_hash' do+ before do+ import.create_mappings+ end++ it 'returns attributes mapped to schema fields' do+ schema_hash = import_row.to_schema_hash+ expect(schema_hash).to be_a(Hash)+ expect(schema_hash).to have_key('slug')+ end+ end++ describe '#attribute_by_schema_field' do+ before do+ import.create_mappings+ end++ it 'returns the mapped attribute value' do+ result = import_row.attribute_by_schema_field('slug')+ expect(result).to eq('test-product')+ end+ end++ describe '#process!' do+ let(:processor) { double('processor') }+ let(:product) { create(:product) }++ before do+ import_row.save!+ allow(import).to receive(:row_processor_class).and_return(double(new: processor))+ end++ context 'when processing succeeds' do+ before do+ allow(processor).to receive(:process!).and_return(product)+ end++ it 'transitions to processing then completed' do+ expect { import_row.process! }.to change(import_row, :status).from('pending').to('completed')+ end++ it 'sets the item' do+ import_row.process!+ expect(import_row.item).to eq(product)+ end+ end++ context 'when processing fails' do+ let(:error_message) { 'Processing failed' }++ before do+ allow(processor).to receive(:process!).and_raise(StandardError, error_message)+ end++ it 'transitions to failed' do+ expect { import_row.process! }.to change(import_row, :status).from('pending').to('failed')+ end++ it 'sets validation errors' do+ import_row.process!+ expect(import_row.validation_errors).to eq(error_message)+ end+ end+ end+enddiff --git a/core/spec/models/spree/import_spec.rb b/core/spec/models/spree/import_spec.rbnew file mode 100644index 0000000000..ba74891b1a--- /dev/null+++ b/core/spec/models/spree/import_spec.rb@@ -0,0 +1,297 @@+require 'spec_helper'++RSpec.describe Spree::Import, :job, type: :model do+ let(:store) { @default_store }+ let(:user) { create(:admin_user) }++ let(:csv_content) { File.read(File.join(Spree::Core::Engine.root, 'spec/fixtures/files', 'products_import.csv')) }+ let(:import) { build(:product_import, owner: store, user: user) }++ before do+ # Stub the file content reading since ActiveStorage doesn't persist files properly in transactional tests+ allow(import).to receive(:attachment_file_content).and_return(csv_content)+ end++ describe 'Validations' do+ context 'type validation' do+ it 'validates type is whitelisted' do+ import.type = 'InvalidType'+ expect(import).not_to be_valid+ expect(import.errors[:type].first).to include('is not included in the list')+ end++ it 'allows valid types' do+ import.type = 'Spree::Imports::Products'+ expect(import).to be_valid+ end+ end++ context 'attachment validation' do+ it 'validates attachment content type' do+ import.attachment.attach(+ io: StringIO.new('test'),+ filename: 'test.txt',+ content_type: 'text/plain'+ )+ expect(import).not_to be_valid+ expect(import.errors[:attachment].first).to include('content type')+ end+ end+ end++ describe 'State machine' do+ before { import.save! }++ describe 'initial state' do+ it 'starts in pending state' do+ expect(import.status).to eq('pending')+ end+ end++ describe 'start_mapping event' do+ it 'transitions from pending to mapping' do+ expect { import.start_mapping! }.to change(import, :status).from('pending').to('mapping')+ end++ it 'creates mappings before transition' do+ expect { import.start_mapping! }.to change { import.mappings.count }.from(0)+ end+ end++ describe 'complete_mapping event' do+ before { import.start_mapping! }++ it 'transitions from mapping to completed_mapping' do+ expect { import.complete_mapping! }.to change(import, :status).from('mapping').to('completed_mapping')+ end++ it 'creates rows asynchronously after transition' do+ expect(import).to receive(:create_rows_async)+ import.complete_mapping!+ end+ end++ describe 'start_processing event' do+ before do+ import.start_mapping!+ import.complete_mapping!+ end++ it 'transitions from completed_mapping to processing' do+ expect { import.start_processing! }.to change(import, :status).from('completed_mapping').to('processing')+ end+ end++ describe 'complete event' do+ before do+ import.start_mapping!+ import.complete_mapping!+ import.start_processing!+ end++ it 'transitions from processing to completed' do+ expect { import.complete! }.to change(import, :status).from('processing').to('completed')+ end++ it 'sends import completed email after transition' do+ expect(import).to receive(:send_import_completed_email)+ import.complete!+ end++ it 'updates loader in import view after transition' do+ expect(import).to receive(:update_loader_in_import_view)+ import.complete!+ end+ end+ end++ describe '#model_class' do+ context 'for Products import' do+ it 'returns Spree::Product' do+ import.type = 'Spree::Imports::Products'+ expect(import.model_class).to eq(Spree::Product)+ end+ end++ context 'for Customers import' do+ it 'returns the user class' do+ import.type = 'Spree::Imports::Customers'+ expect(import.model_class).to eq(Spree.user_class)+ end+ end+ end++ describe '#import_schema' do+ it 'returns the correct schema class' do+ import.type = 'Spree::Imports::Products'+ expect(import.import_schema).to be_a(Spree::ImportSchemas::Products)+ end+ end++ describe '#display_name' do+ before { import.save! } # need to generate the number++ it 'returns the correct display name' do+ expect(import.display_name).to match(/Products IM\d+/)+ end+ end++ describe '#csv_headers' do+ it 'returns the CSV headers' do+ expect(import.csv_headers).to eq([+ 'slug',+ 'sku',+ 'name',+ 'status',+ 'vendor_name',+ 'brand_name',+ 'description',+ 'meta_title',+ 'meta_description',+ 'meta_keywords',+ 'tags',+ 'labels',+ 'price',+ 'compare_at_price',+ 'currency',+ 'width',+ 'height',+ 'depth',+ 'dimensions_unit',+ 'weight',+ 'weight_unit',+ 'available_on',+ 'discontinue_on',+ 'track_inventory',+ 'inventory_count',+ 'inventory_backorderable',+ 'tax_category',+ 'digital',+ 'image1_src',+ 'image2_src',+ 'image3_src',+ 'option1_name',+ 'option1_value',+ 'option2_name',+ 'option2_value',+ 'option3_name',+ 'option3_value',+ 'category1',+ 'category2',+ 'category3',+ 'metafield.properties.fit',+ 'metafield.properties.manufacturer',+ 'metafield.properties.material'+ ])+ end++ context 'with custom delimiter' do+ let(:csv_content) { "slug;sku;name;price\ntest;SKU1;Test;9.99" }++ before { import.preferred_delimiter = ';' }++ it 'parses headers with custom delimiter' do+ expect(import.csv_headers).to eq(['slug', 'sku', 'name', 'price'])+ end+ end+ end++ describe '#create_mappings' do+ before { import.save! }++ it 'creates mappings for schema fields' do+ expect { import.create_mappings }.to change { import.mappings.count }.from(0)+ end++ it 'auto-assigns file columns when possible' do+ import.create_mappings+ slug_mapping = import.mappings.find_by(schema_field: 'slug')+ expect(slug_mapping.file_column).to eq('slug')+ end+ end++ describe '#unmapped_file_columns' do+ before do+ import.save!+ import.create_mappings+ # Map only slug column+ import.mappings.find_by(schema_field: 'slug').update!(file_column: 'slug')+ end++ it 'returns columns that are not mapped' do+ expect(import.unmapped_file_columns).to include("vendor_name", "brand_name", "labels", "metafield.properties.fit", "metafield.properties.manufacturer", "metafield.properties.material")+ expect(import.unmapped_file_columns).not_to include('slug')+ end+ end++ describe '#mapping_done?' do+ before do+ import.save!+ end++ context 'when all required fields are mapped' do+ before do+ import.create_mappings+ end++ it 'returns true' do+ expect(import.mapping_done?).to be true+ end+ end++ context 'when not all required fields are mapped' do+ it 'returns false' do+ expect(import.mapping_done?).to be false+ end+ end+ end++ describe '#create_rows_async' do+ before { import.save! }++ it 'enqueues CreateRowsJob' do+ expect { import.create_rows_async }.to have_enqueued_job(Spree::Imports::CreateRowsJob).with(import.id)+ end+ end++ describe '#process_rows_async' do+ before { import.save! }++ it 'enqueues ProcessRowsJob' do+ expect { import.process_rows_async }.to have_enqueued_job(Spree::Imports::ProcessRowsJob).with(import.id)+ end+ end++ describe '#store' do+ context 'when owner is a Store' do+ it 'returns the owner' do+ expect(import.store).to eq(store)+ end+ end+ end++ describe '.available_types' do+ it 'returns configured import types' do+ expect(described_class.available_types).to eq(Rails.application.config.spree.import_types)+ end+ end++ describe '.available_models' do+ it 'returns model classes for available types' do+ expect(described_class.available_models).to include(Spree::Product)+ end+ end++ describe '.type_for_model' do+ it 'returns the import type for a given model' do+ type = described_class.type_for_model(Spree::Product)+ expect(type.to_s).to eq('Spree::Imports::Products')+ end+ end++ describe '.model_class' do+ it 'returns the model class for the import type' do+ expect(Spree::Imports::Products.model_class).to eq(Spree::Product)+ end+ end+enddiff --git a/core/spec/presenters/spree/csv/product_variant_presenter_spec.rb b/core/spec/presenters/spree/csv/product_variant_presenter_spec.rbindex e73129f4c1..3edf9a5a51 100644--- a/core/spec/presenters/spree/csv/product_variant_presenter_spec.rb+++ b/core/spec/presenters/spree/csv/product_variant_presenter_spec.rb@@ -68,7 +68,6 @@ RSpec.describe Spree::CSV::ProductVariantPresenter doit 'returns nil for product-level fields' doexpect(subject[2]).to be_nil # name- expect(subject[3]).to be_nil # slugexpect(subject[4]).to be_nil # statusexpect(subject[5]).to be_nil # vendor_nameenddiff --git a/core/spec/services/spree/imports/row_processors/product_variant_spec.rb b/core/spec/services/spree/imports/row_processors/product_variant_spec.rbnew file mode 100644index 0000000000..13603a9ae3--- /dev/null+++ b/core/spec/services/spree/imports/row_processors/product_variant_spec.rb@@ -0,0 +1,192 @@+require 'spec_helper'++RSpec.describe Spree::Imports::RowProcessors::ProductVariant, type: :service do+ subject { described_class.new(row) }++ let(:store) { Spree::Store.default }+ let(:import) { create(:product_import, owner: store) }+ let(:row) { create(:import_row, import: import, data: row_data.to_json) }+ let(:csv_row_headers) { Spree::ImportSchemas::Products.new.headers }+ let(:variant) { subject.process! }++ before do+ import.create_mappings+ end++ # Matches how our production import will pass attributes+ def csv_row_hash(attrs = {})+ csv_row_headers.index_with { |header| attrs[header] }+ end++ context 'when importing a master variant product row' do+ let(:row_data) do+ csv_row_hash(+ 'slug' => 'denim-shirt',+ 'name' => 'Denim Shirt',+ 'status' => 'draft',+ 'description' => 'Adipisci sapiente velit nihil ullam. Placeat cumque ipsa cupiditate velit magni sapiente mollitia dolorum. Veritatis esse illo eos perferendis. Perspiciatis vel iusto odio eveniet quam officia quidem. Fugiat a ipsum tempore optio accusantium autem in fugit.',+ 'price' => '62.99',+ 'currency' => 'USD',+ 'weight' => '0.0',+ 'inventory_count' => '100',+ 'inventory_backorderable' => 'true',+ 'tags' => 'ECO, Gold'+ )+ end++ it 'creates a product and sets correct attributes' do+ product = variant.product++ expect(product).to be_persisted+ expect(product.slug).to eq 'denim-shirt'+ expect(product.name).to eq 'Denim Shirt'+ expect(product.status).to eq 'draft'+ expect(product.description).to eq row_data['description']+ expect(product.stores).to include(store)+ expect(product.tag_list).to contain_exactly('ECO', 'Gold')+ expect(product.master).to eq variant+ expect(variant.sku).to be_blank+ expect(variant.price_in('USD').amount.to_f).to eq 62.99+ expect(variant.weight.to_f).to eq 0.0+ expect(variant.stock_items.first.count_on_hand).to eq 100+ expect(variant.stock_items.first.backorderable).to eq true+ end+ end++ context 'when importing a variant row with options' do+ let!(:product) do+ # Pre-create the product and associate to the store+ p = create(:product, slug: 'denim-shirt', name: 'Denim Shirt', stores: [store])+ # Add Color and Size option types+ color = create(:option_type, name: 'color', presentation: 'Color')+ size = create(:option_type, name: 'size', presentation: 'Size')+ p.option_types << color+ p.option_types << size+ p+ end++ let(:row_data) do+ csv_row_hash(+ 'slug' => 'denim-shirt',+ 'sku' => 'DENIM-SHIRT-XS-BLUE',+ 'price' => '62.99',+ 'currency' => 'USD',+ 'weight' => '0.0',+ 'inventory_count' => '100',+ 'inventory_backorderable' => 'true',+ 'option1_name' => 'Color',+ 'option1_value' => 'Blue',+ 'option2_name' => 'Size',+ 'option2_value' => 'XS',+ )+ end++ it 'assigns to existing product and creates/re-uses option values' do+ expect(variant).to be_persisted+ expect(variant.sku).to eq 'DENIM-SHIRT-XS-BLUE'+ expect(variant.price_in('USD').amount.to_f).to eq 62.99++ expect(variant.option_values.map(&:presentation).sort).to contain_exactly('Blue', 'XS')++ # Option values should exist for those names+ color_option_type = Spree::OptionType.search_by_name('Color').first+ size_option_type = Spree::OptionType.search_by_name('Size').first+ expect(color_option_type).to be_present+ expect(size_option_type).to be_present+ expect(color_option_type.option_values.find_by(presentation: 'Blue')).to be_present+ expect(size_option_type.option_values.find_by(presentation: 'XS')).to be_present+ end+ end++ context 'when importing a variant row with a new option type/value' do+ let!(:product) do+ create(:product, slug: 'denim-shirt', name: 'Denim Shirt', stores: [store])+ end++ let(:row_data) do+ csv_row_hash(+ 'slug' => 'denim-shirt',+ 'sku' => 'DENIM-SHIRT-NEW-GREEN',+ 'option1_name' => 'Finish',+ 'option1_value' => 'Green',+ 'price' => '62.99',+ 'currency' => 'USD',+ )+ end++ it 'creates a new option type and value as needed' do+ expect do+ subject.process!+ end.to change { Spree::OptionType.where(presentation: 'Finish').count }.by(1)+ .and change { Spree::OptionValue.where(presentation: 'Green').count }.by(1)++ variant = subject.process!++ expect(variant.option_values.map(&:presentation)).to include('Green')+ end+ end++ context 'with images' do+ let!(:product) do+ create(:product, slug: 'denim-shirt', name: 'Denim Shirt', stores: [store])+ end++ let(:row_data) do+ csv_row_hash(+ 'slug' => 'denim-shirt',+ 'image1_src' => 'https://example.com/image1.jpg',+ 'image2_src' => 'https://example.com/image2.jpg',+ 'image3_src' => 'https://example.com/image3.jpg'+ )+ end++ it 'saves the images' do+ expect { subject.process! }.to have_enqueued_job(Spree::Images::SaveFromUrlJob).exactly(3).times.on_queue(Spree.queues.images)+ .and have_enqueued_job(Spree::Images::SaveFromUrlJob).with(variant.id, 'Spree::Variant', row_data['image1_src'])+ .and have_enqueued_job(Spree::Images::SaveFromUrlJob).with(variant.id, 'Spree::Variant', row_data['image2_src'])+ .and have_enqueued_job(Spree::Images::SaveFromUrlJob).with(variant.id, 'Spree::Variant', row_data['image3_src'])+ end+ end++ context 'when importing a variant with all option columns empty' do+ let!(:product) do+ create(:product, slug: 'denim-shirt', name: 'Denim Shirt', stores: [store])+ end++ let(:row_data) do+ csv_row_hash(+ 'slug' => 'denim-shirt',+ 'sku' => 'DENIM-SHIRT-PLAIN',+ 'price' => '62.99',+ 'currency' => 'USD'+ )+ end++ it 'does not create a variant' do+ expect { subject.process! }.to raise_error(ActiveRecord::RecordInvalid)+ end+ end++ context 'when variant row refers to missing product slug' do+ let(:row_data) do+ csv_row_hash(+ 'slug' => 'new-missing-shirt',+ 'sku' => 'NEW-MISSING-SHIRT-SKU',+ 'name' => 'Brand New Shirt',+ 'status' => 'active',+ 'price' => '99.99',+ 'currency' => 'USD'+ )+ end++ it 'creates a new product and assigns the variant as its master if no option1_name given' do+ variant = subject.process!+ product = variant.product++ expect(product).to be_persisted+ expect(product.slug).to eq 'new-missing-shirt'+ expect(product.master).to eq variant+ expect(variant.sku).to eq 'NEW-MISSING-SHIRT-SKU'+ end+ end+end