The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Merge Gmail and Google Calendar into one Google app in app preferences (#28257)
nitin4d268473b5c4
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/constants/NativeAccountApps.ts b/packages/twenty-front/src/modules/settings/app-preferences/constants/NativeAccountApps.tsindex 9c0d661744b..8bfb7219e5d 100644--- a/packages/twenty-front/src/modules/settings/app-preferences/constants/NativeAccountApps.ts+++ b/packages/twenty-front/src/modules/settings/app-preferences/constants/NativeAccountApps.ts@@ -1,21 +1,16 @@import { type NativeAccountApp } from '@/settings/app-preferences/types/NativeAccountApp';import { msg } from '@lingui/core/macro';import { ConnectedAccountProvider } from 'twenty-shared/types';-import {- IconAt,- IconGmail,- IconGoogleCalendar,- IconMicrosoftOutlook,-} from 'twenty-ui/icon';+import { IconAt, IconGoogle, IconMicrosoftOutlook } from 'twenty-ui/icon';export const NATIVE_ACCOUNT_APPS: NativeAccountApp[] = [{- id: 'gmail',- name: msg`Gmail`,- Icon: IconGmail,+ id: 'google',+ name: msg`Gmail and Calendar`,+ Icon: IconGoogle,provider: ConnectedAccountProvider.GOOGLE,hasEmails: true,- hasCalendar: false,+ hasCalendar: true,permissions: [{label: msg`Read emails`,@@ -28,16 +23,6 @@ export const NATIVE_ACCOUNT_APPS: NativeAccountApp[] = ['https://www.googleapis.com/auth/gmail.compose',],},- ],- },- {- id: 'google-calendar',- name: msg`Google Calendar`,- Icon: IconGoogleCalendar,- provider: ConnectedAccountProvider.GOOGLE,- hasEmails: false,- hasCalendar: true,- permissions: [{label: msg`Manage events`,scopes: ['https://www.googleapis.com/auth/calendar.events'],diff --git a/packages/twenty-front/src/modules/settings/app-preferences/hooks/useEnabledNativeAccountApps.ts b/packages/twenty-front/src/modules/settings/app-preferences/hooks/useEnabledNativeAccountApps.tsindex c5a4a698bf7..6067aece31c 100644--- a/packages/twenty-front/src/modules/settings/app-preferences/hooks/useEnabledNativeAccountApps.ts+++ b/packages/twenty-front/src/modules/settings/app-preferences/hooks/useEnabledNativeAccountApps.ts@@ -25,8 +25,7 @@ export const useEnabledNativeAccountApps = () => {);const isAppEnabled: Record<NativeAccountApp['id'], boolean> = {- gmail: isGoogleMessagingEnabled,- 'google-calendar': isGoogleCalendarEnabled,+ google: isGoogleMessagingEnabled || isGoogleCalendarEnabled,outlook: isMicrosoftMessagingEnabled || isMicrosoftCalendarEnabled,imap: isImapSmtpCaldavEnabled,};diff --git a/packages/twenty-front/src/modules/settings/app-preferences/types/NativeAccountApp.ts b/packages/twenty-front/src/modules/settings/app-preferences/types/NativeAccountApp.tsindex 4695404ee4a..adde2946196 100644--- a/packages/twenty-front/src/modules/settings/app-preferences/types/NativeAccountApp.ts+++ b/packages/twenty-front/src/modules/settings/app-preferences/types/NativeAccountApp.ts@@ -4,7 +4,7 @@ import { type ConnectedAccountProvider } from 'twenty-shared/types';import { type IconComponent } from 'twenty-ui/icon';export type NativeAccountApp = {- id: 'gmail' | 'google-calendar' | 'outlook' | 'imap';+ id: 'google' | 'outlook' | 'imap';name: MessageDescriptor;Icon: IconComponent;provider: ConnectedAccountProvider;diff --git a/packages/twenty-front/src/modules/settings/app-preferences/utils/__tests__/getNativeAccountAppsUsingAccount.test.ts b/packages/twenty-front/src/modules/settings/app-preferences/utils/__tests__/getNativeAccountAppsUsingAccount.test.tsindex 16ef0a72624..1a06cb94fb0 100644--- a/packages/twenty-front/src/modules/settings/app-preferences/utils/__tests__/getNativeAccountAppsUsingAccount.test.ts+++ b/packages/twenty-front/src/modules/settings/app-preferences/utils/__tests__/getNativeAccountAppsUsingAccount.test.ts@@ -27,24 +27,24 @@ const getAppIds = () => getNativeAccountAppsUsingAccount(account).map((app) => app.id);describe('getNativeAccountAppsUsingAccount', () => {- it('splits a Google account into Gmail and Google Calendar', () => {+ it('lists Google once for a Google account with mail and calendar', () => {expect(getAppIds({provider: ConnectedAccountProvider.GOOGLE,messageChannels: [mailbox],calendarChannels: [calendar],}),- ).toEqual(['gmail', 'google-calendar']);+ ).toEqual(['google']);});- it('only lists the Google apps whose channel exists', () => {+ it('lists Google for a Google account with only a calendar', () => {expect(getAppIds({provider: ConnectedAccountProvider.GOOGLE,messageChannels: [],calendarChannels: [calendar],}),- ).toEqual(['google-calendar']);+ ).toEqual(['google']);});it('counts channels that still need setup', () => {@@ -54,7 +54,7 @@ describe('getNativeAccountAppsUsingAccount', () => {messageChannels: [mailboxWaitingForSetup],calendarChannels: [],}),- ).toEqual(['gmail']);+ ).toEqual(['google']);});it('ignores message channels that are not mailboxes', () => {diff --git a/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsAccounts.stories.tsx b/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsAccounts.stories.tsxindex 163d3d1a65b..b8594edc01c 100644--- a/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsAccounts.stories.tsx+++ b/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsAccounts.stories.tsx@@ -87,8 +87,9 @@ export const AccountsGroupedByEmail: Story = {const timRow = getTableRow(canvasElement, '[email protected]');- expect(timRow.getByRole('img', { name: 'Gmail' })).toBeVisible();- expect(timRow.getByRole('img', { name: 'Google Calendar' })).toBeVisible();+ expect(+ timRow.getAllByRole('img', { name: 'Gmail and Calendar' }),+ ).toHaveLength(1);expect(timRow.getByRole('img', { name: 'Fathom' })).toBeVisible();expect(timRow.queryByRole('img', { name: 'Granola' }),@@ -107,7 +108,7 @@ export const AccountsGroupedByEmail: Story = {expect(notesRow.getByRole('img', { name: 'Fathom' })).toBeVisible();expect(- notesRow.queryByRole('img', { name: 'Gmail' }),+ notesRow.queryByRole('img', { name: 'Gmail and Calendar' }),).not.toBeInTheDocument();expect(notesRow.queryByRole('button', { name: 'More options' }),@@ -136,8 +137,9 @@ export const AppPreferencesListEnabledApps: Story = {);await canvas.findByText('[email protected]');- expect(canvas.getByRole('link', { name: 'Gmail' })).toBeVisible();- expect(canvas.getByRole('link', { name: 'Google Calendar' })).toBeVisible();+ expect(+ canvas.getByRole('link', { name: 'Gmail and Calendar' }),+ ).toBeVisible();expect(canvas.queryByText('IMAP')).not.toBeInTheDocument();expect(canvas.queryByText('Missing account')).not.toBeInTheDocument();expect(canvas.queryByText('Blocklist')).not.toBeInTheDocument();@@ -158,7 +160,7 @@ export const RowOpensAccountPage: Story = {await canvas.findByText('Used by', undefined, { timeout: 3000 });await userEvent.click(getTableRow(canvasElement, '[email protected]').getByRole('img', {- name: 'Gmail',+ name: 'Gmail and Calendar',}),);@@ -247,12 +249,9 @@ export const AppsWithoutAccountShowMissingAccount: Story = {await getTableRow(canvasElement, 'Outlook').findByText('Missing account'),).toBeVisible();expect(- getTableRow(canvasElement, 'Google Calendar').getByText(+ getTableRow(canvasElement, 'Gmail and Calendar').queryByText('Missing account',),- ).toBeVisible();- expect(- getTableRow(canvasElement, 'Gmail').queryByText('Missing account'),).not.toBeInTheDocument();},};diff --git a/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsNativeAccountApp.stories.tsx b/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsNativeAccountApp.stories.tsxindex 0abd2b0e635..0e0791544d4 100644--- a/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsNativeAccountApp.stories.tsx+++ b/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsNativeAccountApp.stories.tsx@@ -21,7 +21,7 @@ const meta: Meta<PageDecoratorArgs> = {decorators: [PageDecorator],args: {routePath: '/settings/accounts/apps/:nativeAccountAppId',- routeParams: { ':nativeAccountAppId': 'gmail' },+ routeParams: { ':nativeAccountAppId': 'google' },additionalRoutes: ['/settings/accounts'],},beforeEach: seedAccountGroupsStory,@@ -35,7 +35,7 @@ export default meta;export type Story = StoryObj<typeof SettingsNativeAccountApp>;-export const GmailGeneralShowsAccountsAndBlocklist: Story = {+export const GoogleGeneralShowsAccountsAndBlocklist: Story = {play: async ({ canvasElement }) => {const canvas = within(canvasElement);@@ -49,17 +49,16 @@ export const GmailGeneralShowsAccountsAndBlocklist: Story = {expect(canvas.queryByText('[email protected]')).not.toBeInTheDocument();expect(canvas.queryByText('Used by')).not.toBeInTheDocument();expect(canvas.getByText('Permissions')).toBeVisible();- expect(canvas.getByText('Read emails, Send emails')).toBeVisible();- expect(canvas.getByText('Read emails')).toBeVisible();expect(- canvas.queryByRole('img', { name: 'Google Calendar' }),- ).not.toBeInTheDocument();+ canvas.getByText('Read emails, Send emails, Manage events'),+ ).toBeVisible();+ expect(canvas.getByText('Read emails')).toBeVisible();expect(canvas.getByTestId('tab-emails')).toBeVisible();- expect(canvas.queryByTestId('tab-calendar')).not.toBeInTheDocument();+ expect(canvas.getByTestId('tab-calendar')).toBeVisible();},};-export const GmailEmailsTabSwitchesAccount: Story = {+export const GoogleEmailsTabSwitchesAccount: Story = {play: async ({ canvasElement }) => {const canvas = within(canvasElement);const body = within(canvasElement.ownerDocument.body);@@ -82,6 +81,20 @@ export const GmailEmailsTabSwitchesAccount: Story = {},};+export const GoogleCalendarTabShowsCalendarSettings: Story = {+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ await userEvent.click(+ await canvas.findByTestId('tab-calendar', undefined, { timeout: 3000 }),+ );++ expect(await canvas.findByText('Event visibility')).toBeVisible();+ expect(canvas.getByText('[email protected]')).toBeVisible();+ expect(canvas.queryByText('[email protected]')).not.toBeInTheDocument();+ },+};+export const OutlookHasEmailsAndCalendarTabs: Story = {args: {routeParams: { ':nativeAccountAppId': 'outlook' },