Skip to content

fix: replace item popup with shared item popup, adjust props and actions - #1034

Open
tomrndom wants to merge 1 commit into
masterfrom
fix/sponsor-global-manage-item-popup
Open

fix: replace item popup with shared item popup, adjust props and actions#1034
tomrndom wants to merge 1 commit into
masterfrom
fix/sponsor-global-manage-item-popup

Conversation

@tomrndom

@tomrndom tomrndom commented Aug 4, 2026

Copy link
Copy Markdown

ref: https://app.clickup.com/t/9014802374/86bb7u2gt

Signed-off-by: Tomás Castillo tcastilloboireau@gmail.com

Summary by CodeRabbit

  • New Features

    • Added configurable validation requiring a positive default quantity when creating or editing sponsor inventory items.
    • Unified sponsor inventory creation, editing, and inline updates through a consistent dialog experience.
    • Added distinct success feedback for newly created and updated items.
  • Bug Fixes

    • Improved required-field validation for sponsor item codes, names, and default quantities.
    • Prevented invalid quantity values from being submitted.

…in actions, add tests

Signed-off-by: Tomás Castillo <tcastilloboireau@gmail.com>
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 964c1ebf-a778-4c66-a94b-279c8743d4d6

📥 Commits

Reviewing files that changed from the base of the PR and between 78ef677 and 1b3e483.

📒 Files selected for processing (7)
  • src/actions/sponsor-forms-actions.js
  • src/pages/sponsors-global/form-templates/__tests__/sponsor-inventory-popup.test.js
  • src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js
  • src/pages/sponsors/sponsor-form-item-list-page/__tests__/sponsor-form-item-list-page.test.js
  • src/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-form.js
  • src/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-popup.js
  • src/pages/sponsors/sponsor-form-item-list-page/index.js
💤 Files with no reviewable changes (2)
  • src/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-form.js
  • src/pages/sponsors/sponsor-form-item-list-page/components/sponsor-form-item-popup.js

📝 Walkthrough

Walkthrough

The PR consolidates sponsor item creation and updates into saveSponsorFormItem, adds conditional default_quantity validation to SponsorItemDialog, and replaces the legacy sponsor item popup with the inventory dialog on the sponsor form item page.

Changes

Sponsor item CRUD

Layer / File(s) Summary
Unified sponsor item save action
src/actions/sponsor-forms-actions.js
saveSponsorFormItem uses POST for new items and PUT for existing items. It dispatches separate success notifications and always stops loading.
Inventory dialog quantity validation
src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js, src/pages/sponsors-global/form-templates/__tests__/*
default_quantity is conditionally required through requireDefaultQuantity. Tests cover dialog modes, required fields, validation, and successful submission.
Sponsor item page integration
src/pages/sponsors/sponsor-form-item-list-page/index.js, src/pages/sponsors/sponsor-form-item-list-page/components/*, src/pages/sponsors/sponsor-form-item-list-page/__tests__/*
The page uses SponsorInventoryDialog and saveSponsorFormItem for CRUD and inline edits. The legacy form and popup components are removed. Tests use the shared save action.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: santipalenque, smarcet

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: replacing the item popup and updating related props and actions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sponsor-global-manage-item-popup

Comment @coderabbitai help to get the list of available commands.


return Promise.all(promises).then(() => {
if (entity.id) {
return putRequest(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomrndom This branch was cut from 78ef677c (Aug 3) and does not contain #1002 (merged Aug 21), so this rewrite of saveSponsorFormItem sits on top of the pre-#1002 version of the file and reverts it. GitHub already reports the PR as CONFLICTING; master is 31 commits ahead.

#1002 deliberately stopped sending images in the item request body, because the nested-images path replaces the whole collection on update. origin/master:src/actions/sponsor-forms-actions.js:1424-1429:

// Images are never round-tripped inline: the item add/update endpoint's
// nested-images path only clones the file name (no S3 copy) and, on
// update, replaces the whole collection - wiping cloned-from-inventory
// images whose id it can't preserve. New uploads are persisted separately
// via saveNewItemImages once the item itself is saved.
delete normalizedEntity.images;

With this branch's normalizeItem, stored images are filtered out — file_path is write_only in purchases-api's ShowFormItemImageSerializer, so a fetched item only carries id + file_url — and the PUT sends images: []. ShowFormItemService.update then runs form_item.images.all().delete() (show_form_item_service.py:95-97). Concretely: upload an image, save, reopen the item, edit the name, save — every image on that item is gone.

What merging as-is would undo:

# master (post-#1002) this branch
1 delete normalizedEntity.images images.filter(img => img.file_path) → PUT sends images: [] → collection wiped
2 saveNewItemImages posts new uploads to /items/{id}/images removed
3 onImageDeleted on SponsorItemDialog, wired to MuiFormikUpload's onDelete absent
4 removeItemFile wired through handleRemoveItemImage in the list page absent
5 expand: "images" on the save request params absent
6 ~450 lines of saveSponsorFormItem / updateSponsorFormItem tests, including "omits persisted images from the update request body so they are never round-tripped" replaced by the pre-#1002 file

Could you rebase onto master and rebuild the change on top of #1002? The intent here — one shared dialog, a single save action, requireDefaultQuantity — still holds. On the new base it needs to keep delete normalizedEntity.images + saveNewItemImages, the expand: "images" param, onImageDeleted passed from sponsor-form-item-list-page/index.js, and master's existing tests, extended to cover the new POST/PUT branch.

@smarcet smarcet left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomrndom please review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants