feat: onFileUploadComplete (#1175)
from #1175 -- Created for Canary (since that action fails on forks)
Summary by CodeRabbit
- New Features
- Enhanced the file upload experience by introducing a configurable callback that triggers custom actions once an upload completes.
- Improved the handling of both individual and multiple file uploads, offering greater flexibility and control over post-upload events.
The latest updates on your projects. Learn more about Vercel for Git βοΈ
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| docs-uploadthing | β Ready (Inspect) | Visit Preview | π¬ Add feedback | Apr 8, 2025 4:49pm |
1 Skipped Deployment
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| legacy-docs-uploadthing | β¬οΈ Ignored (Inspect) | Apr 8, 2025 4:49pm |
Walkthrough
This pull request introduces an onFileUploadComplete callback into the file upload workflow. The changes add the callback property to multiple components and types across the React and upload modules. The UploadButton component, related hooks, and type definitions have been altered to include and pass this callback, while the underlying upload methods in the browser upload module have been adjusted to invoke the callback upon upload completion.
Changes
| Files | Change Summary |
|---|---|
packages/react/src/components/button.tsxpackages/react/src/types.tspackages/react/src/use-uploadthing.ts |
Updated the UploadButton component and related types/hooks by removing outdated type imports and adding new ones from @uploadthing/shared. Introduced the onFileUploadComplete property into the configuration objects and hook parameters to handle upload completion. |
packages/uploadthing/src/_internal/upload-browser.tspackages/uploadthing/src/types.ts |
Modified method signatures for both single and multiple file uploads to include an onFileUploadComplete callback. The upload functions now invoke this callback with the appropriate upload data upon completion. |
Sequence Diagram(s)
sequenceDiagram
actor User
participant UploadButton
participant UploadHook as useUploadThingInternal
participant UploadModule as upload-browser.ts
User->>UploadButton: Initiates file upload
UploadButton->>UploadHook: startUpload(config with onFileUploadComplete)
UploadHook->>UploadModule: uploadFiles(opts with onFileUploadComplete)
UploadModule->>UploadModule: Process file upload
UploadModule->>UploadModule: Invoke onFileUploadComplete callback
UploadModule-->>UploadHook: Return upload result
UploadHook-->>UploadButton: Complete upload flow with callback execution
Possibly related PRs
- pingdotgg/uploadthing#1055: Introduced similar
onFileUploadCompleteadditions, aligning with the updates in callback handling. - pingdotgg/uploadthing#1175: Involved adding the
onFileUploadCompleteproperty in theUploadButtoncomponent and type definitions, directly related to this update.
Suggested labels
release canary, @uploadthing/react
Suggested reviewers
- juliusmarminge
[!WARNING] There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.
π§ ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
Scope: all 3 workspace projects Progress: resolved 0, reused 0, downloaded 1, added 0 Progress: resolved 17, reused 0, downloaded 17, added 0 Progress: resolved 18, reused 0, downloaded 18, added 0 /tmp/eslint/packages/uploadthing: βERR_PNPM_WORKSPACE_PKG_NOT_FOUNDβ In packages/uploadthing: "@uploadthing/mime-types@workspace:*" is in the dependencies but no package named "@uploadthing/mime-types" is present in the workspace
This error happened while installing a direct dependency of /tmp/eslint/packages/uploadthing
Packages found in the workspace:
β¨ Finishing Touches
- [ ] π Generate Docstrings
πͺ§ Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai planto trigger planning for file edits and PR creation.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
More templates
npm i https://pkg.pr.new/pingdotgg/uploadthing/@uploadthing/react@1177
npm i https://pkg.pr.new/pingdotgg/uploadthing@1177
commit: 551afc4
A new canary is available for testing. You can install this latest build in your project with:
pnpm add @uploadthing/[email protected]
pnpm add @uploadthing/[email protected]
pnpm add @uploadthing/[email protected]
pnpm add @uploadthing/[email protected]
pnpm add @uploadthing/[email protected]
pnpm add @uploadthing/[email protected]
pnpm add @uploadthing/[email protected]
pnpm add [email protected]
pnpm add @uploadthing/[email protected]
π¦ Bundle size comparison
| Bundle | Size (gzip) | Visualization |
|---|---|---|
| Main | 30.66KB | See Treemap π |
| PR (b547b29c570ab7187577a92e4c9b3cb460429851) | 30.72KB | See Treemap π |
| Diff | β58.00B |