Skip to content
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

Merged
merged 11 commits into from
Nov 5, 2024

Conversation

yadavshubham01
Copy link
Contributor

@yadavshubham01 yadavshubham01 commented Oct 14, 2024

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

Copy link
Contributor

@greptile-apps greptile-apps bot left a 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 in packages/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 in packages/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

@yadavshubham01
Copy link
Contributor Author

@charlesBochet please review this PR

@charlesBochet
Copy link
Member

This PR does not look functional

@yadavshubham01
Copy link
Contributor Author

there any issue in this PR @charlesBochet

@charlesBochet
Copy link
Member

/award 300

Copy link

oss-gg bot commented Oct 31, 2024

Awarding yadavshubham01: 300 points 🕹️ Well done! Check out your new contribution on oss.gg/yadavshubham01

@lucasbordeau
Copy link
Contributor

Follow-up issue : #8351

@lucasbordeau lucasbordeau merged commit ca91dc2 into twentyhq:main Nov 5, 2024
17 checks passed
Copy link

github-actions bot commented Nov 5, 2024

Thanks @yadavshubham01 for your contribution!
This marks your 4th PR on the repo. You're top 8% of all our contributors 🎉
See contributor page - Share on LinkedIn - Share on Twitter

Contributions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Editing a RICH_TEXT field should update the attachment table when new images are added.
4 participants