-
Notifications
You must be signed in to change notification settings - Fork 414
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
Allow only images in modal image uploader. #7672
Merged
jessopb
merged 8 commits into
master
from
7646-in-the-cover-upload-modal-trying-to-upload-anything-other-than-an-image-doesnt-reset-the-form
Sep 2, 2022
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f6a9419
Allow only images in modal image uploader.
Ruk33 3bc2373
Set file path and mime in file selector.
Ruk33 fa5c1a1
Refactor WebFile.
Ruk33 25a71be
Update get-file-from-path to work with folders; fix file-list component.
Ruk33 d65d36f
Get rid of File | string for filePath property in components.
Ruk33 1259b54
Show instant preview while updating channel thumbnail.
Ruk33 0dcfe8f
Fix publish.
Ruk33 3eb99f8
Add jpeg and svg to image filter.
Ruk33 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,13 @@ type Props = { | |
|
||
function ModalImageUpload(props: Props) { | ||
const { closeModal, currentValue, title, assetName, helpText, onUpdate } = props; | ||
const filters = React.useMemo(() => [{ name: 'Images', extensions: ['jpg', 'png', 'gif'] }]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this blocks |
||
|
||
return ( | ||
<Modal isOpen type="card" onAborted={closeModal} contentLabel={title}> | ||
<SelectAsset | ||
filters={filters} | ||
type="openFile" | ||
onUpdate={onUpdate} | ||
currentValue={currentValue} | ||
assetName={assetName} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm concerned that changing this from { path } to file will break publishing. Did you try?
lbry-desktop/ui/component/publishFile/view.jsx
Line 273 in b9be8d9
It may be good to send { file: file , path: path } and adjust all the functions assigned to onFileChosen to take that.
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.
Sounds good @jessopb, nice catch. Perhaps as a small note for the future, we should avoid using these union types. Notice how I'm still respecting the interface (by sending a
File
type) but still, it manages to break parts of the app...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.
You're probably right. The union types were originally added when the codebase was supporting both web and app.
Maybe the type should be ChosenFile = { file: WebFile, path: string }
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.
@jessopb I have updated the code so the
File
now contains apath
and amime
type. With this, the file upload for posts works fine. Please let me know what you think. Thanks.