-
Notifications
You must be signed in to change notification settings - Fork 94
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(attachments): add support for creating new attachments #6676
base: main
Are you sure you want to change the base?
Conversation
- Introduced a new endpoint (`Attachment#createAttachment`) to create attachment files via POST requests. - Added `createAttachment` method in `AttachmentService` to handle file creation logic with permission checks. - Updated `MediaHandler.vue` and `MediaHandler.provider.js` to integrate the new attachment creation functionality in the editor. - Enhanced `ActionAttachmentUpload.vue` to support dynamic attachment creation from predefined templates. - Included a new "Plus" icon for attachment creation actions in `icons.js`. - Extended `SessionApi.js` with a `createAttachment` method to interface with the new API endpoint. - Minor refactor and UI enhancements to support seamless attachment creation in the text editor. These changes enable users to create and insert new attachment files directly from the editor, improving workflow efficiency. Signed-off-by: Peter Birrer <[email protected]>
Dear @pbirrer At first sight this looks like a good addition to me. I wonder if it becomes very verbose if one has a lot of possible file types that can be created. @marcoambrosini What do you think from a design perspective? |
I agree that this is a great addition too, should we have too many "New" menu items, we can add a "Create new" submenu in the future. |
Yeah, a 'Create New' submenu could also work pretty well here. The number of file types you can create depends on what’s registered in the files app—it adjusts based on the apps being used in your Nextcloud instance. |
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
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.
Code looks good. Have not tested it though and there's no tests included. So I'll take another look and give it a try then.
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 tested it locally and noticed that creating the new files is inconsistent with how attachments are inserted thus far.
I'll attach a screencast to illustrate what i mean by that.
If I upload a .md
file from my computer it will show as a tiny preview with the filename and size. Same if I insert it from the files already on the Nextcloud.
However if i use the new Create new text file
functionality the file will be embedded.
The markdown syntax matches this difference (first file was uploaded, second was created):
![New text file.md](.attachments.2371/New%20text%20file.md)
[http://nextcloud.local/index.php/f/2393](http://nextcloud.local/index.php/f/2393 (preview))
I understand you actually want the embedding, not just an attachment. From my point of view these are two different steps:
- Enable the creation of new files as attachments (this PR)
- Make attachments behave (more) like previews.
Please change the behavior to match the one of other attachments for now so we can get this in. I'll add a (failing) cypress test case in the attachments test suite that should pass once the created text files behave the same as the uploaded ones.
Here's a screencast illustrating what I am referring to. |
Signed-off-by: Max <[email protected]>
Hi @max-nextcloud, you mean you want the link to use the syntax with the global file id, instead of the relative path? Or do you mean that the file shouldn't be previewed initially (which would not make much sense, when inserting new files...)? |
I understand that the inconsistency between the attachment options is unfortunate. However, as it stands, there’s no way to interact with the default view created by “Upload from computer” or “Insert from file” beyond directly downloading the file or deleting the entry. But I’m assuming this isn’t the intended behavior, correct? |
Thanks @rvjr and @pbirrer for getting back so swiftly! Let me try and answer you both at once...
Yes... both was my thinking - but I see how an empty attachment that cannot even be accessed makes little sense.
Well - it's not what we want in the long run - but it's the current behavior of attachments. I'd like to see a way to convert between the three:
But I think this is out of scope for this PR. I'd be fine with what @pbirrer currently developed if we make sure...
I'll add these as todo items to the PR description. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6676 +/- ##
=======================================
Coverage ? 46.86%
=======================================
Files ? 730
Lines ? 34112
Branches ? 1223
=======================================
Hits ? 15986
Misses ? 17522
Partials ? 604 ☔ View full report in Codecov by Sentry. |
These changes enable users to create and insert new attachment files directly from within the editor.
📝 Summary
Attachment#createAttachment
) to create attachment files via POST requests.createAttachment
method inAttachmentService
to handle file creation logic with permission checks.MediaHandler.vue
andMediaHandler.provider.js
to integrate the new attachment creation functionality in the editor.ActionAttachmentUpload.vue
to support dynamic attachment creation from file app templates.SessionApi.js
with acreateAttachment
method to interface with the new API endpoint.🖼️ Screenshots
☑️ Todo
🏁 Checklist
npm run lint
/npm run stylelint
/composer run cs:check
)