Skip to content

feat: replace UploadInputV2 with UploadInputV3#891

Open
priscila-moneo wants to merge 2 commits intomasterfrom
feature/replace-v2-upload-for-v3-upload
Open

feat: replace UploadInputV2 with UploadInputV3#891
priscila-moneo wants to merge 2 commits intomasterfrom
feature/replace-v2-upload-for-v3-upload

Conversation

@priscila-moneo
Copy link
Copy Markdown

@priscila-moneo priscila-moneo commented Apr 23, 2026

ref: https://app.clickup.com/t/86b9hy7n5

Summary by CodeRabbit

Release Notes

  • Refactor

    • Updated upload widget components across event forms, sponsor inventory, and upload dialogs for improved consistency and maintainability.
    • Simplified form component lifecycle and state management patterns throughout the application.
  • Tests

    • Updated test infrastructure to align with refactored component structure and module organization.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

Warning

Rate limit exceeded

@priscila-moneo has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 52 minutes and 25 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 52 minutes and 25 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: afa0f9e7-0ea7-4ba8-8ee9-f23b23fc516c

📥 Commits

Reviewing files that changed from the base of the PR and between 13964a9 and 7c52cd0.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (1)
  • package.json
📝 Walkthrough

Walkthrough

This PR refactors upload component infrastructure by migrating from UploadInputV2 to UploadInputV3, removing the local MuiFormikUpload component, consolidating imports from a shared library, simplifying event form lifecycle methods, and updating corresponding test expectations.

Changes

Cohort / File(s) Summary
Upload Input V2 to V3 Migration
src/components/forms/event-material-form.js, src/components/upload-dialog/index.js
Migrate upload widgets from UploadInputV2 to UploadInputV3 with same configuration props.
MuiFormikUpload Consolidation
src/components/mui/formik-inputs/mui-formik-upload.js, src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js, src/pages/sponsors-global/page-templates/page-template-popup/modules/page-template-document-download-module.js
Delete local MuiFormikUpload implementation; switch sponsor inventory form from UploadInputV2 to MuiFormikUpload; change MuiFormikUpload import from local path to named library import, removing custom upload handlers and field wiring complexity.
Event Forms Refactoring
src/components/forms/event-comment-form.js
Simplify componentDidUpdate signature, refactor state updates to use shorthand property syntax, remove unused imports (Dropdown, UploadInputV2, TextEditor), and drop error prop from form field.
Test Updates
src/pages/sponsors-global/page-templates/page-template-popup/page-template-module-form.test.js
Remove mock implementation of mui-formik-upload component and adjust confirmation dialog assertion by removing title field verification.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly Related PRs

Suggested Reviewers

  • tomrndom
  • smarcet

Poem

🐰 Upload components dance and migrate with grace,
V2 steps back, V3 takes its place,
Local forms now borrow from the library shelf,
Refactored and simplified—cleaner thyself! ✨

🚥 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 pull request title accurately and concisely summarizes the main change: replacing UploadInputV2 with UploadInputV3 across the codebase.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/replace-v2-upload-for-v3-upload

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
src/components/forms/event-comment-form.js (1)

136-146: ⚠️ Potential issue | 🟡 Minor

Minor: body field no longer surfaces validation errors.

The error prop was removed from the body field per the summary, but the current textarea is a plain HTML element that never rendered an error message anyway — so removal is a no-op here. If body validation errors are expected server-side (e.g., length limits), consider surfacing them via hasErrors("body", errors) to keep UX consistent with owner_full_name above.

💡 Optional: surface body validation errors
           <div className="col-md-12">
             <label> {T.translate("edit_event_comment.body")}</label>
             <textarea
               id="body"
               value={entity.body}
               onChange={this.handleChange}
               className="form-control"
             />
