Added cloudinary#222
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
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:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe Firebase deploy workflow now exports Cloudinary build variables. A new admin upload widget loads Cloudinary’s script and returns uploaded image URLs. Portfolio management uses it for cover images, alongside manual URLs and sanitized previews. ChangesCloudinary cover image upload
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
Visit the preview URL for this PR (updated for commit 2976967): https://servio-0--pr222-added-cloudinary-onlgp3it.web.app (expires Sat, 04 Jul 2026 11:25:10 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 15915abb5951eb298a844eda460b24f444d93a69 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/admin/components/CloudinaryUploadWidget.tsx (1)
11-12: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDefine the Cloudinary widget types once in
src/vite-env.d.ts.window.cloudinaryis undeclared, which forcesuseRef<any>,@ts-ignore, and theanycallback types insrc/admin/components/CloudinaryUploadWidget.tsx. Add a localWindow.cloudinary/widget type and reuse it here to remove the suppressions.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/admin/components/CloudinaryUploadWidget.tsx` around lines 11 - 12, The Cloudinary widget usage in CloudinaryUploadWidget is relying on undeclared globals and any-typed refs, so define the shared Cloudinary/window widget types once in src/vite-env.d.ts and then reuse those types here. Update the CloudinaryUploadWidget component to type cloudinaryRef, widgetRef, and the widget callback payloads with the new Window.cloudinary/widget types, and remove the `@ts-ignore` and any suppressions.Sources: Linters/SAST tools, Pipeline failures
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/admin/components/CloudinaryUploadWidget.tsx`:
- Around line 19-29: The widget readiness flag is being set too early in
CloudinaryUploadWidget’s onScriptLoad, before the env check and before
createUploadWidget returns a real instance. Move setIsLoaded(true) so it only
runs after widgetRef.current has been assigned successfully, and keep it false
on any early return or initialization failure; also make sure the button state
in the render logic only depends on widgetRef.current being present, so the
click handler never becomes a no-op when the widget was not created.
---
Nitpick comments:
In `@src/admin/components/CloudinaryUploadWidget.tsx`:
- Around line 11-12: The Cloudinary widget usage in CloudinaryUploadWidget is
relying on undeclared globals and any-typed refs, so define the shared
Cloudinary/window widget types once in src/vite-env.d.ts and then reuse those
types here. Update the CloudinaryUploadWidget component to type cloudinaryRef,
widgetRef, and the widget callback payloads with the new
Window.cloudinary/widget types, and remove the `@ts-ignore` and any suppressions.
🪄 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 Plus
Run ID: 611a5743-adba-4505-a4ba-e5bf27bd4a8f
📒 Files selected for processing (3)
.github/workflows/firebase-deploy.ymlsrc/admin/components/CloudinaryUploadWidget.tsxsrc/admin/pages/PortfolioManagement.tsx
| const onScriptLoad = () => { | ||
| setIsLoaded(true); | ||
| // @ts-ignore | ||
| cloudinaryRef.current = window.cloudinary; | ||
|
|
||
| const cloudName = import.meta.env.VITE_CLOUDINARY_CLOUD_NAME; | ||
| const uploadPreset = import.meta.env.VITE_CLOUDINARY_UPLOAD_PRESET; | ||
|
|
||
| if (!cloudName || !uploadPreset) { | ||
| console.error("Cloudinary environment variables are missing."); | ||
| return; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Only enable the button after the widget is created.
Line 20 marks the widget as ready before the env check and before createUploadWidget(...) returns. If initialization fails, Line 72 becomes a clickable no-op because widgetRef.current was never set. Keep isLoaded false until the widget instance exists.
Minimal fix
const onScriptLoad = () => {
- setIsLoaded(true);
// `@ts-ignore`
cloudinaryRef.current = window.cloudinary;
@@
widgetRef.current = cloudinaryRef.current.createUploadWidget(
{
@@
}
);
+ setIsLoaded(true);
};Also applies to: 32-45, 71-72
🧰 Tools
🪛 ESLint
[error] 21-21: Use "@ts-expect-error" instead of "@ts-ignore", as "@ts-ignore" will do nothing if the following line is error-free.
(@typescript-eslint/ban-ts-comment)
🪛 GitHub Check: Type check, lint & build
[failure] 21-21:
Use "@ts-expect-error" instead of "@ts-ignore", as "@ts-ignore" will do nothing if the following line is error-free
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/admin/components/CloudinaryUploadWidget.tsx` around lines 19 - 29, The
widget readiness flag is being set too early in CloudinaryUploadWidget’s
onScriptLoad, before the env check and before createUploadWidget returns a real
instance. Move setIsLoaded(true) so it only runs after widgetRef.current has
been assigned successfully, and keep it false on any early return or
initialization failure; also make sure the button state in the render logic only
depends on widgetRef.current being present, so the click handler never becomes a
no-op when the widget was not created.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/admin/pages/PortfolioManagement.tsx`:
- Around line 67-69: The root-relative branch in the URL validation helper
inside PortfolioManagement.tsx currently accepts protocol-relative values
because it only checks startsWith("/"). Update the helper to reject inputs
beginning with "//" while still allowing genuine root-relative paths, and keep
the existing validation flow intact so the DOM-sink guard only returns safe
local URLs.
🪄 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 Plus
Run ID: 5581ce04-042a-4b73-b6fd-8a7f2cbbb137
📒 Files selected for processing (1)
src/admin/pages/PortfolioManagement.tsx
Description
This PR integrates cloudinary in the portfolio project management
Summary by CodeRabbit