-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
245 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 31 additions & 3 deletions
34
packages/twenty-front/src/modules/accounts/types/CalendarChannel.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,39 @@ | ||
import { CalendarChannelVisibility } from '~/generated/graphql'; | ||
|
||
export enum CalendarChannelSyncStatus { | ||
NOT_SYNCED = 'NOT_SYNCED', | ||
ONGOING = 'ONGOING', | ||
ACTIVE = 'ACTIVE', | ||
FAILED_INSUFFICIENT_PERMISSIONS = 'FAILED_INSUFFICIENT_PERMISSIONS', | ||
FAILED_UNKNOWN = 'FAILED_UNKNOWN', | ||
} | ||
|
||
export enum CalendarChannelSyncStage { | ||
FULL_CALENDAR_EVENT_LIST_FETCH_PENDING = 'FULL_CALENDAR_EVENT_LIST_FETCH_PENDING', | ||
PARTIAL_CALENDAR_EVENT_LIST_FETCH_PENDING = 'PARTIAL_CALENDAR_EVENT_LIST_FETCH_PENDING', | ||
CALENDAR_EVENT_LIST_FETCH_ONGOING = 'CALENDAR_EVENT_LIST_FETCH_ONGOING', | ||
CALENDAR_EVENTS_IMPORT_PENDING = 'CALENDAR_EVENTS_IMPORT_PENDING', | ||
CALENDAR_EVENTS_IMPORT_ONGOING = 'CALENDAR_EVENTS_IMPORT_ONGOING', | ||
FAILED = 'FAILED', | ||
} | ||
|
||
export enum CalendarChannelContactAutoCreationPolicy { | ||
AS_PARTICIPANT_AND_ORGANIZER = 'AS_PARTICIPANT_AND_ORGANIZER', | ||
AS_PARTICIPANT = 'AS_PARTICIPANT', | ||
AS_ORGANIZER = 'AS_ORGANIZER', | ||
NONE = 'NONE', | ||
} | ||
export type CalendarChannel = { | ||
id: string; | ||
handle: string; | ||
isContactAutoCreationEnabled?: boolean; | ||
isSyncEnabled?: boolean; | ||
isContactAutoCreationEnabled: boolean; | ||
contactAutoCreationPolicy: CalendarChannelContactAutoCreationPolicy; | ||
isSyncEnabled: boolean; | ||
visibility: CalendarChannelVisibility; | ||
syncStatus: string; | ||
syncStatus: CalendarChannelSyncStatus; | ||
syncStage: CalendarChannelSyncStage; | ||
syncCursor: string; | ||
syncStageStartedAt: Date; | ||
throttleFailureCount: number; | ||
__typename: 'CalendarChannel'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/twenty-front/src/modules/settings/accounts/constants/SyncStatus.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export enum SyncStatus { | ||
SYNCED = 'SYNCED', | ||
FAILED = 'FAILED', | ||
NOT_SYNCED = 'NOT_SYNCED', | ||
IMPORTING = 'IMPORTING', | ||
} |
87 changes: 87 additions & 0 deletions
87
...ages/twenty-front/src/modules/settings/accounts/utils/__tests__/computeSyncStatus.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { CalendarChannelSyncStatus } from '@/accounts/types/CalendarChannel'; | ||
import { MessageChannelSyncStatus } from '@/accounts/types/MessageChannel'; | ||
import { SyncStatus } from '@/settings/accounts/constants/SyncStatus'; | ||
import { computeSyncStatus } from '../computeSyncStatus'; | ||
|
||
describe('computeSyncStatus', () => { | ||
test('should return FAILED when both sync statuses are FAILED', () => { | ||
expect( | ||
computeSyncStatus( | ||
MessageChannelSyncStatus.FAILED_UNKNOWN, | ||
CalendarChannelSyncStatus.FAILED_UNKNOWN, | ||
), | ||
).toEqual(SyncStatus.FAILED); | ||
}); | ||
|
||
test('should return FAILED when message channel sync status is FAILED_UNKNOWN', () => { | ||
expect( | ||
computeSyncStatus( | ||
MessageChannelSyncStatus.FAILED_UNKNOWN, | ||
CalendarChannelSyncStatus.ACTIVE, | ||
), | ||
).toEqual(SyncStatus.FAILED); | ||
}); | ||
|
||
test('should return FAILED when message channel sync status is FAILED_INSUFFICIENT_PERMISSIONS', () => { | ||
expect( | ||
computeSyncStatus( | ||
MessageChannelSyncStatus.FAILED_INSUFFICIENT_PERMISSIONS, | ||
CalendarChannelSyncStatus.ACTIVE, | ||
), | ||
).toEqual(SyncStatus.FAILED); | ||
}); | ||
|
||
test('should return FAILED when calendar channel sync status is FAILED_UNKNOWN', () => { | ||
expect( | ||
computeSyncStatus( | ||
MessageChannelSyncStatus.ACTIVE, | ||
CalendarChannelSyncStatus.FAILED_UNKNOWN, | ||
), | ||
).toEqual(SyncStatus.FAILED); | ||
}); | ||
|
||
test('should return FAILED when calendar channel sync status is FAILED_INSUFFICIENT_PERMISSIONS', () => { | ||
expect( | ||
computeSyncStatus( | ||
MessageChannelSyncStatus.ACTIVE, | ||
CalendarChannelSyncStatus.FAILED_INSUFFICIENT_PERMISSIONS, | ||
), | ||
).toEqual(SyncStatus.FAILED); | ||
}); | ||
|
||
test('should return IMPORTING when message channel sync status is ONGOING', () => { | ||
expect( | ||
computeSyncStatus( | ||
MessageChannelSyncStatus.ONGOING, | ||
CalendarChannelSyncStatus.ACTIVE, | ||
), | ||
).toEqual(SyncStatus.IMPORTING); | ||
}); | ||
|
||
test('should return IMPORTING when calendar channel sync status is ONGOING', () => { | ||
expect( | ||
computeSyncStatus( | ||
MessageChannelSyncStatus.ACTIVE, | ||
CalendarChannelSyncStatus.ONGOING, | ||
), | ||
).toEqual(SyncStatus.IMPORTING); | ||
}); | ||
|
||
test('should return SYNCED when one channel is ACTIVE and the other is NOT_SYNCED', () => { | ||
expect( | ||
computeSyncStatus( | ||
MessageChannelSyncStatus.NOT_SYNCED, | ||
CalendarChannelSyncStatus.ACTIVE, | ||
), | ||
).toEqual(SyncStatus.SYNCED); | ||
}); | ||
|
||
test('should return SYNCED when one channel is ACTIVE and the other is NOT_SYNCED', () => { | ||
expect( | ||
computeSyncStatus( | ||
MessageChannelSyncStatus.ACTIVE, | ||
CalendarChannelSyncStatus.NOT_SYNCED, | ||
), | ||
).toEqual(SyncStatus.SYNCED); | ||
}); | ||
}); |
42 changes: 42 additions & 0 deletions
42
packages/twenty-front/src/modules/settings/accounts/utils/computeSyncStatus.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { CalendarChannelSyncStatus } from '@/accounts/types/CalendarChannel'; | ||
import { MessageChannelSyncStatus } from '@/accounts/types/MessageChannel'; | ||
import { SyncStatus } from '@/settings/accounts/constants/SyncStatus'; | ||
|
||
export const computeSyncStatus = ( | ||
messageChannelSyncStatus: MessageChannelSyncStatus, | ||
calendarChannelSyncStatus: CalendarChannelSyncStatus, | ||
) => { | ||
if ( | ||
messageChannelSyncStatus === MessageChannelSyncStatus.FAILED_UNKNOWN || | ||
messageChannelSyncStatus === | ||
MessageChannelSyncStatus.FAILED_INSUFFICIENT_PERMISSIONS || | ||
calendarChannelSyncStatus === CalendarChannelSyncStatus.FAILED_UNKNOWN || | ||
calendarChannelSyncStatus === | ||
CalendarChannelSyncStatus.FAILED_INSUFFICIENT_PERMISSIONS | ||
) { | ||
return SyncStatus.FAILED; | ||
} | ||
|
||
if ( | ||
messageChannelSyncStatus === MessageChannelSyncStatus.ONGOING || | ||
calendarChannelSyncStatus === CalendarChannelSyncStatus.ONGOING | ||
) { | ||
return SyncStatus.IMPORTING; | ||
} | ||
|
||
if ( | ||
messageChannelSyncStatus === MessageChannelSyncStatus.NOT_SYNCED && | ||
calendarChannelSyncStatus === CalendarChannelSyncStatus.NOT_SYNCED | ||
) { | ||
return SyncStatus.NOT_SYNCED; | ||
} | ||
|
||
if ( | ||
messageChannelSyncStatus === MessageChannelSyncStatus.ACTIVE || | ||
calendarChannelSyncStatus === CalendarChannelSyncStatus.ACTIVE | ||
) { | ||
return SyncStatus.SYNCED; | ||
} | ||
|
||
return SyncStatus.NOT_SYNCED; | ||
}; |
7 changes: 1 addition & 6 deletions
7
packages/twenty-server/src/engine/core-modules/calendar/dtos/timeline-calendar-event.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 1 addition & 6 deletions
7
packages/twenty-server/src/engine/core-modules/messaging/dtos/timeline-thread.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.