+            {hasErrors("body", errors) && (
+              <p className="error-label">{hasErrors("body", errors)}</p>
+            )}
           </div>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/forms/event-comment-form.js` around lines 136 - 146, The body
textarea currently never shows validation errors because it is a plain HTML
element; update the JSX in the EventCommentForm to render validation feedback
the same way owner_full_name does: use hasErrors("body", errors) to set an
error/invalid state and render the corresponding error message from errors for
entity.body, keeping the id="body", value={entity.body} and
onChange={this.handleChange} intact so server-side length/validation messages
surface to the user.
src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js (2)

41-47: ⚠️ Potential issue | 🟠 Major

Dropping onImageDeleted causes server-side image files to leak.

Both parent pages pass onImageDeleted (inventory-list-page.js line 421, form-template-item-list-page.js line 318), but the dialog no longer destructures it or invokes it. When users delete images in the UI, MuiFormikUpload removes them from the Formik array, which are then filtered out of the PUT request by normalizeEntity. However, this only removes the image reference from the inventory item—the actual image file on the server is never deleted, leaving orphaned files on disk.

Restore onImageDeleted to the component signature and wire it into the image deletion handler (likely within MuiFormikUpload's onRemove callback if supported, or via custom state tracking), ensuring deleteInventoryItemImage / deleteItemImage are explicitly called when users remove images.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js` around
lines 41 - 47, The SponsorItemDialog component signature dropped onImageDeleted
which causes server-side image files to leak; restore onImageDeleted in the
SponsorItemDialog props and wire it into the image-removal flow used by
MuiFormikUpload so the parent-provided handler is invoked when an image is
removed. Specifically, re-add onImageDeleted to the destructured props in
SponsorItemDialog, locate the image remove callback used by MuiFormikUpload (or
the component/handler that calls onRemove), and call onImageDeleted (or call
deleteInventoryItemImage/deleteItemImage via that prop) with the relevant image
id/path when an image is removed so that normalizeEntity still filters
references but the server-side delete is invoked. Ensure the call uses the same
identifiers expected by the parent pages that pass onImageDeleted so the
existing deleteInventoryItemImage/deleteItemImage logic runs.

72-78: ⚠️ Potential issue | 🟠 Major

Most of mediaType is unused; file size and format validation are not enforced.

The mediaType object (lines 72–78) constructs constraints for file size and allowed formats, but only max_uploads_qty is passed to MuiFormikUpload via the maxFiles prop. The MAX_INVENTORY_IMAGE_UPLOAD_SIZE and ALLOWED_INVENTORY_IMAGE_FORMATS values are not used anywhere—MuiFormikUpload does not accept a mediaType prop or equivalent configuration for these constraints.

The Formik validation schema (line 60) defines images as a basic yup.array() with no file size or extension validation. Either wire the constraints through props if MuiFormikUpload supports them (review its prop interface), or remove the unused configuration and implement server-side validation.

Also applies to: 220-224

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js` around
lines 72 - 78, mediaType is building file-size and format constraints (using
MAX_INVENTORY_IMAGE_UPLOAD_SIZE and ALLOWED_INVENTORY_IMAGE_FORMATS) but those
values are never applied: only max_uploads_qty is passed to MuiFormikUpload and
the Formik/Yup schema for images is just yup.array(), so file size/extension
checks aren’t enforced. Fix by either: (A) if MuiFormikUpload supports props for
max file size and allowed extensions, pass MAX_INVENTORY_IMAGE_UPLOAD_SIZE and
ALLOWED_INVENTORY_IMAGE_FORMATS into the component alongside maxFiles (update
the MuiFormikUpload usage), or (B) remove the unused mediaType and add
client-side validation to the Formik schema (the images field currently defined
as yup.array()) to validate each file’s size and extension against
MAX_INVENTORY_IMAGE_UPLOAD_SIZE and ALLOWED_INVENTORY_IMAGE_FORMATS, and ensure
server-side validation is implemented as a fallback; update or remove mediaType
accordingly and keep only the used constraints.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js`:
- Line 21: The import in
src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js currently
brings in MuiFormikUpload but the PR intends to standardize on UploadInputV3;
update the import to use UploadInputV3 (or explicitly document why
Formik-specific MuiFormikUpload is required in the PR description), and then
update any usage of MuiFormikUpload in this file (e.g., where the component is
rendered) to the UploadInputV3 component name so the file aligns with the other
migrated files (or add a clear comment in the file/PR explaining the deliberate
Formik choice if you must keep MuiFormikUpload).

---

