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
Fix three more issues from review
Damian Legawiec5b56046ff49b
diff --git a/packages/dashboard-core/src/components/media-picker-sheet.tsx b/packages/dashboard-core/src/components/media-picker-sheet.tsxindex 2b71f0bda7..9238a32e15 100644--- a/packages/dashboard-core/src/components/media-picker-sheet.tsx+++ b/packages/dashboard-core/src/components/media-picker-sheet.tsx@@ -82,6 +82,10 @@ export function MediaPickerSheet<T extends MediaPickerOption>({const [submitting, setSubmitting] = useState(false)const [uploading, setUploading] = useState(false)const fileInputRef = useRef<HTMLInputElement>(null)+ // Bumped whenever the sheet closes. An upload started in an earlier session+ // must not confirm into a host that has already moved on — closing mid-upload+ // would otherwise still set the field the merchant cancelled.+ const sessionRef = useRef(0)// The store id is part of the key: a library is one store's, and without it// reopening the picker after a store switch serves the previous store's@@ -128,12 +132,17 @@ export function MediaPickerSheet<T extends MediaPickerOption>({async function handleUpload(files: FileList | null) {if (!files?.length || !onUpload) return+ const session = sessionRef.currentsetUploading(true)try {const uploaded: T[] = []for (const file of Array.from(files)) {uploaded.push(await onUpload(file))}+ // The file is in the library either way — only the confirmation is+ // abandoned, so nothing the merchant uploaded is lost.+ if (session !== sessionRef.current) return+await refetch()if (multiple) {@@ -159,7 +168,10 @@ export function MediaPickerSheet<T extends MediaPickerOption>({}function handleOpenChange(next: boolean) {- if (!next) reset()+ if (!next) {+ sessionRef.current += 1+ reset()+ }onOpenChange(next)}diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/media.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/media.tsxindex 3aa60024df..b8fd35b2f8 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/media.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/media.tsx@@ -435,6 +435,10 @@ function MediaDetailSheet({const updateFile = useUpdateMediaLibraryFile()const usage = useMediaUsage(media?.id ?? null)const [alt, setAlt] = useState('')+ // Compared against what was last saved, not against the record the sheet+ // opened with: that snapshot never refreshes, so after a successful save it+ // would still hold the old alt and every close would ask to discard.+ const [savedAlt, setSavedAlt] = useState('')const [poster, setPoster] = useState<{signedId: string | nullpreviewUrl: string | null@@ -447,22 +451,27 @@ function MediaDetailSheet({if (media && seededFor !== media.id) {setSeededFor(media.id)setAlt(media.alt ?? '')+ setSavedAlt(media.alt ?? '')setPoster({ signedId: null, previewUrl: null, cleared: false })}const references = usage.data?.data ?? []- const isDirty = !!media && alt !== (media.alt ?? '')+ const isDirty = !!media && alt !== savedAlt// An explicit save, not save-on-blur: blur is invisible, so a merchant had// no way to tell whether their edit stuck.function saveAlt() {if (!media || !isDirty) return+ const submitted = altupdateFile.mutate(- { id: media.id, alt },+ { id: media.id, alt: submitted },{- onSuccess: () => toastManager.add({ type: 'success', title: t('admin.messages.saved') }),+ onSuccess: () => {+ setSavedAlt(submitted)+ toastManager.add({ type: 'success', title: t('admin.messages.saved') })+ },onError: () => toastManager.add({ type: 'error', title: t('admin.errors.failed_to_save') }),},)diff --git a/spree/core/lib/spree/upgrades/5_6_to_6_0/manifest.yml b/spree/core/lib/spree/upgrades/5_6_to_6_0/manifest.ymlindex 8ca66f6353..3fdd11dc00 100644--- a/spree/core/lib/spree/upgrades/5_6_to_6_0/manifest.yml+++ b/spree/core/lib/spree/upgrades/5_6_to_6_0/manifest.yml@@ -84,19 +84,6 @@ steps:Idempotent — rows that already carry a store_id are skipped, so aninterrupted run resumes for free.- - id: backfill_library_media_placements- name: "Place existing category and collection images in the media library"- task: "spree:upgrade:backfill_library_media_placements"- notes: |- Category and collection images used to exist only as attachments —- in storage but invisible to the media library. New uploads create their- library placement on save; this walks the records that predate that.-- Runs after backfill_media_store_ids so the library the placements land- in is already store-scoped.-- Idempotent — slots that already have their placement are skipped.-- id: remove_master_variantname: "Migrate products off the master variant"task: "spree:remove_master_variant"@@ -130,6 +117,22 @@ steps:Idempotent. Multi-tenant installs run the per-tenant override shipped byspree_multi_tenant.+ - id: backfill_library_media_placements+ name: "Place existing category and collection images in the media library"+ task: "spree:upgrade:backfill_library_media_placements"+ notes: |+ Category and collection images used to exist only as attachments —+ in storage but invisible to the media library. New uploads create their+ library placement on save; this walks the records that predate that.++ Runs after backfill_media_store_ids so the library the placements land+ in is already store-scoped, and after+ migrate_taxons_to_categories_and_collections, which moves image+ attachments onto collections with a callback-bypassing write — a+ placement created before that step would be left behind on the category.++ Idempotent — slots that already have their placement are skipped.+- id: migrate_users_to_customersname: "Move users onto the gem-owned Customer/AdminUser models"task: "spree:upgrade:migrate_users_to_customers"