-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add useUploadAttachment hook (#7617) #7690
Add useUploadAttachment hook (#7617) #7690
Conversation
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.
PR Summary
This pull request introduces a new useUploadAttachment
hook and integrates it into the RichTextEditor
component to handle image uploads and update the attachment table. Here's a summary of the key changes:
- Added
useUploadAttachment
hook inpackages/twenty-front/src/modules/activities/files/hooks/useUploadAttachment.tsx
for file uploads and attachment creation - Modified
RichTextEditor
component to use the new hook for image uploads - Updated GraphQL operations in
packages/twenty-front/src/modules/attachments/graphql/queries/uploadFile.ts
to support file uploads and attachment creation - Added
AddAttachment
mutation inpackages/twenty-front/src/generated/graphql.tsx
for inserting attachment details
Key points to note:
- The
useUploadAttachment
hook combines file upload and attachment creation in a single operation RichTextEditor
now uses the new hook instead of separate upload and attachment mutations- The implementation in
RichTextEditor
needs refinement, as there are some inconsistencies with the new hook usage - Error handling in the new hook could be improved for better robustness
4 file(s) reviewed, 6 comment(s)
Edit PR Review Bot Settings | Greptile
packages/twenty-front/src/modules/activities/components/RichTextEditor.tsx
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/activities/components/RichTextEditor.tsx
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/activities/files/hooks/useUploadAttachment.tsx
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/activities/files/hooks/useUploadAttachment.tsx
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/activities/files/hooks/useUploadAttachment.tsx
Outdated
Show resolved
Hide resolved
@charlesBochet please review this PR |
packages/twenty-front/src/modules/activities/files/hooks/useUploadAttachment.tsx
Outdated
Show resolved
Hide resolved
This PR does not look functional |
there any issue in this PR @charlesBochet |
/award 300 |
Awarding yadavshubham01: 300 points 🕹️ Well done! Check out your new contribution on oss.gg/yadavshubham01 |
Follow-up issue : #8351 |
Thanks @yadavshubham01 for your contribution! |
Reusing the useUploadAttachment Hook
In the implementation of the feature to ensure the attachment table is updated whenever new images are added to a RICH_TEXT field #7617 , it is likely that the useUploadAttachment hook is reused.
The useUploadAttachment hook is responsible for handling the upload of attachments, including images, and returning the uploaded file URL. By reusing this hook, you can leverage its existing functionality to handle image uploads within the RICH_TEXT field.
In this case, the modified image handling logic would utilize the useUploadAttachment hook to upload new images added to the RICH_TEXT content. The hook would then return the uploaded file URL, which would be used to update the attachment table with the details of the newly added images.
By reusing the useUploadAttachment hook, you can avoid duplicating code and ensure consistency in the way attachments are handled throughout the application.
Fixes #6565