fix: add inventory item image preview#819
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdded three i18n keys and a reusable exported InventoryImagePreviewCell component (uses MUI Popover for a 220×220 preview with load-failure fallback and click-to-open). Replaced inline image rendering in the inventory list, updated useEffect deps, and added tests for preview behavior and accessibility. Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant InventoryPage as InventoryPage
participant Popover as Popover (Preview)
participant Browser as Browser
User->>InventoryPage: hover or focus preview button
InventoryPage->>Popover: open with imageUrl, set size 220x220
Popover->>User: render image or fallback text (onError)
User->>InventoryPage: click preview/button
InventoryPage->>Browser: window.open(imageUrl, "_blank", "noopener,noreferrer")
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/inventory/inventory-list-page.js`:
- Around line 171-213: The render function currently dereferences row.images
without guarding for null/undefined; update the render lambda (the render: (row)
=> ...) to first check that row.images is an array (e.g. row.images &&
row.images.length > 0) before accessing row.images[0] and
row.images[0].file_url, and use optional chaining where helpful
(row.images?.[0]?.file_url) for both the Tooltip src/alt and the IconButton
onClick so the UI won't throw when the relationship is missing.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5d96d6c6-8f89-4ba5-927b-78ce911f2f19
📒 Files selected for processing (2)
src/i18n/en.jsonsrc/pages/sponsors-global/inventory/inventory-list-page.js
26a11d4 to
dbe5ae4
Compare
martinquiroga-exo
left a comment
There was a problem hiding this comment.
@priscila-moneo please see comments.
| if (!hasImages || !imageUrl) return null; | ||
|
|
||
| return ( | ||
| <Tooltip |
There was a problem hiding this comment.
For this use case we should use Popover instead of Tooltip
| overflow: "hidden" | ||
| }} | ||
| > | ||
| <Box |
There was a problem hiding this comment.
This will cause the browser to eagerly load the images. We want preview images to be lazy loaded, conditionally mount them using Popover
| > | ||
| <Box | ||
| component="img" | ||
| src={imageUrl} |
There was a problem hiding this comment.
There is no fallback we could be rendering a broken preview if the image load fails for instance. Currently the code prevents rendering when the URL is missing but not if the link is broken or there is a network issue, etc.
dbe5ae4 to
e3a0014
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/inventory/inventory-list-page.js`:
- Around line 177-179: The useEffect is causing duplicate dispatches because
handlers (onPageChange/onSort/onSearch/onFilter) already call getInventoryItems
and the effect also re-dispatches when mapped props change; remove the duplicate
by changing the useEffect to run only once on mount (useEffect(..., [])) and
call getInventoryItems with the current mapped page prop instead of the
hard-coded 1 (use getInventoryItems(term, page, perPage, order, orderDir,
hideArchived)), or alternatively delete this useEffect entirely and keep the
handler-driven calls—ensure you update the effect (or remove it) so it no longer
depends on getInventoryItems, term, perPage, order, orderDir, hideArchived to
avoid double requests.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0e84f382-ab5a-49e1-a3bd-a2026cf7e17a
📒 Files selected for processing (3)
src/i18n/en.jsonsrc/pages/sponsors-global/inventory/__tests__/inventory-list-page.test.jssrc/pages/sponsors-global/inventory/inventory-list-page.js
🚧 Files skipped from review as they are similar to previous changes (1)
- src/i18n/en.json
e3a0014 to
77bca5a
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
src/pages/sponsors-global/inventory/inventory-list-page.js (1)
177-185:⚠️ Potential issue | 🟡 MinorPreserve the stored page on mount.
Line 180 still hard-resets the first fetch to page 1. If this screen is remounted after paging through the list, the Redux-backed list state is discarded and users get bounced back to the first page.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/pages/sponsors-global/inventory/inventory-list-page.js` around lines 177 - 185, The useEffect currently forces the first fetch to DEFAULT_CURRENT_PAGE which resets Redux-backed paging on remount; change the call to getInventoryItems(...) to use the stored page value (e.g., currentPage / inventory.currentPage from props or selector) instead of DEFAULT_CURRENT_PAGE, falling back to DEFAULT_CURRENT_PAGE only if that stored page is undefined/null; update the useEffect dependencies if needed so it reads the stored page value on mount and does not always reset to 1.
🤖 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/inventory/inventory-list-page.js`:
- Around line 57-79: The accessible label (previewAlt) used on the IconButton is
generic and doesn't communicate the click action that opens the asset in a new
tab; update the component to accept the item name (e.g., itemName prop) and
build an action-oriented aria-label (replace previewAlt on the IconButton) that
includes the item name and mentions the new-tab behavior (for example: "Open
image preview for {itemName} in a new tab"), while keeping the existing
hover/focus handlers (openPreview, closePreview) and the onClick
window.open(imageUrl, "_blank", "noopener,noreferrer") behavior unchanged.
---
Duplicate comments:
In `@src/pages/sponsors-global/inventory/inventory-list-page.js`:
- Around line 177-185: The useEffect currently forces the first fetch to
DEFAULT_CURRENT_PAGE which resets Redux-backed paging on remount; change the
call to getInventoryItems(...) to use the stored page value (e.g., currentPage /
inventory.currentPage from props or selector) instead of DEFAULT_CURRENT_PAGE,
falling back to DEFAULT_CURRENT_PAGE only if that stored page is undefined/null;
update the useEffect dependencies if needed so it reads the stored page value on
mount and does not always reset to 1.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 34b1fa9c-e171-46f6-9313-77fd4548810a
📒 Files selected for processing (3)
src/i18n/en.jsonsrc/pages/sponsors-global/inventory/__tests__/inventory-list-page.test.jssrc/pages/sponsors-global/inventory/inventory-list-page.js
🚧 Files skipped from review as they are similar to previous changes (1)
- src/pages/sponsors-global/inventory/tests/inventory-list-page.test.js
77bca5a to
fd56ed7
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/inventory/inventory-list-page.js`:
- Around line 59-63: The previewAlt variable and the IconButton label are
reusing the action-oriented translation key, causing the <img> to have an
imperative alt; instead, use two separate translation keys and values: keep
"inventory_item_list.image_preview_action_alt" (with itemName) for the
IconButton's aria-label/label and switch the <img>'s alt to a descriptive key
like "inventory_item_list.image_preview_alt" (also accept itemName if needed for
context); update the code references around previewAlt, the IconButton props,
and the <img> alt so the button announces the action and the image has a
descriptive alt.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 064c253d-ed5e-4d98-898e-a3a53fdb0a01
📒 Files selected for processing (3)
src/i18n/en.jsonsrc/pages/sponsors-global/inventory/__tests__/inventory-list-page.test.jssrc/pages/sponsors-global/inventory/inventory-list-page.js
🚧 Files skipped from review as they are similar to previous changes (2)
- src/pages/sponsors-global/inventory/tests/inventory-list-page.test.js
- src/i18n/en.json
fd56ed7 to
2910cef
Compare
2910cef to
b1112c3
Compare
ref: https://app.clickup.com/t/86b883qz9
Summary by CodeRabbit
New Features
Improvements
Tests