5622 add a syncemail onboarding step (#5689)
- add sync email onboarding step - refactor calendar and email visibility enums - add a new table `keyValuePair` in `core` schema - add a new resolved boolean field `skipSyncEmail` in current user https://github.com/twentyhq/twenty/assets/29927851/de791475-5bfe-47f9-8e90-76c349fba56f
This commit is contained in:
@ -14,6 +14,7 @@ import { hasCalendarEventEnded } from '@/activities/calendar/utils/hasCalendarEv
|
||||
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
|
||||
import { Card } from '@/ui/layout/card/components/Card';
|
||||
import { CardContent } from '@/ui/layout/card/components/CardContent';
|
||||
import { CalendarChannelVisibility } from '~/generated/graphql';
|
||||
import { TimelineCalendarEvent } from '~/generated-metadata/graphql';
|
||||
import { getImageAbsoluteURIOrBase64 } from '~/utils/image/getImageAbsoluteURIOrBase64';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
@ -118,7 +119,8 @@ export const CalendarEventRow = ({
|
||||
const isCurrentWorkspaceMemberAttending = calendarEvent.participants?.some(
|
||||
({ workspaceMemberId }) => workspaceMemberId === currentWorkspaceMember?.id,
|
||||
);
|
||||
const showTitle = calendarEvent.visibility === 'SHARE_EVERYTHING';
|
||||
const showTitle =
|
||||
calendarEvent.visibility === CalendarChannelVisibility.ShareEverything;
|
||||
|
||||
return (
|
||||
<StyledContainer
|
||||
|
||||
@ -2,6 +2,7 @@ import { act, renderHook } from '@testing-library/react';
|
||||
|
||||
import { useCalendarEvents } from '@/activities/calendar/hooks/useCalendarEvents';
|
||||
import { CalendarEvent } from '@/activities/calendar/types/CalendarEvent';
|
||||
import { CalendarChannelVisibility } from '~/generated/graphql';
|
||||
|
||||
const calendarEvents: CalendarEvent[] = [
|
||||
{
|
||||
@ -9,7 +10,7 @@ const calendarEvents: CalendarEvent[] = [
|
||||
externalCreatedAt: '2024-02-17T20:45:43.854Z',
|
||||
isFullDay: false,
|
||||
startsAt: '2024-02-17T21:45:27.822Z',
|
||||
visibility: 'METADATA',
|
||||
visibility: CalendarChannelVisibility.Metadata,
|
||||
__typename: 'CalendarEvent',
|
||||
},
|
||||
{
|
||||
@ -17,7 +18,7 @@ const calendarEvents: CalendarEvent[] = [
|
||||
externalCreatedAt: '2024-02-18T19:43:37.854Z',
|
||||
isFullDay: false,
|
||||
startsAt: '2024-02-18T21:43:27.754Z',
|
||||
visibility: 'SHARE_EVERYTHING',
|
||||
visibility: CalendarChannelVisibility.ShareEverything,
|
||||
__typename: 'CalendarEvent',
|
||||
},
|
||||
{
|
||||
@ -25,7 +26,7 @@ const calendarEvents: CalendarEvent[] = [
|
||||
externalCreatedAt: '2024-02-19T20:45:20.854Z',
|
||||
isFullDay: true,
|
||||
startsAt: '2024-02-19T22:05:27.653Z',
|
||||
visibility: 'METADATA',
|
||||
visibility: CalendarChannelVisibility.Metadata,
|
||||
__typename: 'CalendarEvent',
|
||||
},
|
||||
{
|
||||
@ -33,7 +34,7 @@ const calendarEvents: CalendarEvent[] = [
|
||||
externalCreatedAt: '2024-02-20T20:45:12.854Z',
|
||||
isFullDay: true,
|
||||
startsAt: '2024-02-20T23:15:23.150Z',
|
||||
visibility: 'SHARE_EVERYTHING',
|
||||
visibility: CalendarChannelVisibility.ShareEverything,
|
||||
__typename: 'CalendarEvent',
|
||||
},
|
||||
];
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { CalendarEventParticipant } from '@/activities/calendar/types/CalendarEventParticipant';
|
||||
import { CalendarChannelVisibility } from '~/generated/graphql';
|
||||
|
||||
// TODO: use backend CalendarEvent type when ready
|
||||
export type CalendarEvent = {
|
||||
@ -15,7 +16,7 @@ export type CalendarEvent = {
|
||||
location?: string;
|
||||
startsAt: string;
|
||||
title?: string;
|
||||
visibility: 'METADATA' | 'SHARE_EVERYTHING';
|
||||
visibility: CalendarChannelVisibility;
|
||||
calendarEventParticipants?: CalendarEventParticipant[];
|
||||
__typename: 'CalendarEvent';
|
||||
};
|
||||
|
||||
@ -8,18 +8,22 @@ import { useEmailThread } from '@/activities/emails/hooks/useEmailThread';
|
||||
import { emailThreadIdWhenEmailThreadWasClosedState } from '@/activities/emails/states/lastViewableEmailThreadIdState';
|
||||
import { CardContent } from '@/ui/layout/card/components/CardContent';
|
||||
import { useRightDrawer } from '@/ui/layout/right-drawer/hooks/useRightDrawer';
|
||||
import { TimelineThread } from '~/generated/graphql';
|
||||
import { MessageChannelVisibility, TimelineThread } from '~/generated/graphql';
|
||||
import { formatToHumanReadableDate } from '~/utils';
|
||||
import { getImageAbsoluteURIOrBase64 } from '~/utils/image/getImageAbsoluteURIOrBase64';
|
||||
|
||||
const StyledCardContent = styled(CardContent)<{ visibility: string }>`
|
||||
const StyledCardContent = styled(CardContent)<{
|
||||
visibility: MessageChannelVisibility;
|
||||
}>`
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: ${({ theme }) => theme.spacing(2)};
|
||||
height: ${({ theme }) => theme.spacing(12)};
|
||||
padding: ${({ theme }) => theme.spacing(0, 4)};
|
||||
cursor: ${({ visibility }) =>
|
||||
visibility === 'share_everything' ? 'pointer' : 'default'};
|
||||
visibility === MessageChannelVisibility.ShareEverything
|
||||
? 'pointer'
|
||||
: 'default'};
|
||||
`;
|
||||
|
||||
const StyledHeading = styled.div<{ unread: boolean }>`
|
||||
@ -78,8 +82,6 @@ const StyledReceivedAt = styled.div`
|
||||
padding: ${({ theme }) => theme.spacing(0, 1)};
|
||||
`;
|
||||
|
||||
export type EmailThreadVisibility = 'metadata' | 'subject' | 'share_everything';
|
||||
|
||||
type EmailThreadPreviewProps = {
|
||||
divider?: boolean;
|
||||
thread: TimelineThread;
|
||||
@ -93,7 +95,7 @@ export const EmailThreadPreview = ({
|
||||
|
||||
const { openEmailThread } = useEmailThread();
|
||||
|
||||
const visibility = thread.visibility as EmailThreadVisibility;
|
||||
const visibility = thread.visibility;
|
||||
|
||||
const senderNames =
|
||||
thread.firstParticipant.displayName +
|
||||
@ -126,7 +128,7 @@ export const EmailThreadPreview = ({
|
||||
.getValue();
|
||||
|
||||
const canOpen =
|
||||
thread.visibility === 'share_everything' &&
|
||||
thread.visibility === MessageChannelVisibility.ShareEverything &&
|
||||
(!clickJustTriggeredEmailDrawerClose ||
|
||||
emailThreadIdWhenEmailThreadWasClosed !== thread.id);
|
||||
|
||||
@ -183,13 +185,15 @@ export const EmailThreadPreview = ({
|
||||
</StyledHeading>
|
||||
|
||||
<StyledSubjectAndBody>
|
||||
{visibility !== 'metadata' && (
|
||||
{visibility !== MessageChannelVisibility.Metadata && (
|
||||
<StyledSubject>{thread.subject}</StyledSubject>
|
||||
)}
|
||||
{visibility === 'share_everything' && (
|
||||
{visibility === MessageChannelVisibility.ShareEverything && (
|
||||
<StyledBody>{thread.lastMessageBody}</StyledBody>
|
||||
)}
|
||||
{visibility !== 'share_everything' && <EmailThreadNotShared />}
|
||||
{visibility !== MessageChannelVisibility.ShareEverything && (
|
||||
<EmailThreadNotShared />
|
||||
)}
|
||||
</StyledSubjectAndBody>
|
||||
<StyledReceivedAt>
|
||||
{formatToHumanReadableDate(thread.lastMessageReceivedAt)}
|
||||
|
||||
Reference in New Issue
Block a user