The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Show Not connected for built-in apps without an account (#29329)
nitin4441a99247b8
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/utils/__tests__/getAppPreferencesAppStatusesById.test.ts b/packages/twenty-front/src/modules/settings/app-preferences/utils/__tests__/getAppPreferencesAppStatusesById.test.tsindex c84c04760e7..8f5dcb026fb 100644--- a/packages/twenty-front/src/modules/settings/app-preferences/utils/__tests__/getAppPreferencesAppStatusesById.test.ts+++ b/packages/twenty-front/src/modules/settings/app-preferences/utils/__tests__/getAppPreferencesAppStatusesById.test.ts@@ -92,9 +92,34 @@ describe('getAppPreferencesAppStatusesById', () => {}),).toEqual({google: [{ type: 'accountSyncIssue', account: failedAccount }],+ outlook: [{ type: 'notConnected' }],});});+ it('hints at connecting a built-in app only when no account uses it', () => {+ const pausedAccount = buildAccount({+ provider: ConnectedAccountProvider.GOOGLE,+ applicationId: null,+ archivedAt: '2026-09-01',+ messageChannelSyncStatus: MessageChannelSyncStatus.FAILED_UNKNOWN,+ });++ expect(+ getAppPreferencesAppStatusesById({+ groups: [+ {+ id: 'group',+ handle: '[email protected]',+ builtInAccount: pausedAccount,+ appAccounts: [],+ },+ ],+ builtInAccountApps: [{ id: 'google' }, { id: 'imap' }],+ applicationsWithPreferences: [],+ }),+ ).toEqual({ imap: [{ type: 'notConnected' }] });+ });+it('asks to reconnect when an active connection failed to authenticate', () => {expect(getStatusesOfInstalledApplication({diff --git a/packages/twenty-front/src/modules/settings/app-preferences/utils/getAppPreferencesAppStatusesById.ts b/packages/twenty-front/src/modules/settings/app-preferences/utils/getAppPreferencesAppStatusesById.tsindex 02362f7ecaa..b20318bda75 100644--- a/packages/twenty-front/src/modules/settings/app-preferences/utils/getAppPreferencesAppStatusesById.ts+++ b/packages/twenty-front/src/modules/settings/app-preferences/utils/getAppPreferencesAppStatusesById.ts@@ -18,10 +18,9 @@ export const getAppPreferencesAppStatusesById = <builtInAccountApps: Pick<BuiltInAccountApp, 'id'>[];applicationsWithPreferences: AppPreferencesAppStatusApplication[];}): Record<string, SettingsMemberApplicationStatus<TConnectedAccount>[]> => {- const activeBuiltInAccounts = groups+ const builtInAccounts = groups.map((group) => group.builtInAccount)- .filter(isDefined)- .filter((account) => !isDefined(account.archivedAt));+ .filter(isDefined);const activeAppAccounts = groups.flatMap((group) => group.appAccounts).filter((account) => !isDefined(account.archivedAt));@@ -34,7 +33,7 @@ export const getAppPreferencesAppStatusesById = <for (const { id } of builtInAccountApps) {const statuses = getBuiltInAccountAppStatuses({builtInAccountAppId: id,- activeBuiltInAccounts,+ builtInAccounts,});if (isNonEmptyArray(statuses)) {diff --git a/packages/twenty-front/src/modules/settings/app-preferences/utils/getBuiltInAccountAppStatuses.ts b/packages/twenty-front/src/modules/settings/app-preferences/utils/getBuiltInAccountAppStatuses.tsindex 788a83320cc..a326d85407a 100644--- a/packages/twenty-front/src/modules/settings/app-preferences/utils/getBuiltInAccountAppStatuses.ts+++ b/packages/twenty-front/src/modules/settings/app-preferences/utils/getBuiltInAccountAppStatuses.ts@@ -4,33 +4,39 @@ import { type AppPreferencesAppStatusAccount } from '@/settings/app-preferences/import { type BuiltInAccountApp } from '@/settings/app-preferences/types/BuiltInAccountApp';import { getBuiltInAccountAppsUsingAccount } from '@/settings/app-preferences/utils/getBuiltInAccountAppsUsingAccount';import { type SettingsMemberApplicationStatus } from '@/settings/applications/types/SettingsMemberApplicationStatus';-import { isDefined } from 'twenty-shared/utils';+import { isDefined, isNonEmptyArray } from 'twenty-shared/utils';export const getBuiltInAccountAppStatuses = <TConnectedAccount extends AppPreferencesAppStatusAccount,>({builtInAccountAppId,- activeBuiltInAccounts,+ builtInAccounts,}: {builtInAccountAppId: BuiltInAccountApp['id'];- activeBuiltInAccounts: TConnectedAccount[];+ builtInAccounts: TConnectedAccount[];}): SettingsMemberApplicationStatus<TConnectedAccount>[] => {- const accountsUsingApp = activeBuiltInAccounts.filter((account) =>+ const accountsUsingApp = builtInAccounts.filter((account) =>getBuiltInAccountAppsUsingAccount(account).some((app) => app.id === builtInAccountAppId,),);- const findAccountWithStatus = (status: SyncStatus) =>++ if (!isNonEmptyArray(accountsUsingApp)) {+ return [{ type: 'notConnected' }];+ }++ const findActiveAccountWithStatus = (status: SyncStatus) =>accountsUsingApp.find((account) =>+ !isDefined(account.archivedAt) &&computeSyncStatus(account.messageChannels[0],account.calendarChannels[0],) === status,);const brokenAccount =- findAccountWithStatus(SyncStatus.FAILED) ??- findAccountWithStatus(SyncStatus.PENDING_CONFIGURATION);+ findActiveAccountWithStatus(SyncStatus.FAILED) ??+ findActiveAccountWithStatus(SyncStatus.PENDING_CONFIGURATION);return isDefined(brokenAccount)? [{ type: 'accountSyncIssue', account: brokenAccount }]