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

Share an email thread to workspace members chip and dropdown (#4199) #5640

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

pereira0x
Copy link
Contributor

Feature: Email thread members visibility

For this feature we implemented a chip and a dropdown menu that allows users to check which workspace members can see an email thread, as depicted on issue (#4199).

Implementations

  • create a new database table (messageThreadMember)
  • relations between messageThreadMembers and the relevant existing tables (MessageThread and WorkspaceMembers)
  • added a new column to the MessageThread table: everyone - to indicate that all workspace members can see the email thread
  • create a new repository for the new table, including new queries
  • edit the queries so that the new fields could be fetched from the frontend
  • created a component MultiChip, that shows a group of user avatars, instead of just one
  • created a component, ShareDropdownMenu, that shows up once the EmailThreadMembersChip is clicked. On this menu you can see which workspace members can view the email thread.

Screenshots

Here are some screenshots of the frontend components that were created:

Chip with everyone in the workspace being part of the message thread:
image

Chip with just one member of the workspace (the owner) being part of the message thread:
image

Chip with some members of the workspace being part of the message thread:
image

How the chip looks in a message thread:
image

Dropdown that opens when you click on the chip:
image

Testing and Mock data

We also added mock data (TypeORM seeds), focusing on adding mock data related to message thread members.

Conclusion

As some of the changes that we needed to do, regarding the change of visibility of the message thread, were not covered by the existing documentation, we were told to open a PR and ask for feedback on this part of the implementation. Right now, our implementation is focused on displaying who is part of an email thread.

Feel free to let us know which steps we should follow next :)

Copy link

@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

  • Introduced EmailThreadMembersChip component to display email thread visibility.
  • Added new fields to fetchAllThreadMessagesOperationSignatureFactory.ts for message thread members.
  • Updated RightDrawerEmailThread.tsx to manage message thread state with Recoil.
  • Created new types MessageThread and MessageThreadMember.
  • Added MessageThreadMembersBar component to show email thread members in the right drawer.

messageThread: MessageThread | null;
}) => {
const renderChip = () => {
if (!messageThread) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming isEveryone to isVisibleToEveryone for better clarity.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't feel the need for this change, as we wanted the variable to be consistent with the database table.

const renderChip = () => {
if (!messageThread) {
return null;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid using optional chaining (?.) when the variable is already checked for null.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct, we will be fixing this in our next commit.

switch (isEveryone) {
case false:
if (numberOfMessageThreadMembers === 1) {
return (
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The label prop for SharedDropdownMenu is missing when numberOfMessageThreadMembers is not 1. Consider adding a default label.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Label already has a default value (empty string).

@@ -10,6 +11,7 @@ import { useRightDrawerEmailThread } from '@/activities/emails/right-drawer/hook
import { emailThreadIdWhenEmailThreadWasClosedState } from '@/activities/emails/states/lastViewableEmailThreadIdState';
import { EmailThreadMessage as EmailThreadMessageType } from '@/activities/emails/types/EmailThreadMessage';
import { RIGHT_DRAWER_CLICK_OUTSIDE_LISTENER_ID } from '@/ui/layout/right-drawer/constants/RightDrawerClickOutsideListener';
import { messageThreadState } from '@/ui/layout/right-drawer/states/messageThreadState';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move the declaration of setMessageThread above the useEffect hook for better readability.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will apply this change as well.


export type MessageThread = {
id: string;
everyone: boolean;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming everyone to something more descriptive like isVisibleToAll for better clarity.

Copy link
Contributor

@simaosanguinho simaosanguinho Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We think everyone is fine for this case.

avatarUrl={getImageAbsoluteURIOrBase64(
messageThreadMembersAvatarUrls?.[0],
)}
entityId={messageThreadMembers?.[0].workspaceMember.id}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider extracting the avatar rendering logic into a separate function to improve readability.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't think that this is necessary for this case.

@@ -0,0 +1,103 @@
import { EntityManager } from 'typeorm';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding a comment explaining the purpose of this seed script for future maintainers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not an existing practice in the codebase. We don't think this is relevant here.

'updatedAt',
'deletedAt',
'messageThreadId',
'workspaceMemberId',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add error handling for the database insertion to manage potential failures gracefully.

Copy link
Contributor Author

@pereira0x pereira0x Jun 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We followed the same approach as with the other files, so we don't believe this is necessary.

])
.orIgnore()
.values([
{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field 'workspaceUserId' should be 'workspaceMemberId' to match the table schema.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above. We will be fixing this..

avatarUrls = [],
LeftIcon,
RightIcon,
className,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider renaming nAvatars to additionalAvatarsCount for better clarity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can change this variable name, but we think that a better name would be numberOfAvatars.

@Bonapara
Copy link
Member

Thanks so much @pereira0x! From a design perspective, there is an unwanted top bar on the following component:

Dropdown that opens when you click on the chip: image

@simaosanguinho
Copy link
Contributor

Hey @Bonapara. Me and @pereira0x will take care of removing the unwanted top bar from the Dropdown component. Additionally, we'll review the bot suggestions and apply them to our patch.

@simaosanguinho
Copy link
Contributor

Good afternoon everyone! Just pushed some changes, please tell us if we missed something.

@simaosanguinho
Copy link
Contributor

Hi everyone. Regarding shared emails visibility change, me and @pereira0x were told on Discord that we could not leverage useFindManyRecords to change the visibility on shared email threads, given that nested query filters are not supported yet. Any ideas how we can move forward now @charlesBochet?

@FelixMalfait
Copy link
Member

Hey thanks for this and apologies for the slow review! We'll review and try to get it merged this week.
Do you think you can handle the merge conflicts? I know it's a pain sorry

@simaosanguinho
Copy link
Contributor

No worries!! The merge conflicts will be solved by the end of tomorrow.

pereira0x and others added 19 commits June 29, 2024 12:32
Co-authored-by: José Pereira <[email protected]>
Co-authored-by: Simão Sanguinho <[email protected]>
Co-authored-by: Simão Sanguinho <[email protected]>
@pereira0x
Copy link
Contributor Author

pereira0x commented Jun 29, 2024

Hey, just letting you guys know that the new conflicts are now fixed!

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.

None yet

5 participants