- Notifications
You must be signed in to change notification settings - Fork 3.2k
feat: admin upload controls #11615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: admin upload controls #11615
Conversation
| This makes me very happy. I'll no longer need a custom upload component for my image search plugin, thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kendelljoseph Can we update the styling of the Select a file & Paste url buttons or / it's parent wrappers so that the buttons do not stretch (like shown in your image above) if the parent height changes due to the custom components?
| @PatrikKozak yep, will do! |
7b98279 to 3c1ca0f Compare fec1bf6 to 99e2cf3 Compare 2d2d4e8 to 1c8e823 Compare | updateUploadEdits={updateUploadEdits} | ||
| uploadEdits={uploadEdits} | ||
| /> | ||
| <UploadControlsProvider> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this provider should wrap these lines https://github.com/payloadcms/payload/pull/11615/files#diff-1bff65262fbaf801a00a575c6b3ced6b40325c0e5cadcdfdc88c8590a256bdbdR592-R598
and can be removed from this file. This way if they define a CustomUpload it will have access to the context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm -- It's not clear by the link which lines or file you mean. It's not zooming to it correctly or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it!
| useEffect(() => { | ||
| const handleControlFileUrl = async () => { | ||
| if (uploadControlFileUrl) { | ||
| setFileUrl(uploadControlFileUrl) | ||
| await handleUrlSubmit() | ||
| } | ||
| } | ||
| | ||
| void handleControlFileUrl() | ||
| }, [uploadControlFileUrl, handleUrlSubmit]) | ||
| | ||
| useEffect(() => { | ||
| const handleControlFile = () => { | ||
| if (uploadControlFile) { | ||
| handleFileChange(uploadControlFile) | ||
| } | ||
| } | ||
| | ||
| void handleControlFile() | ||
| }, [uploadControlFile, handleFileChange]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need effects here? Or could we just make functions that get called in the onClick handlers below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the uploadControlFileUrl and uploadControlFile can be modified by a custom component that is the useUploadControls(), we want to look for changes here and then run the internal handleFileChange or handleUrlSubmit the same way.
So I think we do need the effect here to watch for changes.
| We need a way to get UploadControls into the BulkUpload view as well. Currently they do not show up. |
| @JarrodMFlesch I think we can add the
The Also Given the amount of adaptations needed I'm proposing grouping that effort into a different PR, |
| 🚀 This is included in version v3.43.0 |
| This worked amazingly in my image search plugin, no longer need to keep track of any changes that happen to the default upload component. Thanks again for your work on this! Looking forward to seeing the equivalent for the bulk upload feature in the near future. |





What?
Adds the ability to add additional components to the file upload component.
Provider
Use the
useUploadControlsprovider to eithersetUploadControlFilepassing a file object, or set the file by url usingsetUploadControlFileUrl.Why?
Add the ability to use a custom component to select a document to upload.