Skip to content

feat: replace UploadInputV2 with UploadInputV3#891

Merged
smarcet merged 1 commit into
masterfrom
feature/replace-v2-upload-for-v3-upload
May 8, 2026
Merged

feat: replace UploadInputV2 with UploadInputV3#891
smarcet merged 1 commit into
masterfrom
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

  • Refactor

    • Migrated upload controls to a unified newer upload component across forms, dialogs, and sponsor flows for more consistent upload behavior.
    • Simplified comment form lifecycle and streamlined state handling.
  • Tests

    • Adjusted tests to reflect the updated upload component integration and dialog behavior.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2a51fbcf-f652-449f-bccc-4a64ea5fffe1

📥 Commits

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

📒 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

📝 Walkthrough

Walkthrough

This PR migrates upload consumers from UploadInputV2 to UploadInputV3, deletes the local MuiFormikUpload adapter, updates imports and sponsor upload wiring to use the library-provided MuiFormikUpload, simplifies an event-comment component's lifecycle/state handling, and updates a test to match the new upload integration.

Changes

Upload/UploadAdapter migration

Layer / File(s) Summary
Imports and public component source changes
src/components/forms/event-comment-form.js, src/components/forms/event-material-form.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
Update imports: only import Input in event-comment; switch UploadInputV2UploadInputV3; import MuiFormikUpload from shared library instead of local module.
Core deletion
src/components/mui/formik-inputs/mui-formik-upload.js
Remove local MuiFormikUpload implementation and its PropTypes/export.
Wiring / Integration
src/components/forms/event-material-form.js, src/components/upload-dialog/index.js, src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js
Replace rendered upload components: event material and upload-dialog now use UploadInputV3; sponsor inventory uses MuiFormikUpload bound to Formik and drops custom upload handlers and explicit upload props.
Event Form Tweaks
src/components/forms/event-comment-form.js
Change componentDidUpdate signature to single prevProps, refactor handleChange to use shorthand { entity, errors }, and remove error prop from the body field render.
Tests
src/pages/sponsors-global/page-templates/page-template-popup/page-template-module-form.test.js
Remove Jest mock for local upload component and relax confirmation dialog assertion by dropping expected title field.

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly Related PRs

Suggested Reviewers

  • martinquiroga-exo
  • smarcet
  • tomrndom

Poem

🐰 I hopped through imports, neat and spry,
V2 stepped back as V3 hopped by,
Local adapter trimmed to none,
Forms bind cleanly—work is done,
A carrot-coded cheer from this rabbit guy.

🚥 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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 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

@coderabbitai coderabbitai Bot Apr 23, 2026

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

Choose a reason for hiding this comment

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

@priscila-moneo this point the same question that i did please change it to v3

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

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

@priscila-moneo priscila-moneo force-pushed the feature/replace-v2-upload-for-v3-upload branch from 7c52cd0 to 244bdbf Compare April 28, 2026 23:38
Comment thread src/pages/sponsors-global/form-templates/sponsor-inventory-popup.js
Copy link
Copy Markdown

@smarcet smarcet left a comment

Choose a reason for hiding this comment

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

@priscila-moneo please review comments and please fix the merge conflicts

@priscila-moneo priscila-moneo force-pushed the feature/replace-v2-upload-for-v3-upload branch from 244bdbf to a820f85 Compare May 8, 2026 21:15
@priscila-moneo priscila-moneo requested a review from smarcet May 8, 2026 21:15
Copy link
Copy Markdown

@smarcet smarcet left a comment

Choose a reason for hiding this comment

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

LGTM

@smarcet smarcet merged commit bda55af into master May 8, 2026
8 of 9 checks passed
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.

3 participants