Outside diff comments:
In `@src/components/forms/event-comment-form.js`:
- Around line 136-146: The body textarea currently never shows validation errors
because it is a plain HTML element; update the JSX in the EventCommentForm to
render validation feedback the same way owner_full_name does: use
hasErrors("body", errors) to set an error/invalid state and render the
corresponding error message from errors for entity.body, keeping the id="body",
value={entity.body} and onChange={this.handleChange} intact so server-side
length/validation messages surface to the user.

In `@src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js`:
- Around line 41-47: The SponsorItemDialog component signature dropped
onImageDeleted which causes server-side image files to leak; restore
onImageDeleted in the SponsorItemDialog props and wire it into the image-removal
flow used by MuiFormikUpload so the parent-provided handler is invoked when an
image is removed. Specifically, re-add onImageDeleted to the destructured props
in SponsorItemDialog, locate the image remove callback used by MuiFormikUpload
(or the component/handler that calls onRemove), and call onImageDeleted (or call
deleteInventoryItemImage/deleteItemImage via that prop) with the relevant image
id/path when an image is removed so that normalizeEntity still filters
references but the server-side delete is invoked. Ensure the call uses the same
identifiers expected by the parent pages that pass onImageDeleted so the
existing deleteInventoryItemImage/deleteItemImage logic runs.
- Around line 72-78: mediaType is building file-size and format constraints
(using MAX_INVENTORY_IMAGE_UPLOAD_SIZE and ALLOWED_INVENTORY_IMAGE_FORMATS) but
those values are never applied: only max_uploads_qty is passed to
MuiFormikUpload and the Formik/Yup schema for images is just yup.array(), so
file size/extension checks aren’t enforced. Fix by either: (A) if
MuiFormikUpload supports props for max file size and allowed extensions, pass
MAX_INVENTORY_IMAGE_UPLOAD_SIZE and ALLOWED_INVENTORY_IMAGE_FORMATS into the
component alongside maxFiles (update the MuiFormikUpload usage), or (B) remove
the unused mediaType and add client-side validation to the Formik schema (the
images field currently defined as yup.array()) to validate each file’s size and
extension against MAX_INVENTORY_IMAGE_UPLOAD_SIZE and
ALLOWED_INVENTORY_IMAGE_FORMATS, and ensure server-side validation is
implemented as a fallback; update or remove mediaType accordingly and keep only
the used constraints.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9254e0ee-ed4f-49cc-a14c-eda33e9d7051

📥 Commits

Reviewing files that changed from the base of the PR and between 477dcd0 and 13964a9.

📒 Files selected for processing (7)
  • src/components/forms/event-comment-form.js
  • src/components/forms/event-material-form.js
  • src/components/mui/formik-inputs/mui-formik-upload.js
  • src/components/upload-dialog/index.js
  • src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js
  • src/pages/sponsors-global/page-templates/page-template-popup/modules/page-template-document-download-module.js
  • src/pages/sponsors-global/page-templates/page-template-popup/page-template-module-form.test.js
💤 Files with no reviewable changes (2)
  • src/pages/sponsors-global/page-templates/page-template-popup/page-template-module-form.test.js
  • src/components/mui/formik-inputs/mui-formik-upload.js

} from "@mui/material";
import CloseIcon from "@mui/icons-material/Close";
import { UploadInputV2 } from "openstack-uicore-foundation/lib/components";
import { MuiFormikUpload } from "openstack-uicore-foundation/lib/components";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Inconsistent with PR intent — this file uses MuiFormikUpload, not UploadInputV3.

The PR title and sibling files migrate UploadInputV2UploadInputV3, but here the replacement is MuiFormikUpload. If intentional (Formik-integrated variant), consider calling this out in the PR description; otherwise align on UploadInputV3 for consistency.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js` at line
21, The import in
src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js currently
brings in MuiFormikUpload but the PR intends to standardize on UploadInputV3;
update the import to use UploadInputV3 (or explicitly document why
Formik-specific MuiFormikUpload is required in the PR description), and then
update any usage of MuiFormikUpload in this file (e.g., where the component is
rendered) to the UploadInputV3 component name so the file aligns with the other
migrated files (or add a clear comment in the file/PR explaining the deliberate
Formik choice if you must keep MuiFormikUpload).

Copy link
Copy Markdown

@santipalenque santipalenque left a comment

Choose a reason for hiding this comment

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

LGTM

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