-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Implemented user media manager #262
Conversation
- Added responsive media manager - Added /fof/uploads endpoint - Updated /fof/upload endpoint output - Updated FileSerializer - Added File frontend model
This really is great work @jaspervriends thank you for your time in creating this feature! Might take a couple of days to go over this, please bear with us :) |
This looks very nice! I probably also won't be able to review immediately, but I will try to get to it! How are the image preview managed? Is it the full image? If so, does it load all of the images immediately or only as you scroll down? If a forum allows very large uploads, or someone just has many images, will it not bring the website down by loading all of them? |
Awesome, take your time :)
The files are loaded in batches as usual (20 files each), so it will depend on the overal image size. Currently the images are just using the path of the image. As there are no thumbnails generated by this extention :( So if someone has any suggestions, let me know. Maybe generate it on-the-fly on a specific endpoint? |
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 not in FoF, so I won't make this a proper review, but I just had a few suggestions to point out to do with styling.
padding: 0px; | ||
margin: 0 -7px; | ||
|
||
display: flex; |
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.
Could display: grid
be easier for this? Has good support across browsers (even IE, if you're mad you provide the older spec properties too).
display: grid;
grid-template-columns: repeat(3, minmax(10px, 1fr));
...would generate a grid with 3 columns. I think it's clearer than the calc
s being used at the moment. Plus you can then use gap
to create the spacing between the items (supported in FF61+, Chrome 66+, Safari 12+, or even earlier if you also provide grid-gap
).
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 considered the display: grid
too, but I wasn't sure if it was used in Flarum anywhere else, so I went for the safe flexbox
variant instead. I could change it if needed.
Comma splicing Co-authored-by: David Wheatley <[email protected]>
Comma splicing Co-authored-by: David Wheatley <[email protected]>
I'd love to hear other peoples' opinion about the following. Jasper and I had a discussion about the upload button, previous commits had it replaced by the media manager. Right now there's (yet) another button. Screen space is scarce, especially in the editor. My suggestion is to allow an admin setting to choose between (upload button, media manager button or both). And then render accordingly. The media manager adds another click to upload. |
I'm a fan of that. Maybe it's time to also replace the "Upload" text with a tooltip to match the other buttons in the editor toolbar? |
@luceos I think an admin setting would be fine. What would be the default setting then? Both buttons visible? And optionally hide one of the buttons?
Yup, I already gave the upload button a tooltip :) |
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've been checking out this PR for a couple of days locally, and I must say it works very, very well.
There's a couple of features that I personally feel this needs, and I'd really appreciate the thoughts of others here:
- Ability to remove an upload from the media manager
- Ability to access the media manager from the user profile
- Ability for moderators to access the media of others, with the possibility to remove inappropriate content
I'm quite undecided on if the above should delay merging, or could be follow up changes
@@ -193,6 +201,17 @@ export default class UploadPage extends ExtensionPage { | |||
m('.helpText', app.translator.trans('fof-upload.admin.help_texts.download_templates')), | |||
this.templateOptionsDescriptions(), | |||
]), | |||
m('fieldset', [ |
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.
Non-blocking, but we should probably change this stuff to JSX for better readability in another PR.
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.
Agreed, but as you say, this should be a separate PR to this feature
Not sure on others' opinions, but it might be worth considering Up to you at the end of the day -- both work fine! |
@imorland I've updated the PR again and added an uploads overview to the user profile page (I agree it is a good addition too). Also, I added a Also, I already added the When a user sees their own profile, the button label is When you click a file in the user profile page, it will open the file URL. |
Superb @jaspervriends - I'll take a closer look after work tonight! In regards to deletion, I agree it's a tricky subject. My feeling is that instead of actually deleting the file from disk/bucket/whatever, which in turn could likely impact posts that have it embedded, we should instead 'delete from media manager'. Perhaps this could be done by adding a column to the |
Any thoughts on the above @jaspervriends ? Ideally I'd like to get this merged before we start working on the beta 16 updates for this extension |
I'll merge this now, @davwheat and I will add the 'delete from media manager' feature as described #262 (comment) |
I've implemented a user media upload manager with the idea of stopping multi-uploads from the same file. The files were already attached to the user, so I did not change anything of that.
Changelog:
/fof/uploads
endpoint/fof/upload
endpoint outputFileSerializer
File
frontend modelModal features:
The media manager is expandable minded. Other extensions could open the
FileManagerModal
modal component and attach custom params to customize their needs.The file manager is responsive, has drag & drop support and automatically selects the uploaded files. After clicking the 'Select files' button, the files will be added with their
bbcode
to the composer.onSelect
: Optional, custom callback, default:adds bbcode to composer
multiSelect
: Optional, allow multiple selections, defaulttrue
restrictFileType
: Optional, restrict file selection to specific types, defaultnull
, supported values:[array]
image
audio
video
This PR
Let's focus on the code and improvements/removals:
fof-upload-dropping
andthis.isDropping
.Updated composer buttons
Automatically select uploaded files
Example: Restricted to file type
image
Night mode
Mobile view