Inertia Migration: Edit Product Pages #3301
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes: #3030
Description
This PR migrates the product edit flow to Inertia. The main product edit tab (edit/update), content edit tab, receipt edit tab, and share edit tab are now Inertia pages backed by
Products::MainController,Products::ContentController,Products::ReceiptController, andProducts::ShareControllerSolution
Frontend Changes
Product edit pages and shared components no longer depend on
Reactcontext for sharing data. Each component now receives exactly the props it needs to work.Product edit pages use Inertia's
useFormhelper to manage form stateFollows Bundles Inertia migration pattern for consistency and keeps page state in sync with the server when moving between product edit tabs. If the form is in dirty state, navigation triggers a request so that common data is synced before the next page load.
Backend Changes
Each tab gets only the product fields and metadata it needs (e.g. receipt tab: receipt text and view-content button; content tab: files and content settings).
Controllers/presentersbuild these per-tab payloads.Centralized update logic in
Product::UpdateService. All product-tab updates (main, content, receipt, share) go throughProduct::UpdateService, which updates, publish/unpublish, in one place.Few of the internal API endpoints, used to load tab specific data are now passed as props like
receipt_preview_html(receipt tab), andexisting_files(content tab).For failed form submissions we use status: :found (302) inertia to populate error props (required by inertia, 303 sends empty error object), which is then automatically converted to 303 by Inertia
Backend now supports two new flash cases,
<and ends with>) are passed through withhtml: truein the shared flash props so the client can render them as HTML. Used inProduct::UpdateServicewhen publish fails (e.g. empty seller email), it setsflash[:alert]to an HTML string with a link (e.g. “Set an email”).flash[:inertia]is set with a status that starts with "frontend_alert" and optional data, the backend sends{ status, data }in the shared flash. The client can branch on status and data to show custom UI (e.g. toasts, modals, or inline messages). After saving the content tab, the backend sends a “contents updated” alert with a link so the seller can notify buyers; the content edit page reads that flash and shows the alert with the link.Before/After
Test Results
Request Specs
Other Specs
One flaky elastic search spec
bundle exec rspec spec/controllers/links_controller_spec.rb spec/controllers/products/content_controller_spec.rb spec/controllers/products/main_controller_spec.rb spec/controllers/products/receipt_controller_spec.rb spec/controllers/products/share_controller_spec.rb spec/mailers/contacting_creator_mailer_spec.rb spec/presenters/collab_products_page_presenter_spec.rb spec/presenters/dashboard_products_page_presenter_spec.rb spec/presenters/product_presenter_spec.rb spec/services/product/rich_content_updater_service_spec.rb spec/services/product/variant_category_updater_service_spec.rb spec/services/product/variants_updater_service_spec.rbChecklist
AI Disclosure
Cursor Auto was used for drafting a plan, edits, debugging and documentation checks