The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Let members manage personal app connections from App preferences (#28418)
nitin01aea1ef324b
diff --git a/packages/twenty-agent-skills/references/develop-app/logic.md b/packages/twenty-agent-skills/references/develop-app/logic.mdindex cd5d2d04348..e9ab48d124d 100644--- a/packages/twenty-agent-skills/references/develop-app/logic.md+++ b/packages/twenty-agent-skills/references/develop-app/logic.md@@ -100,7 +100,7 @@ For third-party connections:- Document required OAuth or API setup in the app README or listing.- Verify failure states for expired or missing credentials.- When the provider can say which account a token belongs to (team, organization, user), declare `identifyAccountLogicFunction` so a reconnect that authorizes a different account is refused instead of overwriting the connection. Write the handler as one request to the provider's "who am I" endpoint, return the id as a string, and return `{ externalAccountId: null }` when there is no stable id.-- Set `scope` on `defineConnectionProvider`: `'WORKSPACE'` (default) when the app uses one connection shared with the workspace, `'USER'` when each member connects their own account. One scope per provider; declare two providers when the app needs both. A provider's scope cannot change in a later version: declare a new provider with a new `universalIdentifier` instead, which deletes the old provider's connections on upgrade, and deletes existing `'USER'` connected accounts left on a `'WORKSPACE'` provider. Members cannot add `USER` connections from settings yet (they will from App preferences). Requires `"engines": { "twenty": ">=2.49.0" }`.+- Set `scope` on `defineConnectionProvider`: `'WORKSPACE'` (default) when the app uses one connection shared with the workspace, `'USER'` when each member connects their own account. One scope per provider; declare two providers when the app needs both. A provider's scope cannot change in a later version: declare a new provider with a new `universalIdentifier` instead, which deletes the old provider's connections on upgrade, and deletes existing `'USER'` connected accounts left on a `'WORKSPACE'` provider. Members add, reconnect and remove `USER` connections from the app's page under Settings > User > App preferences, but that page is not enabled in every workspace yet, so do not rely on a `USER` provider for a feature every workspace needs now. Requires `"engines": { "twenty": ">=2.49.0" }`.- For services that connect accounts through their own hosted flow instead of OAuth (Unipile, Plaid, Merge), declare `type: 'custom'` with `custom.authorizeLogicFunction` (return `{ authorizationUrl }` built with the given `callbackUrl`) and `custom.callbackLogicFunction` (receives each `GET` return and `POST` notification to that URL with its query, headers, body and `rawBody`; verify a signed notification over `rawBody`, confirm the account with the service, then return `{ externalAccountId, handle?, accessToken? }`, or `null` when the request carries no account). Both run within 10 seconds. Connections carry `providerType`: an `'oauth'` connection always has an `accessToken`, a `'custom'` one has `null` unless the callback returned one, so call the service with the app's own key and `externalAccountId`. Release upstream state in `onDisconnectLogicFunction`; Twenty does not refresh or revoke custom connections. The `type` cannot change after the first sync; declare a new provider with a new `universalIdentifier` instead. Requires `"engines": { "twenty": ">=2.52.0" }`.## Messaging Providersdiff --git a/packages/twenty-client-sdk/src/metadata/generated/schema.graphql b/packages/twenty-client-sdk/src/metadata/generated/schema.graphqlindex b4ea8025a80..c438d732fb9 100644--- a/packages/twenty-client-sdk/src/metadata/generated/schema.graphql+++ b/packages/twenty-client-sdk/src/metadata/generated/schema.graphql@@ -629,6 +629,7 @@ type ApplicationMonitoringVersion {type ApplicationPreferences {applicationId: UUID!+ connectionProviders: [ApplicationConnectionProvider!]!settingsMenuItems: [SettingsMenuItem!]!variables: [UserApplicationVariableValue!]!}diff --git a/packages/twenty-client-sdk/src/metadata/generated/schema.ts b/packages/twenty-client-sdk/src/metadata/generated/schema.tsindex 34bba92a1fa..f859d1622ce 100644--- a/packages/twenty-client-sdk/src/metadata/generated/schema.ts+++ b/packages/twenty-client-sdk/src/metadata/generated/schema.ts@@ -552,6 +552,7 @@ export interface ApplicationMonitoringVersion {export interface ApplicationPreferences {applicationId: Scalars['UUID']+ connectionProviders: ApplicationConnectionProvider[]settingsMenuItems: SettingsMenuItem[]variables: UserApplicationVariableValue[]__typename: 'ApplicationPreferences'@@ -4743,6 +4744,7 @@ export interface ApplicationMonitoringVersionGenqlSelection{export interface ApplicationPreferencesGenqlSelection{applicationId?: boolean | number+ connectionProviders?: ApplicationConnectionProviderGenqlSelectionsettingsMenuItems?: SettingsMenuItemGenqlSelectionvariables?: UserApplicationVariableValueGenqlSelection__typename?: boolean | numberdiff --git a/packages/twenty-client-sdk/src/metadata/generated/types.ts b/packages/twenty-client-sdk/src/metadata/generated/types.tsindex b5596f86e7c..0a38c8928b3 100644--- a/packages/twenty-client-sdk/src/metadata/generated/types.ts+++ b/packages/twenty-client-sdk/src/metadata/generated/types.ts@@ -1426,6 +1426,9 @@ export default {"applicationId": [519],+ "connectionProviders": [+ 48+ ],"settingsMenuItems": [479],diff --git a/packages/twenty-docs/developers/extend/apps/logic/connections.mdx b/packages/twenty-docs/developers/extend/apps/logic/connections.mdxindex 66f6f798f57..d95971844b5 100644--- a/packages/twenty-docs/developers/extend/apps/logic/connections.mdx+++ b/packages/twenty-docs/developers/extend/apps/logic/connections.mdx@@ -455,7 +455,7 @@ Each connection has:| Field | Description || ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- || `id` | Unique row id; pass to `getConnection(id)` to refetch a single one |-| `scope` | `'USER'` (private to one workspace member) or `'WORKSPACE'` (shared with all members) |+| `scope` | `'USER'` (belongs to the connecting member) or `'WORKSPACE'` (shared with all members) || `visibility` | Deprecated: `scope` in lowercase (`'user'` or `'workspace'`). Use `scope` instead || `scopes` | OAuth permissions granted by the upstream provider (distinct from `scope` — those are unrelated) || `userWorkspaceId` | The owner's userWorkspace id — useful for picking "the request user's connection" in HTTP-route triggers |@@ -503,12 +503,18 @@ The mutation behind this helper ships with Twenty 2.40.0, so calling it againstEach connection has one of two scopes:- **Workspace shared** (`'WORKSPACE'`) — any workspace member can use the credential. Cron / database triggers also see it, since they have no request user.-- **Just for me** (`'USER'`) — the credential is private to the connecting member. Any logic function called on their behalf (HTTP-route trigger with `isAuthRequired: true`) sees it; cron triggers and database events do not.+- **Just for me** (`'USER'`) — the credential belongs to the connecting member. In runs made on a member's behalf (HTTP-route trigger with `isAuthRequired: true`), `listConnections` returns the shared connections plus that member's own, and `findConnectionForRequest` picks the member's personal connection, falling back to a shared one when they have none. In runs without a request user (cron triggers, for example), `listConnections` returns every connection, including every member's personal ones.The provider's `scope` decides which one its new connections get:-- `scope: 'WORKSPACE'` (the default) — the app works with connections shared with the workspace. **Add connection** in the app's settings creates a workspace-shared connection.-- `scope: 'USER'` — each member connects their own account, creating personal connections. Members will connect from their **App preferences**, which is not available yet: until then a `USER` provider has no **Add connection** button, and the app's settings only list the connections a member can already see.+- `scope: 'WORKSPACE'` (the default) — the app works with connections shared with the workspace. **Add connection** in the app's workspace settings creates a workspace-shared connection.+- `scope: 'USER'` — each member connects their own account, creating personal connections. Members add, reconnect and remove them from the app's page under **Settings > User > App preferences**, which requires the `CONNECTED_ACCOUNTS` (User Apps) permission. The app's workspace settings have no **Add connection** button for a `USER` provider.++<Note>+ **App preferences** is not enabled in every workspace yet: where it is not,+ members have no place to add a `USER` connection, so do not rely on one for+ a feature every workspace needs now.+</Note>A provider has exactly one scope. If your app needs both a shared credential and one per member for the same service (a bot token and each member's own account, say), declare two providers.diff --git a/packages/twenty-front/src/generated-metadata/graphql.ts b/packages/twenty-front/src/generated-metadata/graphql.tsindex be855885823..77b7235ac9d 100644--- a/packages/twenty-front/src/generated-metadata/graphql.ts+++ b/packages/twenty-front/src/generated-metadata/graphql.ts@@ -700,6 +700,7 @@ export type ApplicationMonitoringVersion = {export type ApplicationPreferences = {__typename?: 'ApplicationPreferences';applicationId: Scalars['UUID']['output'];+ connectionProviders: Array<ApplicationConnectionProvider>;settingsMenuItems: Array<SettingsMenuItem>;variables: Array<UserApplicationVariableValue>;};@@ -10255,7 +10256,7 @@ export type UpdateMyUserApplicationVariableMutation = { __typename?: 'Mutation',export type MyApplicationPreferencesQueryVariables = Exact<{ [key: string]: never; }>;-export type MyApplicationPreferencesQuery = { __typename?: 'Query', myApplicationPreferences: Array<{ __typename?: 'ApplicationPreferences', applicationId: string, settingsMenuItems: Array<{ __typename?: 'SettingsMenuItem', id: string, universalIdentifier: string, applicationId: string, frontComponentId: string, title: string, icon?: string | null, position: number, scope: SettingsMenuItemScope }>, variables: Array<{ __typename?: 'UserApplicationVariableValue', key: string, value: string, description: string, label: string, isSecret: boolean, isDeprecated: boolean, isRequired: boolean, type: string, options?: any | null }> }> };+export type MyApplicationPreferencesQuery = { __typename?: 'Query', myApplicationPreferences: Array<{ __typename?: 'ApplicationPreferences', applicationId: string, settingsMenuItems: Array<{ __typename?: 'SettingsMenuItem', id: string, universalIdentifier: string, applicationId: string, frontComponentId: string, title: string, icon?: string | null, position: number, scope: SettingsMenuItemScope }>, variables: Array<{ __typename?: 'UserApplicationVariableValue', key: string, value: string, description: string, label: string, isSecret: boolean, isDeprecated: boolean, isRequired: boolean, type: string, options?: any | null }>, connectionProviders: Array<{ __typename?: 'ApplicationConnectionProvider', id: string, applicationId: string, type: string, name: string, displayName: string, scope: ConnectionProviderScope, logoUrl?: string | null, oauth?: { __typename?: 'ApplicationConnectionProviderOAuthConfig', scopes: Array<string>, isClientCredentialsConfigured: boolean } | null }> }> };export type ApplicationRegistrationFragmentFragment = { __typename?: 'ApplicationRegistration', id: string, universalIdentifier: string, name: string, logoUrl?: string | null, galleryImagesUrls: Array<string>, oAuthClientId: string, oAuthRedirectUris: Array<string>, oAuthScopes: Array<string>, sourceType: ApplicationRegistrationSourceType, sourcePackage?: string | null, latestAvailableVersion?: string | null, isListed: boolean, isVetted: boolean, isPreInstalled: boolean, isConfigured: boolean, ownerWorkspaceId?: string | null, createdAt: string, updatedAt: string };@@ -10370,6 +10371,8 @@ export type GithubClaimAuthorizationUrlQueryVariables = Exact<{export type GithubClaimAuthorizationUrlQuery = { __typename?: 'Query', githubClaimAuthorizationUrl: string };+export type ApplicationConnectionProviderFragmentFragment = { __typename?: 'ApplicationConnectionProvider', id: string, applicationId: string, type: string, name: string, displayName: string, scope: ConnectionProviderScope, logoUrl?: string | null, oauth?: { __typename?: 'ApplicationConnectionProviderOAuthConfig', scopes: Array<string>, isClientCredentialsConfigured: boolean } | null };+export type TriggerUninstallApplicationMutationVariables = Exact<{input: TriggerUninstallApplicationInput;}>;@@ -10406,7 +10409,7 @@ export type ApplicationConnectedAccountsQueryVariables = Exact<{}>;-export type ApplicationConnectedAccountsQuery = { __typename?: 'Query', applicationConnectedAccounts: Array<{ __typename?: 'ApplicationConnectedAccountDTO', id: string, handle: string, authFailedAt?: string | null, authFailedReason?: string | null, scopes?: Array<string> | null, lastSignedInAt?: string | null, connectionProviderId?: string | null, name?: string | null, scope: ConnectedAccountScope, lastCredentialsRefreshedAt?: string | null, createdAt: string, updatedAt: string }> };+export type ApplicationConnectedAccountsQuery = { __typename?: 'Query', applicationConnectedAccounts: Array<{ __typename?: 'ApplicationConnectedAccountDTO', id: string, handle: string, authFailedAt?: string | null, authFailedReason?: string | null, archivedAt?: string | null, scopes?: Array<string> | null, lastSignedInAt?: string | null, connectionProviderId?: string | null, name?: string | null, scope: ConnectedAccountScope, lastCredentialsRefreshedAt?: string | null, createdAt: string, updatedAt: string }> };export type ApplicationConnectionProvidersQueryVariables = Exact<{applicationId: Scalars['UUID']['input'];@@ -11384,6 +11387,7 @@ export const NavigationMenuItemQueryFieldsFragmentDoc = {"kind":"Document","defiexport const RecordSharingFieldsFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"RecordSharingFields"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"RecordSharingDTO"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"sharingMode"}},{"kind":"Field","name":{"kind":"Name","value":"canManageSharing"}},{"kind":"Field","name":{"kind":"Name","value":"permissions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"canRead"}},{"kind":"Field","name":{"kind":"Name","value":"canUpdate"}},{"kind":"Field","name":{"kind":"Name","value":"canDelete"}},{"kind":"Field","name":{"kind":"Name","value":"canSoftDelete"}}]}},{"kind":"Field","name":{"kind":"Name","value":"generalAccessLevel"}},{"kind":"Field","name":{"kind":"Name","value":"defaultGeneralAccessLevel"}},{"kind":"Field","name":{"kind":"Name","value":"hasManagedGeneralAccess"}},{"kind":"Field","name":{"kind":"Name","value":"shares"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"principalId"}},{"kind":"Field","name":{"kind":"Name","value":"principalType"}},{"kind":"Field","name":{"kind":"Name","value":"principalRoleId"}},{"kind":"Field","name":{"kind":"Name","value":"accessLevel"}},{"kind":"Field","name":{"kind":"Name","value":"rowCause"}}]}},{"kind":"Field","name":{"kind":"Name","value":"roles"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"canRead"}},{"kind":"Field","name":{"kind":"Name","value":"canUpdate"}}]}}]}}]} as unknown as DocumentNode<RecordSharingFieldsFragment, unknown>;export const ApplicationRegistrationFragmentFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ApplicationRegistrationFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ApplicationRegistration"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"universalIdentifier"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"logoUrl"}},{"kind":"Field","name":{"kind":"Name","value":"galleryImagesUrls"}},{"kind":"Field","name":{"kind":"Name","value":"oAuthClientId"}},{"kind":"Field","name":{"kind":"Name","value":"oAuthRedirectUris"}},{"kind":"Field","name":{"kind":"Name","value":"oAuthScopes"}},{"kind":"Field","name":{"kind":"Name","value":"sourceType"}},{"kind":"Field","name":{"kind":"Name","value":"sourcePackage"}},{"kind":"Field","name":{"kind":"Name","value":"latestAvailableVersion"}},{"kind":"Field","name":{"kind":"Name","value":"isListed"}},{"kind":"Field","name":{"kind":"Name","value":"isVetted"}},{"kind":"Field","name":{"kind":"Name","value":"isPreInstalled"}},{"kind":"Field","name":{"kind":"Name","value":"isConfigured"}},{"kind":"Field","name":{"kind":"Name","value":"ownerWorkspaceId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]} as unknown as DocumentNode<ApplicationRegistrationFragmentFragment, unknown>;export const ApplicationRegistrationListItemFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ApplicationRegistrationListItem"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ApplicationRegistration"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"universalIdentifier"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"sourceType"}},{"kind":"Field","name":{"kind":"Name","value":"logoUrl"}}]}}]} as unknown as DocumentNode<ApplicationRegistrationListItemFragment, unknown>;+export const ApplicationConnectionProviderFragmentFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ApplicationConnectionProviderFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ApplicationConnectionProvider"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"applicationId"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"scope"}},{"kind":"Field","name":{"kind":"Name","value":"logoUrl"}},{"kind":"Field","name":{"kind":"Name","value":"oauth"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"scopes"}},{"kind":"Field","name":{"kind":"Name","value":"isClientCredentialsConfigured"}}]}}]}}]} as unknown as DocumentNode<ApplicationConnectionProviderFragmentFragment, unknown>;export const BillingPriceLicensedFragmentFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BillingPriceLicensedFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingPriceLicensed"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"stripePriceId"}},{"kind":"Field","name":{"kind":"Name","value":"unitAmount"}},{"kind":"Field","name":{"kind":"Name","value":"recurringInterval"}},{"kind":"Field","name":{"kind":"Name","value":"priceUsageType"}},{"kind":"Field","name":{"kind":"Name","value":"creditAmount"}},{"kind":"Field","name":{"kind":"Name","value":"isSellable"}}]}}]} as unknown as DocumentNode<BillingPriceLicensedFragmentFragment, unknown>;export const BillingPriceMeteredFragmentFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BillingPriceMeteredFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingPriceMetered"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"priceUsageType"}},{"kind":"Field","name":{"kind":"Name","value":"recurringInterval"}},{"kind":"Field","name":{"kind":"Name","value":"stripePriceId"}},{"kind":"Field","name":{"kind":"Name","value":"tiers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"flatAmount"}},{"kind":"Field","name":{"kind":"Name","value":"unitAmount"}},{"kind":"Field","name":{"kind":"Name","value":"upTo"}}]}}]}}]} as unknown as DocumentNode<BillingPriceMeteredFragmentFragment, unknown>;export const ApiKeyFragmentFragmentDoc = {"kind":"Document","definitions":[{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ApiKeyFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ApiKey"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"expiresAt"}},{"kind":"Field","name":{"kind":"Name","value":"revokedAt"}},{"kind":"Field","name":{"kind":"Name","value":"role"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}}]}}]}}]} as unknown as DocumentNode<ApiKeyFragmentFragment, unknown>;@@ -11600,7 +11604,7 @@ export const MyConnectedAccountsDocument = {"kind":"Document","definitions":[{"kexport const MyMessageChannelsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"MyMessageChannels"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"connectedAccountId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"myMessageChannels"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"connectedAccountId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"connectedAccountId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"handle"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"visibility"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"isContactAutoCreationEnabled"}},{"kind":"Field","name":{"kind":"Name","value":"contactAutoCreationPolicy"}},{"kind":"Field","name":{"kind":"Name","value":"messageFolderImportPolicy"}},{"kind":"Field","name":{"kind":"Name","value":"excludeNonProfessionalEmails"}},{"kind":"Field","name":{"kind":"Name","value":"excludeGroupEmails"}},{"kind":"Field","name":{"kind":"Name","value":"isSyncEnabled"}},{"kind":"Field","name":{"kind":"Name","value":"syncStatus"}},{"kind":"Field","name":{"kind":"Name","value":"syncStage"}},{"kind":"Field","name":{"kind":"Name","value":"syncStageStartedAt"}},{"kind":"Field","name":{"kind":"Name","value":"importProgress"}},{"kind":"Field","name":{"kind":"Name","value":"connectedAccountId"}},{"kind":"Field","name":{"kind":"Name","value":"connectedAccount"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"handle"}}]}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<MyMessageChannelsQuery, MyMessageChannelsQueryVariables>;export const MyMessageFoldersDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"MyMessageFolders"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"messageChannelId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"myMessageFolders"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"messageChannelId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"messageChannelId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"isSynced"}},{"kind":"Field","name":{"kind":"Name","value":"isSentFolder"}},{"kind":"Field","name":{"kind":"Name","value":"parentFolderId"}},{"kind":"Field","name":{"kind":"Name","value":"externalId"}},{"kind":"Field","name":{"kind":"Name","value":"pendingSyncAction"}},{"kind":"Field","name":{"kind":"Name","value":"messageChannelId"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<MyMessageFoldersQuery, MyMessageFoldersQueryVariables>;export const UpdateMyUserApplicationVariableDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateMyUserApplicationVariable"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"applicationUniversalIdentifier"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"key"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"value"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateMyUserApplicationVariable"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"applicationUniversalIdentifier"},"value":{"kind":"Variable","name":{"kind":"Name","value":"applicationUniversalIdentifier"}}},{"kind":"Argument","name":{"kind":"Name","value":"key"},"value":{"kind":"Variable","name":{"kind":"Name","value":"key"}}},{"kind":"Argument","name":{"kind":"Name","value":"value"},"value":{"kind":"Variable","name":{"kind":"Name","value":"value"}}}]}]}}]} as unknown as DocumentNode<UpdateMyUserApplicationVariableMutation, UpdateMyUserApplicationVariableMutationVariables>;-export const MyApplicationPreferencesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"MyApplicationPreferences"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"myApplicationPreferences"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"applicationId"}},{"kind":"Field","name":{"kind":"Name","value":"settingsMenuItems"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"universalIdentifier"}},{"kind":"Field","name":{"kind":"Name","value":"applicationId"}},{"kind":"Field","name":{"kind":"Name","value":"frontComponentId"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"position"}},{"kind":"Field","name":{"kind":"Name","value":"scope"}}]}},{"kind":"Field","name":{"kind":"Name","value":"variables"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"key"}},{"kind":"Field","name":{"kind":"Name","value":"value"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"isSecret"}},{"kind":"Field","name":{"kind":"Name","value":"isDeprecated"}},{"kind":"Field","name":{"kind":"Name","value":"isRequired"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"options"}}]}}]}}]}}]} as unknown as DocumentNode<MyApplicationPreferencesQuery, MyApplicationPreferencesQueryVariables>;+export const MyApplicationPreferencesDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"MyApplicationPreferences"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"myApplicationPreferences"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"applicationId"}},{"kind":"Field","name":{"kind":"Name","value":"settingsMenuItems"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"universalIdentifier"}},{"kind":"Field","name":{"kind":"Name","value":"applicationId"}},{"kind":"Field","name":{"kind":"Name","value":"frontComponentId"}},{"kind":"Field","name":{"kind":"Name","value":"title"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}},{"kind":"Field","name":{"kind":"Name","value":"position"}},{"kind":"Field","name":{"kind":"Name","value":"scope"}}]}},{"kind":"Field","name":{"kind":"Name","value":"variables"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"key"}},{"kind":"Field","name":{"kind":"Name","value":"value"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"isSecret"}},{"kind":"Field","name":{"kind":"Name","value":"isDeprecated"}},{"kind":"Field","name":{"kind":"Name","value":"isRequired"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"options"}}]}},{"kind":"Field","name":{"kind":"Name","value":"connectionProviders"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"ApplicationConnectionProviderFragment"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ApplicationConnectionProviderFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ApplicationConnectionProvider"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"applicationId"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"scope"}},{"kind":"Field","name":{"kind":"Name","value":"logoUrl"}},{"kind":"Field","name":{"kind":"Name","value":"oauth"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"scopes"}},{"kind":"Field","name":{"kind":"Name","value":"isClientCredentialsConfigured"}}]}}]}}]} as unknown as DocumentNode<MyApplicationPreferencesQuery, MyApplicationPreferencesQueryVariables>;export const ClaimApplicationRegistrationOwnershipDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"ClaimApplicationRegistrationOwnership"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"applicationRegistrationId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"claimApplicationRegistrationOwnership"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"applicationRegistrationId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"applicationRegistrationId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}}]}}]}}]} as unknown as DocumentNode<ClaimApplicationRegistrationOwnershipMutation, ClaimApplicationRegistrationOwnershipMutationVariables>;export const DeleteApplicationRegistrationDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"DeleteApplicationRegistration"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"deleteApplicationRegistration"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}]}]}}]} as unknown as DocumentNode<DeleteApplicationRegistrationMutation, DeleteApplicationRegistrationMutationVariables>;export const RotateApplicationRegistrationClientSecretDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"RotateApplicationRegistrationClientSecret"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"rotateApplicationRegistrationClientSecret"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"clientSecret"}}]}}]}}]} as unknown as DocumentNode<RotateApplicationRegistrationClientSecretMutation, RotateApplicationRegistrationClientSecretMutationVariables>;@@ -11620,8 +11624,8 @@ export const TriggerUninstallApplicationDocument = {"kind":"Document","definitioexport const UninstallApplicationDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UninstallApplication"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"uninstallApplication"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"universalIdentifier"},"value":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}}}]}]}}]} as unknown as DocumentNode<UninstallApplicationMutation, UninstallApplicationMutationVariables>;export const UpdateApplicationDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateApplication"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"id"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UpdateApplicationInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateApplication"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"id"},"value":{"kind":"Variable","name":{"kind":"Name","value":"id"}}},{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"autoUpgrade"}}]}}]}}]} as unknown as DocumentNode<UpdateApplicationMutation, UpdateApplicationMutationVariables>;export const UpdateOneApplicationVariableDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"UpdateOneApplicationVariable"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"key"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"value"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"applicationId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"updateOneApplicationVariable"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"key"},"value":{"kind":"Variable","name":{"kind":"Name","value":"key"}}},{"kind":"Argument","name":{"kind":"Name","value":"value"},"value":{"kind":"Variable","name":{"kind":"Name","value":"value"}}},{"kind":"Argument","name":{"kind":"Name","value":"applicationId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"applicationId"}}}]}]}}]} as unknown as DocumentNode<UpdateOneApplicationVariableMutation, UpdateOneApplicationVariableMutationVariables>;-export const ApplicationConnectedAccountsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"ApplicationConnectedAccounts"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"applicationId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"applicationConnectedAccounts"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"applicationId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"applicationId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"handle"}},{"kind":"Field","name":{"kind":"Name","value":"authFailedAt"}},{"kind":"Field","name":{"kind":"Name","value":"authFailedReason"}},{"kind":"Field","name":{"kind":"Name","value":"scopes"}},{"kind":"Field","name":{"kind":"Name","value":"lastSignedInAt"}},{"kind":"Field","name":{"kind":"Name","value":"connectionProviderId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"scope"}},{"kind":"Field","name":{"kind":"Name","value":"lastCredentialsRefreshedAt"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<ApplicationConnectedAccountsQuery, ApplicationConnectedAccountsQueryVariables>;-export const ApplicationConnectionProvidersDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"ApplicationConnectionProviders"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"applicationId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"applicationConnectionProviders"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"applicationId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"applicationId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"applicationId"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"scope"}},{"kind":"Field","name":{"kind":"Name","value":"logoUrl"}},{"kind":"Field","name":{"kind":"Name","value":"oauth"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"scopes"}},{"kind":"Field","name":{"kind":"Name","value":"isClientCredentialsConfigured"}}]}}]}}]}}]} as unknown as DocumentNode<ApplicationConnectionProvidersQuery, ApplicationConnectionProvidersQueryVariables>;+export const ApplicationConnectedAccountsDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"ApplicationConnectedAccounts"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"applicationId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"applicationConnectedAccounts"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"applicationId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"applicationId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"handle"}},{"kind":"Field","name":{"kind":"Name","value":"authFailedAt"}},{"kind":"Field","name":{"kind":"Name","value":"authFailedReason"}},{"kind":"Field","name":{"kind":"Name","value":"archivedAt"}},{"kind":"Field","name":{"kind":"Name","value":"scopes"}},{"kind":"Field","name":{"kind":"Name","value":"lastSignedInAt"}},{"kind":"Field","name":{"kind":"Name","value":"connectionProviderId"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"scope"}},{"kind":"Field","name":{"kind":"Name","value":"lastCredentialsRefreshedAt"}},{"kind":"Field","name":{"kind":"Name","value":"createdAt"}},{"kind":"Field","name":{"kind":"Name","value":"updatedAt"}}]}}]}}]} as unknown as DocumentNode<ApplicationConnectedAccountsQuery, ApplicationConnectedAccountsQueryVariables>;+export const ApplicationConnectionProvidersDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"ApplicationConnectionProviders"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"applicationId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"applicationConnectionProviders"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"applicationId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"applicationId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"ApplicationConnectionProviderFragment"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ApplicationConnectionProviderFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ApplicationConnectionProvider"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"applicationId"}},{"kind":"Field","name":{"kind":"Name","value":"type"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"displayName"}},{"kind":"Field","name":{"kind":"Name","value":"scope"}},{"kind":"Field","name":{"kind":"Name","value":"logoUrl"}},{"kind":"Field","name":{"kind":"Name","value":"oauth"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"scopes"}},{"kind":"Field","name":{"kind":"Name","value":"isClientCredentialsConfigured"}}]}}]}}]} as unknown as DocumentNode<ApplicationConnectionProvidersQuery, ApplicationConnectionProvidersQueryVariables>;export const FindUninstallApplicationJobStatusDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"FindUninstallApplicationJobStatus"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"jobId"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"findUninstallApplicationJobStatus"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"universalIdentifier"},"value":{"kind":"Variable","name":{"kind":"Name","value":"universalIdentifier"}}},{"kind":"Argument","name":{"kind":"Name","value":"jobId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"jobId"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"jobId"}},{"kind":"Field","name":{"kind":"Name","value":"state"}},{"kind":"Field","name":{"kind":"Name","value":"failedReason"}},{"kind":"Field","name":{"kind":"Name","value":"progress"}}]}}]}}]} as unknown as DocumentNode<FindUninstallApplicationJobStatusQuery, FindUninstallApplicationJobStatusQueryVariables>;export const CancelSwitchBillingIntervalDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CancelSwitchBillingInterval"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cancelSwitchBillingInterval"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currentBillingSubscription"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CurrentBillingSubscriptionFragment"}}]}},{"kind":"Field","name":{"kind":"Name","value":"billingSubscriptions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingSubscriptionFragment"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseItemFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseItem"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"price"}},{"kind":"Field","name":{"kind":"Name","value":"quantity"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhase"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"start_date"}},{"kind":"Field","name":{"kind":"Name","value":"end_date"}},{"kind":"Field","name":{"kind":"Name","value":"items"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseItemFragment"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CurrentBillingSubscriptionFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingSubscription"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"interval"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"}},{"kind":"Field","name":{"kind":"Name","value":"currentPeriodEnd"}},{"kind":"Field","name":{"kind":"Name","value":"cancelAt"}},{"kind":"Field","name":{"kind":"Name","value":"collectionMethod"}},{"kind":"Field","name":{"kind":"Name","value":"hasUserCredits"}},{"kind":"Field","name":{"kind":"Name","value":"phases"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseFragment"}}]}},{"kind":"Field","name":{"kind":"Name","value":"billingSubscriptionItems"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"hasReachedCurrentPeriodCap"}},{"kind":"Field","name":{"kind":"Name","value":"quantity"}},{"kind":"Field","name":{"kind":"Name","value":"stripePriceId"}},{"kind":"Field","name":{"kind":"Name","value":"unitAmount"}},{"kind":"Field","name":{"kind":"Name","value":"creditAmount"}},{"kind":"Field","name":{"kind":"Name","value":"billingProduct"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"images"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"productKey"}},{"kind":"Field","name":{"kind":"Name","value":"planKey"}},{"kind":"Field","name":{"kind":"Name","value":"priceUsageBased"}},{"kind":"Field","name":{"kind":"Name","value":"isLegacy"}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BillingSubscriptionFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingSubscription"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"}},{"kind":"Field","name":{"kind":"Name","value":"cancelAt"}},{"kind":"Field","name":{"kind":"Name","value":"phases"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseFragment"}}]}}]}}]} as unknown as DocumentNode<CancelSwitchBillingIntervalMutation, CancelSwitchBillingIntervalMutationVariables>;export const CancelSwitchBillingPlanDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CancelSwitchBillingPlan"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"cancelSwitchBillingPlan"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"currentBillingSubscription"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"CurrentBillingSubscriptionFragment"}}]}},{"kind":"Field","name":{"kind":"Name","value":"billingSubscriptions"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingSubscriptionFragment"}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseItemFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseItem"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"price"}},{"kind":"Field","name":{"kind":"Name","value":"quantity"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhase"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"start_date"}},{"kind":"Field","name":{"kind":"Name","value":"end_date"}},{"kind":"Field","name":{"kind":"Name","value":"items"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseItemFragment"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"CurrentBillingSubscriptionFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingSubscription"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"interval"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"}},{"kind":"Field","name":{"kind":"Name","value":"currentPeriodEnd"}},{"kind":"Field","name":{"kind":"Name","value":"cancelAt"}},{"kind":"Field","name":{"kind":"Name","value":"collectionMethod"}},{"kind":"Field","name":{"kind":"Name","value":"hasUserCredits"}},{"kind":"Field","name":{"kind":"Name","value":"phases"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseFragment"}}]}},{"kind":"Field","name":{"kind":"Name","value":"billingSubscriptionItems"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"hasReachedCurrentPeriodCap"}},{"kind":"Field","name":{"kind":"Name","value":"quantity"}},{"kind":"Field","name":{"kind":"Name","value":"stripePriceId"}},{"kind":"Field","name":{"kind":"Name","value":"unitAmount"}},{"kind":"Field","name":{"kind":"Name","value":"creditAmount"}},{"kind":"Field","name":{"kind":"Name","value":"billingProduct"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"images"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"productKey"}},{"kind":"Field","name":{"kind":"Name","value":"planKey"}},{"kind":"Field","name":{"kind":"Name","value":"priceUsageBased"}},{"kind":"Field","name":{"kind":"Name","value":"isLegacy"}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BillingSubscriptionFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingSubscription"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"status"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"}},{"kind":"Field","name":{"kind":"Name","value":"cancelAt"}},{"kind":"Field","name":{"kind":"Name","value":"phases"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingSubscriptionSchedulePhaseFragment"}}]}}]}}]} as unknown as DocumentNode<CancelSwitchBillingPlanMutation, CancelSwitchBillingPlanMutationVariables>;diff --git a/packages/twenty-front/src/modules/settings/accounts/hooks/useMyConnectedAccounts.ts b/packages/twenty-front/src/modules/settings/accounts/hooks/useMyConnectedAccounts.tsindex ecfaf5b186a..aa86c4d2137 100644--- a/packages/twenty-front/src/modules/settings/accounts/hooks/useMyConnectedAccounts.ts+++ b/packages/twenty-front/src/modules/settings/accounts/hooks/useMyConnectedAccounts.ts@@ -29,7 +29,12 @@ export const useMyConnectedAccounts = ({} = {}) => {const apolloClient = useApolloClient();- const { data, loading: accountsLoading } = useQuery<{+ const {+ data,+ loading: accountsLoading,+ error,+ refetch,+ } = useQuery<{myConnectedAccounts: CoreConnectedAccount[];}>(GET_MY_CONNECTED_ACCOUNTS, {client: apolloClient,@@ -62,5 +67,7 @@ export const useMyConnectedAccounts = ({accounts,loading:accountsLoading || messageChannelsLoading || calendarChannelsLoading,+ error,+ refetch,};};diff --git a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAppStatusCell.tsx b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAppStatusCell.tsxindex 0fd9fcbf1c4..f4e5413b0f4 100644--- a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAppStatusCell.tsx+++ b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAppStatusCell.tsx@@ -1,6 +1,7 @@import { useMyAccountGroups } from '@/settings/app-preferences/hooks/useMyAccountGroups';import { type AppPreferencesRow } from '@/settings/app-preferences/types/AppPreferencesRow';import { getBuiltInAccountAppsUsingAccount } from '@/settings/app-preferences/utils/getBuiltInAccountAppsUsingAccount';+import { canStartConnectionProviderAuthorization } from '@/settings/applications/utils/canStartConnectionProviderAuthorization';import { useLingui } from '@lingui/react/macro';import { isNonEmptyArray } from 'twenty-shared/utils';import { Status } from 'twenty-ui/primitives/data-display';@@ -16,13 +17,31 @@ export const SettingsAppPreferencesAppStatusCell = ({const { groups, loading } = useMyAccountGroups();if (item.type === 'installed') {+ const { application, connectionProviders, missingRequiredVariables } =+ item.applicationWithPreferences;++ if (isNonEmptyArray(missingRequiredVariables)) {+ return <Status color="red">{t`Missing configuration`}</Status>;+ }++ const applicationAccounts = groups.flatMap((group) =>+ group.appAccounts.filter(+ (account) => account.applicationId === application.id,+ ),+ );+ const hasConfiguredProvider = connectionProviders.some(+ canStartConnectionProviderAuthorization,+ );+if (- !isNonEmptyArray(item.applicationWithPreferences.missingRequiredVariables)+ loading ||+ !hasConfiguredProvider ||+ isNonEmptyArray(applicationAccounts)) {return null;}- return <Status color="red">{t`Missing configuration`}</Status>;+ return <Status color="red">{t`Missing account`}</Status>;}const hasAccount = groups.some((group) =>diff --git a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesConnectionRowDropdownMenu.tsx b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesConnectionRowDropdownMenu.tsxnew file mode 100644index 00000000000..76a54ecc23c--- /dev/null+++ b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesConnectionRowDropdownMenu.tsx@@ -0,0 +1,80 @@+import { type ConnectedAccount } from '@/accounts/types/ConnectedAccount';+import { SettingsAppPreferencesRemoveConnectionDialog } from '@/settings/app-preferences/components/SettingsAppPreferencesRemoveConnectionDialog';+import { SettingsApplicationConnectionName } from '@/settings/applications/components/SettingsApplicationConnectionName';+import { getApplicationPreferencesConnectionsPath } from '@/settings/app-preferences/utils/getApplicationPreferencesConnectionsPath';+import { useTriggerAppOAuth } from '@/settings/applications/hooks/useTriggerAppOAuth';+import { isApplicationConnectionReconnectNeeded } from '@/settings/applications/utils/isApplicationConnectionReconnectNeeded';+import { useDialog } from '@/ui/layout/dialog/hooks/useDialog';+import { DropdownContent } from '@/ui/layout/dropdown/components/DropdownContent';+import { DropdownRoot } from '@/ui/layout/dropdown/components/DropdownRoot';+import { useLingui } from '@lingui/react/macro';+import { LightIconButton } from 'twenty-ui/components/input';+import { Dropdown } from 'twenty-ui/components/navigation';+import { IconDotsVertical, IconRefresh, IconTrash } from 'twenty-ui/icon';++type SettingsAppPreferencesConnectionRowDropdownMenuProps = {+ applicationId: string;+ providerName: string;+ connection: ConnectedAccount;+ canStartAuthorization: boolean;+};++export const SettingsAppPreferencesConnectionRowDropdownMenu = ({+ applicationId,+ providerName,+ connection,+ canStartAuthorization,+}: SettingsAppPreferencesConnectionRowDropdownMenuProps) => {+ const { t } = useLingui();+ const { triggerAppOAuth } = useTriggerAppOAuth();+ const { openDialog } = useDialog();+ const removeDialogId = `remove-app-connection-modal-${connection.id}`;++ return (+ <>+ <DropdownRoot+ type="menu"+ dropdownId={`settings-app-connection-row-${connection.id}`}+ >+ <Dropdown.Trigger+ render={+ <LightIconButton emphasis="subtle" aria-label={t`More options`}>+ <IconDotsVertical />+ </LightIconButton>+ }+ />+ <DropdownContent side="right" align="start">+ <Dropdown.Section>+ {canStartAuthorization &&+ isApplicationConnectionReconnectNeeded(connection) && (+ <Dropdown.ActionItem+ startIcon={<IconRefresh />}+ onClick={() =>+ triggerAppOAuth({+ applicationId,+ providerName,+ reconnectingConnectedAccountId: connection.id,+ redirectLocation:+ getApplicationPreferencesConnectionsPath(applicationId),+ })+ }+ >{t`Reconnect`}</Dropdown.ActionItem>+ )}+ <Dropdown.ActionItem+ color="danger"+ startIcon={<IconTrash />}+ onClick={() => openDialog(removeDialogId)}+ >{t`Remove`}</Dropdown.ActionItem>+ </Dropdown.Section>+ </DropdownContent>+ </DropdownRoot>+ <SettingsAppPreferencesRemoveConnectionDialog+ dialogId={removeDialogId}+ connectedAccountId={connection.id}+ connectionLabel={+ <SettingsApplicationConnectionName connection={connection} />+ }+ />+ </>+ );+};diff --git a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesConnectionsTab.tsx b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesConnectionsTab.tsxnew file mode 100644index 00000000000..34e9822391d--- /dev/null+++ b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesConnectionsTab.tsx@@ -0,0 +1,96 @@+import { SettingsAppPreferencesConnectionsTable } from '@/settings/app-preferences/components/SettingsAppPreferencesConnectionsTable';+import { useMyPersonalConnectedAccounts } from '@/settings/app-preferences/hooks/useMyPersonalConnectedAccounts';+import { type ApplicationWithPreferences } from '@/settings/app-preferences/types/ApplicationWithPreferences';+import { getApplicationPreferencesConnectionsPath } from '@/settings/app-preferences/utils/getApplicationPreferencesConnectionsPath';+import { SettingsApplicationAddConnectionButton } from '@/settings/applications/components/SettingsApplicationAddConnectionButton';+import { SettingsApplicationConnectionProviderSection } from '@/settings/applications/components/SettingsApplicationConnectionProviderSection';+import { SettingsApplicationLoadErrorBanner } from '@/settings/applications/components/SettingsApplicationLoadErrorBanner';+import { canStartConnectionProviderAuthorization } from '@/settings/applications/utils/canStartConnectionProviderAuthorization';+import { styled } from '@linaria/react';+import { useLingui } from '@lingui/react/macro';+import { ConnectedAccountProvider } from 'twenty-shared/types';+import { isDefined, isNonEmptyArray } from 'twenty-shared/utils';+import { themeCssVariables } from 'twenty-ui/theme';++const APP_CONNECTED_ACCOUNT_PROVIDERS: ReadonlySet<ConnectedAccountProvider> =+ new Set([ConnectedAccountProvider.APP]);++const StyledEmptyState = styled.div`+ color: ${themeCssVariables.font.color.tertiary};+ font-size: ${themeCssVariables.font.size.md};+`;++type SettingsAppPreferencesConnectionsTabProps = {+ applicationId: string;+ connectionProviders: ApplicationWithPreferences['connectionProviders'];+};++export const SettingsAppPreferencesConnectionsTab = ({+ applicationId,+ connectionProviders,+}: SettingsAppPreferencesConnectionsTabProps) => {+ const { t } = useLingui();+ const {+ accounts: personalAccounts,+ loading,+ error,+ refetch,+ } = useMyPersonalConnectedAccounts({+ providers: APP_CONNECTED_ACCOUNT_PROVIDERS,+ });++ return (+ <>+ {connectionProviders.map((provider) => {+ const canStartAuthorization =+ canStartConnectionProviderAuthorization(provider);++ const providerConnections = personalAccounts.filter(+ (account) => account.connectionProviderId === provider.id,+ );++ return (+ <SettingsApplicationConnectionProviderSection+ key={provider.id}+ providerDisplayName={provider.displayName}+ providerLogoUrl={provider.logoUrl}+ description={t`Connect your own ${provider.displayName} account for this app to use on your behalf.`}+ shouldShowMissingCredentialsBanner={!canStartAuthorization}+ >+ {isDefined(error) ? (+ <SettingsApplicationLoadErrorBanner+ message={t`Your connections could not be loaded. Check your connection and try again.`}+ onRetry={() => refetch().catch(() => undefined)}+ />+ ) : (+ <>+ {loading || isNonEmptyArray(providerConnections) ? (+ <SettingsAppPreferencesConnectionsTable+ applicationId={applicationId}+ providerName={provider.name}+ connections={providerConnections}+ canStartAuthorization={canStartAuthorization}+ isLoading={loading}+ />+ ) : (+ canStartAuthorization && (+ <StyledEmptyState>{t`You have no ${provider.displayName} connection yet.`}</StyledEmptyState>+ )+ )}+ {canStartAuthorization && (+ <SettingsApplicationAddConnectionButton+ applicationId={applicationId}+ providerName={provider.name}+ redirectLocation={getApplicationPreferencesConnectionsPath(+ applicationId,+ )}+ />+ )}+ </>+ )}+ </SettingsApplicationConnectionProviderSection>+ );+ })}+ </>+ );+};diff --git a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesConnectionsTable.tsx b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesConnectionsTable.tsxnew file mode 100644index 00000000000..c07bb85775c--- /dev/null+++ b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesConnectionsTable.tsx@@ -0,0 +1,80 @@+import { type ConnectedAccount } from '@/accounts/types/ConnectedAccount';+import { SettingsAppPreferencesConnectionRowDropdownMenu } from '@/settings/app-preferences/components/SettingsAppPreferencesConnectionRowDropdownMenu';+import { SettingsApplicationConnectionName } from '@/settings/applications/components/SettingsApplicationConnectionName';+import { SettingsApplicationConnectionStatus } from '@/settings/applications/components/SettingsApplicationConnectionStatus';+import { SettingsApplicationConnectionTableRows } from '@/settings/applications/components/SettingsApplicationConnectionTableRows';+import { SettingsTableRowsSkeletonLoader } from '@/settings/components/SettingsTableRowsSkeletonLoader';+import { Table } from '@/ui/layout/table/components/Table';+import { TableCell } from '@/ui/layout/table/components/TableCell';+import { TableHeader } from '@/ui/layout/table/components/TableHeader';+import { TableRow } from '@/ui/layout/table/components/TableRow';+import { useLingui } from '@lingui/react/macro';+import { themeCssVariables } from 'twenty-ui/theme';++const CONNECTION_TABLE_ROW_GRID_TEMPLATE_COLUMNS = `minmax(0, 1fr) auto ${themeCssVariables.spacing[8]}`;++type SettingsAppPreferencesConnectionsTableProps = {+ applicationId: string;+ providerName: string;+ connections: ConnectedAccount[];+ canStartAuthorization: boolean;+ isLoading: boolean;+};++export const SettingsAppPreferencesConnectionsTable = ({+ applicationId,+ providerName,+ connections,+ canStartAuthorization,+ isLoading,+}: SettingsAppPreferencesConnectionsTableProps) => {+ const { t } = useLingui();++ return (+ <Table>+ <TableRow+ gridTemplateColumns={CONNECTION_TABLE_ROW_GRID_TEMPLATE_COLUMNS}+ >+ <TableHeader>{t`Connection`}</TableHeader>+ <TableHeader>{t`Status`}</TableHeader>+ <TableHeader />+ </TableRow>+ {isLoading ? (+ <SettingsTableRowsSkeletonLoader+ gridTemplateColumns={CONNECTION_TABLE_ROW_GRID_TEMPLATE_COLUMNS}+ columns={[{}, { width: 96 }, { align: 'right', width: 24 }]}+ />+ ) : (+ <SettingsApplicationConnectionTableRows>+ {connections.map((connection) => (+ <TableRow+ key={connection.id}+ gridTemplateColumns={CONNECTION_TABLE_ROW_GRID_TEMPLATE_COLUMNS}+ >+ <TableCell+ color={themeCssVariables.font.color.primary}+ minWidth="0"+ overflow="hidden"+ textOverflow="ellipsis"+ whiteSpace="nowrap"+ >+ <SettingsApplicationConnectionName connection={connection} />+ </TableCell>+ <TableCell whiteSpace="nowrap">+ <SettingsApplicationConnectionStatus connection={connection} />+ </TableCell>+ <TableCell align="right">+ <SettingsAppPreferencesConnectionRowDropdownMenu+ applicationId={applicationId}+ providerName={providerName}+ connection={connection}+ canStartAuthorization={canStartAuthorization}+ />+ </TableCell>+ </TableRow>+ ))}+ </SettingsApplicationConnectionTableRows>+ )}+ </Table>+ );+};diff --git a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesRemoveConnectionDialog.tsx b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesRemoveConnectionDialog.tsxnew file mode 100644index 00000000000..7c64d9d2713--- /dev/null+++ b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesRemoveConnectionDialog.tsx@@ -0,0 +1,51 @@+import { getToastOptionsFromError } from '@/error-handler/utils/getToastOptionsFromError';+import { DELETE_CONNECTED_ACCOUNT } from '@/settings/accounts/graphql/mutations/deleteConnectedAccount';+import { GET_MY_CONNECTED_ACCOUNTS } from '@/settings/accounts/graphql/queries/getMyConnectedAccounts';+import { ConfirmationDialog } from '@/ui/layout/dialog/components/ConfirmationDialog';+import { useMutation } from '@apollo/client/react';+import { Trans, useLingui } from '@lingui/react/macro';+import { type ReactNode } from 'react';+import { useToast } from 'twenty-ui/components/feedback';++type SettingsAppPreferencesRemoveConnectionDialogProps = {+ dialogId: string;+ connectedAccountId: string;+ connectionLabel: ReactNode;+};++export const SettingsAppPreferencesRemoveConnectionDialog = ({+ dialogId,+ connectedAccountId,+ connectionLabel,+}: SettingsAppPreferencesRemoveConnectionDialogProps) => {+ const { t } = useLingui();+ const { enqueueToast } = useToast();+ const [deleteConnectedAccount] = useMutation(DELETE_CONNECTED_ACCOUNT, {+ refetchQueries: [{ query: GET_MY_CONNECTED_ACCOUNTS }],+ awaitRefetchQueries: true,+ });++ return (+ <ConfirmationDialog+ dialogId={dialogId}+ title={t`Remove connection?`}+ subtitle={+ <Trans>+ This permanently removes {connectionLabel} from this application. The+ app loses access to it.+ </Trans>+ }+ onConfirmClick={async () => {+ try {+ await deleteConnectedAccount({+ variables: { id: connectedAccountId },+ });+ } catch (error) {+ enqueueToast(getToastOptionsFromError({ error }));+ }+ }}+ confirmButtonText={t`Remove`}+ shouldWaitForConfirmBeforeClosing+ />+ );+};diff --git a/packages/twenty-front/src/modules/settings/app-preferences/constants/ApplicationPreferencesConnectionsTabId.ts b/packages/twenty-front/src/modules/settings/app-preferences/constants/ApplicationPreferencesConnectionsTabId.tsnew file mode 100644index 00000000000..aa3b2b69318--- /dev/null+++ b/packages/twenty-front/src/modules/settings/app-preferences/constants/ApplicationPreferencesConnectionsTabId.ts@@ -0,0 +1 @@+export const APPLICATION_PREFERENCES_CONNECTIONS_TAB_ID = 'connections';diff --git a/packages/twenty-front/src/modules/settings/app-preferences/graphql/queries/myApplicationPreferences.ts b/packages/twenty-front/src/modules/settings/app-preferences/graphql/queries/myApplicationPreferences.tsindex 7cea3722bef..5e22d34b774 100644--- a/packages/twenty-front/src/modules/settings/app-preferences/graphql/queries/myApplicationPreferences.ts+++ b/packages/twenty-front/src/modules/settings/app-preferences/graphql/queries/myApplicationPreferences.ts@@ -1,6 +1,8 @@+import { APPLICATION_CONNECTION_PROVIDER_FRAGMENT } from '@/settings/applications/graphql/fragments/applicationConnectionProviderFragment';import { gql } from '@apollo/client';export const MY_APPLICATION_PREFERENCES = gql`+ ${APPLICATION_CONNECTION_PROVIDER_FRAGMENT}query MyApplicationPreferences {myApplicationPreferences {applicationId@@ -25,6 +27,9 @@ export const MY_APPLICATION_PREFERENCES = gql`typeoptions}+ connectionProviders {+ ...ApplicationConnectionProviderFragment+ }}}`;diff --git a/packages/twenty-front/src/modules/settings/app-preferences/hooks/useMyAccountGroups.ts b/packages/twenty-front/src/modules/settings/app-preferences/hooks/useMyAccountGroups.tsindex 8668e59e8c3..b23802c2459 100644--- a/packages/twenty-front/src/modules/settings/app-preferences/hooks/useMyAccountGroups.ts+++ b/packages/twenty-front/src/modules/settings/app-preferences/hooks/useMyAccountGroups.ts@@ -1,10 +1,6 @@-import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';-import { useMyConnectedAccounts } from '@/settings/accounts/hooks/useMyConnectedAccounts';+import { useMyPersonalConnectedAccounts } from '@/settings/app-preferences/hooks/useMyPersonalConnectedAccounts';import { groupConnectedAccountsByBuiltInAccount } from '@/settings/app-preferences/utils/groupConnectedAccountsByBuiltInAccount';-import { isPersonalConnectedAccount } from '@/settings/app-preferences/utils/isPersonalConnectedAccount';-import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';import { ConnectedAccountProvider } from 'twenty-shared/types';-import { isDefined } from 'twenty-shared/utils';const ACCOUNT_GROUP_PROVIDERS: ReadonlySet<ConnectedAccountProvider> = new Set([ConnectedAccountProvider.GOOGLE,@@ -14,21 +10,12 @@ const ACCOUNT_GROUP_PROVIDERS: ReadonlySet<ConnectedAccountProvider> = new Set([]);export const useMyAccountGroups = () => {- const currentWorkspaceMember = useAtomStateValue(currentWorkspaceMemberState);- const { accounts, loading } = useMyConnectedAccounts({+ const { accounts, loading } = useMyPersonalConnectedAccounts({providers: ACCOUNT_GROUP_PROVIDERS,});- const userWorkspaceId = currentWorkspaceMember?.userWorkspaceId;-- const personalAccounts = isDefined(userWorkspaceId)- ? accounts.filter((account) =>- isPersonalConnectedAccount({ account, userWorkspaceId }),- )- : [];-return {- groups: groupConnectedAccountsByBuiltInAccount(personalAccounts),+ groups: groupConnectedAccountsByBuiltInAccount(accounts),loading,};};diff --git a/packages/twenty-front/src/modules/settings/app-preferences/hooks/useMyPersonalConnectedAccounts.ts b/packages/twenty-front/src/modules/settings/app-preferences/hooks/useMyPersonalConnectedAccounts.tsnew file mode 100644index 00000000000..c41a515ac75--- /dev/null+++ b/packages/twenty-front/src/modules/settings/app-preferences/hooks/useMyPersonalConnectedAccounts.ts@@ -0,0 +1,27 @@+import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';+import { useMyConnectedAccounts } from '@/settings/accounts/hooks/useMyConnectedAccounts';+import { isPersonalConnectedAccount } from '@/settings/app-preferences/utils/isPersonalConnectedAccount';+import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';+import { type ConnectedAccountProvider } from 'twenty-shared/types';+import { isDefined } from 'twenty-shared/utils';++export const useMyPersonalConnectedAccounts = ({+ providers,+}: {+ providers: ReadonlySet<ConnectedAccountProvider>;+}) => {+ const currentWorkspaceMember = useAtomStateValue(currentWorkspaceMemberState);+ const { accounts, loading, error, refetch } = useMyConnectedAccounts({+ providers,+ });++ const userWorkspaceId = currentWorkspaceMember?.userWorkspaceId;++ const personalAccounts = isDefined(userWorkspaceId)+ ? accounts.filter((account) =>+ isPersonalConnectedAccount({ account, userWorkspaceId }),+ )+ : [];++ return { accounts: personalAccounts, loading, error, refetch };+};diff --git a/packages/twenty-front/src/modules/settings/app-preferences/types/ApplicationWithPreferences.ts b/packages/twenty-front/src/modules/settings/app-preferences/types/ApplicationWithPreferences.tsindex 657f6975fe8..d4249d6d9cb 100644--- a/packages/twenty-front/src/modules/settings/app-preferences/types/ApplicationWithPreferences.ts+++ b/packages/twenty-front/src/modules/settings/app-preferences/types/ApplicationWithPreferences.ts@@ -9,4 +9,5 @@ export type ApplicationWithPreferences = {settingsMenuItems: MyApplicationPreferences['settingsMenuItems'];variables: MyApplicationPreferences['variables'];missingRequiredVariables: MyApplicationPreferences['variables'];+ connectionProviders: MyApplicationPreferences['connectionProviders'];};diff --git a/packages/twenty-front/src/modules/settings/app-preferences/utils/__tests__/getApplicationsWithPreferences.test.ts b/packages/twenty-front/src/modules/settings/app-preferences/utils/__tests__/getApplicationsWithPreferences.test.tsindex 7a27a6518f4..f8722909cd8 100644--- a/packages/twenty-front/src/modules/settings/app-preferences/utils/__tests__/getApplicationsWithPreferences.test.ts+++ b/packages/twenty-front/src/modules/settings/app-preferences/utils/__tests__/getApplicationsWithPreferences.test.ts@@ -1,5 +1,8 @@import { getApplicationsWithPreferences } from '@/settings/app-preferences/utils/getApplicationsWithPreferences';-import { SettingsMenuItemScope } from '~/generated-metadata/graphql';+import {+ ConnectionProviderScope,+ SettingsMenuItemScope,+} from '~/generated-metadata/graphql';const RECORDER_APPLICATION_ID = 'recorder-application-id';const NOTETAKER_APPLICATION_ID = 'notetaker-application-id';@@ -64,6 +67,21 @@ const buildVariable = ({options: null,});+const buildUserConnectionProvider = ({+ applicationId,+}: {+ applicationId: string;+}) => ({+ id: `${applicationId}-connection-provider-id`,+ applicationId,+ type: 'oauth',+ name: 'linear',+ displayName: 'Linear',+ scope: ConnectionProviderScope.USER,+ logoUrl: null,+ oauth: { scopes: ['read'], isClientCredentialsConfigured: true },+});+const CURRENT_WORKSPACE = {installedApplications: [buildInstalledApplication({@@ -86,11 +104,13 @@ describe('getApplicationsWithPreferences', () => {applicationId: RECORDER_APPLICATION_ID,settingsMenuItems: [],variables: [buildVariable({ key: 'RECORD_MY_MEETINGS' })],+ connectionProviders: [],},{applicationId: NOTETAKER_APPLICATION_ID,settingsMenuItems: [],variables: [buildVariable({ key: 'LANGUAGE', value: 'en' })],+ connectionProviders: [],},],currentWorkspace: CURRENT_WORKSPACE,@@ -122,6 +142,7 @@ describe('getApplicationsWithPreferences', () => {}),],variables: [],+ connectionProviders: [],},],currentWorkspace: CURRENT_WORKSPACE,@@ -149,6 +170,7 @@ describe('getApplicationsWithPreferences', () => {isDeprecated: true,}),],+ connectionProviders: [],},],currentWorkspace: CURRENT_WORKSPACE,@@ -187,6 +209,7 @@ describe('getApplicationsWithPreferences', () => {isDeprecated: true,}),],+ connectionProviders: [],},],currentWorkspace: CURRENT_WORKSPACE,@@ -211,6 +234,7 @@ describe('getApplicationsWithPreferences', () => {isSecret: true,}),],+ connectionProviders: [],},],currentWorkspace: CURRENT_WORKSPACE,@@ -228,6 +252,7 @@ describe('getApplicationsWithPreferences', () => {applicationId: RECORDER_APPLICATION_ID,settingsMenuItems: [],variables: [buildVariable({ key: 'OLD_FLAG', isDeprecated: true })],+ connectionProviders: [],},],currentWorkspace: CURRENT_WORKSPACE,@@ -236,6 +261,29 @@ describe('getApplicationsWithPreferences', () => {expect(result).toEqual([]);});+ it('should keep an application whose only preference is a connection provider', () => {+ const [result] = getApplicationsWithPreferences({+ applicationPreferences: [+ {+ applicationId: RECORDER_APPLICATION_ID,+ settingsMenuItems: [],+ variables: [],+ connectionProviders: [+ buildUserConnectionProvider({+ applicationId: RECORDER_APPLICATION_ID,+ }),+ ],+ },+ ],+ currentWorkspace: CURRENT_WORKSPACE,+ });++ expect(result.application.id).toBe(RECORDER_APPLICATION_ID);+ expect(result.connectionProviders.map(({ name }) => name)).toEqual([+ 'linear',+ ]);+ });+it('should leave out an application that is not installed', () => {const result = getApplicationsWithPreferences({applicationPreferences: [@@ -243,6 +291,7 @@ describe('getApplicationsWithPreferences', () => {applicationId: UNINSTALLED_APPLICATION_ID,settingsMenuItems: [],variables: [buildVariable({ key: 'LANGUAGE', value: 'en' })],+ connectionProviders: [],},],currentWorkspace: CURRENT_WORKSPACE,diff --git a/packages/twenty-front/src/modules/settings/app-preferences/utils/getApplicationPreferencesConnectionsPath.ts b/packages/twenty-front/src/modules/settings/app-preferences/utils/getApplicationPreferencesConnectionsPath.tsnew file mode 100644index 00000000000..4cbae4291e1--- /dev/null+++ b/packages/twenty-front/src/modules/settings/app-preferences/utils/getApplicationPreferencesConnectionsPath.ts@@ -0,0 +1,13 @@+import { APPLICATION_PREFERENCES_CONNECTIONS_TAB_ID } from '@/settings/app-preferences/constants/ApplicationPreferencesConnectionsTabId';+import { SettingsPath } from 'twenty-shared/types';+import { getSettingsPath } from 'twenty-shared/utils';++export const getApplicationPreferencesConnectionsPath = (+ applicationId: string,+) =>+ getSettingsPath(+ SettingsPath.ApplicationPreferences,+ { applicationId },+ undefined,+ APPLICATION_PREFERENCES_CONNECTIONS_TAB_ID,+ );diff --git a/packages/twenty-front/src/modules/settings/app-preferences/utils/getApplicationsWithPreferences.ts b/packages/twenty-front/src/modules/settings/app-preferences/utils/getApplicationsWithPreferences.tsindex 9b74b9f0028..638985164c0 100644--- a/packages/twenty-front/src/modules/settings/app-preferences/utils/getApplicationsWithPreferences.ts+++ b/packages/twenty-front/src/modules/settings/app-preferences/utils/getApplicationsWithPreferences.ts@@ -25,30 +25,40 @@ export const getApplicationsWithPreferences = ({getApplicationDisplayName({ application, currentWorkspace });return applicationPreferences- .flatMap(({ applicationId, settingsMenuItems, variables }) => {- const application = installedApplications.find(- (installedApplication) => installedApplication.id === applicationId,- );- const displayedVariables = getDisplayedApplicationVariables(variables);+ .flatMap(+ ({+ applicationId,+ settingsMenuItems,+ variables,+ connectionProviders,+ }) => {+ const application = installedApplications.find(+ (installedApplication) => installedApplication.id === applicationId,+ );+ const displayedVariables = getDisplayedApplicationVariables(variables);- if (- !isDefined(application) ||- (!isNonEmptyArray(settingsMenuItems) &&- !isNonEmptyArray(displayedVariables))- ) {- return [];- }+ if (+ !isDefined(application) ||+ (!isNonEmptyArray(settingsMenuItems) &&+ !isNonEmptyArray(displayedVariables) &&+ !isNonEmptyArray(connectionProviders))+ ) {+ return [];+ }- return [- {- application,- settingsMenuItems: sortSettingsMenuItemsByPosition(settingsMenuItems),- variables: displayedVariables,- missingRequiredVariables:- getMissingRequiredApplicationVariables(displayedVariables),- },- ];- })+ return [+ {+ application,+ settingsMenuItems:+ sortSettingsMenuItemsByPosition(settingsMenuItems),+ variables: displayedVariables,+ missingRequiredVariables:+ getMissingRequiredApplicationVariables(displayedVariables),+ connectionProviders,+ },+ ];+ },+ ).sort((applicationWithPreferencesA, applicationWithPreferencesB) =>getDisplayName(applicationWithPreferencesA).localeCompare(diff --git a/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationAddConnectionButton.tsx b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationAddConnectionButton.tsxnew file mode 100644index 00000000000..17f83cd5d94--- /dev/null+++ b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationAddConnectionButton.tsx@@ -0,0 +1,44 @@+import { useTriggerAppOAuth } from '@/settings/applications/hooks/useTriggerAppOAuth';+import { styled } from '@linaria/react';+import { useLingui } from '@lingui/react/macro';+import { IconPlus } from 'twenty-ui/icon';+import { Button } from 'twenty-ui/primitives/input';+import { themeCssVariables } from 'twenty-ui/theme';++const StyledFooter = styled.div`+ display: flex;+ justify-content: flex-end;+ margin-top: ${themeCssVariables.spacing[2]};+`;++type SettingsApplicationAddConnectionButtonProps = {+ applicationId: string;+ providerName: string;+ redirectLocation?: string;+};++export const SettingsApplicationAddConnectionButton = ({+ applicationId,+ providerName,+ redirectLocation,+}: SettingsApplicationAddConnectionButtonProps) => {+ const { t } = useLingui();+ const { triggerAppOAuth } = useTriggerAppOAuth();++ return (+ <StyledFooter>+ <Button+ startIcon={<IconPlus />}+ size="sm"+ onClick={() =>+ triggerAppOAuth({+ applicationId,+ providerName,+ redirectLocation,+ })+ }+ variant="outline"+ >{t`Add connection`}</Button>+ </StyledFooter>+ );+};diff --git a/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationConnectionName.tsx b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationConnectionName.tsxnew file mode 100644index 00000000000..e0fae6d9bb5--- /dev/null+++ b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationConnectionName.tsx@@ -0,0 +1,27 @@+import { styled } from '@linaria/react';+import { isNonEmptyString } from '@sniptt/guards';+import { themeCssVariables } from 'twenty-ui/theme';++const StyledHandle = styled.span`+ color: ${themeCssVariables.font.color.tertiary};+ margin-left: ${themeCssVariables.spacing[1]};+`;++type SettingsApplicationConnectionNameProps = {+ connection: { name?: string | null; handle: string };+};++export const SettingsApplicationConnectionName = ({+ connection: { name, handle },+}: SettingsApplicationConnectionNameProps) => {+ if (!isNonEmptyString(name) || name === handle) {+ return handle;+ }++ return (+ <>+ {name}+ <StyledHandle>{handle}</StyledHandle>+ </>+ );+};diff --git a/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationConnectionProviderSection.tsx b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationConnectionProviderSection.tsxnew file mode 100644index 00000000000..fcedd5fe35e--- /dev/null+++ b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationConnectionProviderSection.tsx@@ -0,0 +1,52 @@+import { useLingui } from '@lingui/react/macro';+import { isNonEmptyString } from '@sniptt/guards';+import { type ReactNode } from 'react';+import { InlineBanner } from 'twenty-ui/components/feedback';+import { Section } from 'twenty-ui/components/layout';+import { Avatar } from 'twenty-ui/primitives/data-display';+import { getAbsoluteImageUrl } from '~/utils/image/getAbsoluteImageUrl';++type SettingsApplicationConnectionProviderSectionProps = {+ providerDisplayName: string;+ providerLogoUrl?: string | null;+ description: string;+ shouldShowMissingCredentialsBanner: boolean;+ children: ReactNode;+};++export const SettingsApplicationConnectionProviderSection = ({+ providerDisplayName,+ providerLogoUrl,+ description,+ shouldShowMissingCredentialsBanner,+ children,+}: SettingsApplicationConnectionProviderSectionProps) => {+ const { t } = useLingui();++ return (+ <Section.Root>+ <Section.Header+ title={providerDisplayName}+ description={description}+ actions={+ isNonEmptyString(providerLogoUrl) ? (+ <Avatar+ shape="square"+ variant="outline"+ src={getAbsoluteImageUrl(providerLogoUrl)}+ name={providerDisplayName}+ />+ ) : undefined+ }+ />+ {shouldShowMissingCredentialsBanner && (+ <InlineBanner+ layout="compact"+ status="error"+ fullWidth+ >{t`${providerDisplayName} OAuth is not yet set up by your server administrator. They need to fill in the OAuth client ID and secret on the application registration before you can add a connection.`}</InlineBanner>+ )}+ {children}+ </Section.Root>+ );+};diff --git a/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationConnectionStatus.tsx b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationConnectionStatus.tsxnew file mode 100644index 00000000000..ea83a23fe37--- /dev/null+++ b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationConnectionStatus.tsx@@ -0,0 +1,25 @@+import { type ConnectedAccount } from '@/accounts/types/ConnectedAccount';+import { isApplicationConnectionReconnectNeeded } from '@/settings/applications/utils/isApplicationConnectionReconnectNeeded';+import { useLingui } from '@lingui/react/macro';+import { isDefined } from 'twenty-shared/utils';+import { Status } from 'twenty-ui/primitives/data-display';++type SettingsApplicationConnectionStatusProps = {+ connection: Partial<Pick<ConnectedAccount, 'authFailedAt' | 'archivedAt'>>;+};++export const SettingsApplicationConnectionStatus = ({+ connection,+}: SettingsApplicationConnectionStatusProps) => {+ const { t } = useLingui();++ if (isDefined(connection.archivedAt)) {+ return <Status color="gray">{t`Disconnected`}</Status>;+ }++ return isApplicationConnectionReconnectNeeded(connection) ? (+ <Status color="red">{t`Reconnect needed`}</Status>+ ) : (+ <Status color="green">{t`Connected`}</Status>+ );+};diff --git a/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationConnectionTableRows.tsx b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationConnectionTableRows.tsxnew file mode 100644index 00000000000..ce8d61298ea--- /dev/null+++ b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationConnectionTableRows.tsx@@ -0,0 +1,18 @@+import { styled } from '@linaria/react';+import { type ReactNode } from 'react';+import { themeCssVariables } from 'twenty-ui/theme';++const StyledTableRows = styled.div`+ border-bottom: 1px solid ${themeCssVariables.border.color.light};+ padding: ${themeCssVariables.spacing[2]} 0;+`;++type SettingsApplicationConnectionTableRowsProps = {+ children: ReactNode;+};++export const SettingsApplicationConnectionTableRows = ({+ children,+}: SettingsApplicationConnectionTableRowsProps) => (+ <StyledTableRows>{children}</StyledTableRows>+);diff --git a/packages/twenty-front/src/modules/settings/applications/graphql/fragments/applicationConnectionProviderFragment.ts b/packages/twenty-front/src/modules/settings/applications/graphql/fragments/applicationConnectionProviderFragment.tsnew file mode 100644index 00000000000..aed0a96429f--- /dev/null+++ b/packages/twenty-front/src/modules/settings/applications/graphql/fragments/applicationConnectionProviderFragment.ts@@ -0,0 +1,17 @@+import { gql } from '@apollo/client';++export const APPLICATION_CONNECTION_PROVIDER_FRAGMENT = gql`+ fragment ApplicationConnectionProviderFragment on ApplicationConnectionProvider {+ id+ applicationId+ type+ name+ displayName+ scope+ logoUrl+ oauth {+ scopes+ isClientCredentialsConfigured+ }+ }+`;diff --git a/packages/twenty-front/src/modules/settings/applications/graphql/queries/findApplicationConnectedAccounts.ts b/packages/twenty-front/src/modules/settings/applications/graphql/queries/findApplicationConnectedAccounts.tsindex 33ef25aaed7..3dfd4ec7878 100644--- a/packages/twenty-front/src/modules/settings/applications/graphql/queries/findApplicationConnectedAccounts.ts+++ b/packages/twenty-front/src/modules/settings/applications/graphql/queries/findApplicationConnectedAccounts.ts@@ -7,6 +7,7 @@ export const FIND_APPLICATION_CONNECTED_ACCOUNTS = gql`handleauthFailedAtauthFailedReason+ archivedAtscopeslastSignedInAtconnectionProviderIddiff --git a/packages/twenty-front/src/modules/settings/applications/graphql/queries/findApplicationConnectionProviders.ts b/packages/twenty-front/src/modules/settings/applications/graphql/queries/findApplicationConnectionProviders.tsindex ac47e8f47de..2055d09a1b0 100644--- a/packages/twenty-front/src/modules/settings/applications/graphql/queries/findApplicationConnectionProviders.ts+++ b/packages/twenty-front/src/modules/settings/applications/graphql/queries/findApplicationConnectionProviders.ts@@ -1,19 +1,11 @@+import { APPLICATION_CONNECTION_PROVIDER_FRAGMENT } from '@/settings/applications/graphql/fragments/applicationConnectionProviderFragment';import { gql } from '@apollo/client';export const FIND_APPLICATION_CONNECTION_PROVIDERS = gql`+ ${APPLICATION_CONNECTION_PROVIDER_FRAGMENT}query ApplicationConnectionProviders($applicationId: UUID!) {applicationConnectionProviders(applicationId: $applicationId) {- id- applicationId- type- name- displayName- scope- logoUrl- oauth {- scopes- isClientCredentialsConfigured- }+ ...ApplicationConnectionProviderFragment}}`;diff --git a/packages/twenty-front/src/pages/settings/applications/hooks/__tests__/useTriggerAppOAuth.test.tsx b/packages/twenty-front/src/modules/settings/applications/hooks/__tests__/useTriggerAppOAuth.test.tsxsimilarity index 93%rename from packages/twenty-front/src/pages/settings/applications/hooks/__tests__/useTriggerAppOAuth.test.tsxrename to packages/twenty-front/src/modules/settings/applications/hooks/__tests__/useTriggerAppOAuth.test.tsxindex 883bbc2ed10..ebca5fd3f52 100644--- a/packages/twenty-front/src/pages/settings/applications/hooks/__tests__/useTriggerAppOAuth.test.tsx+++ b/packages/twenty-front/src/modules/settings/applications/hooks/__tests__/useTriggerAppOAuth.test.tsx@@ -1,7 +1,7 @@import { useMutation } from '@apollo/client/react';import { act, renderHook } from '@testing-library/react';-import { useTriggerAppOAuth } from '~/pages/settings/applications/hooks/useTriggerAppOAuth';+import { useTriggerAppOAuth } from '@/settings/applications/hooks/useTriggerAppOAuth';const mockRedirect = jest.fn();diff --git a/packages/twenty-front/src/pages/settings/applications/hooks/useTriggerAppOAuth.ts b/packages/twenty-front/src/modules/settings/applications/hooks/useTriggerAppOAuth.tssimilarity index 100%rename from packages/twenty-front/src/pages/settings/applications/hooks/useTriggerAppOAuth.tsrename to packages/twenty-front/src/modules/settings/applications/hooks/useTriggerAppOAuth.tsdiff --git a/packages/twenty-front/src/modules/settings/applications/utils/__tests__/canStartConnectionProviderAuthorization.test.ts b/packages/twenty-front/src/modules/settings/applications/utils/__tests__/canStartConnectionProviderAuthorization.test.tsnew file mode 100644index 00000000000..eab16a2a778--- /dev/null+++ b/packages/twenty-front/src/modules/settings/applications/utils/__tests__/canStartConnectionProviderAuthorization.test.ts@@ -0,0 +1,27 @@+import { canStartConnectionProviderAuthorization } from '@/settings/applications/utils/canStartConnectionProviderAuthorization';++describe('canStartConnectionProviderAuthorization', () => {+ it('allows an OAuth provider only once its client credentials are configured', () => {+ expect(+ canStartConnectionProviderAuthorization({+ type: 'oauth',+ oauth: { isClientCredentialsConfigured: true },+ }),+ ).toBe(true);+ expect(+ canStartConnectionProviderAuthorization({+ type: 'oauth',+ oauth: { isClientCredentialsConfigured: false },+ }),+ ).toBe(false);+ expect(+ canStartConnectionProviderAuthorization({ type: 'oauth', oauth: null }),+ ).toBe(false);+ });++ it('always allows a custom provider', () => {+ expect(+ canStartConnectionProviderAuthorization({ type: 'custom', oauth: null }),+ ).toBe(true);+ });+});diff --git a/packages/twenty-front/src/modules/settings/applications/utils/canStartConnectionProviderAuthorization.ts b/packages/twenty-front/src/modules/settings/applications/utils/canStartConnectionProviderAuthorization.tsnew file mode 100644index 00000000000..bcc12bc0300--- /dev/null+++ b/packages/twenty-front/src/modules/settings/applications/utils/canStartConnectionProviderAuthorization.ts@@ -0,0 +1,6 @@+export const canStartConnectionProviderAuthorization = (provider: {+ type: string;+ oauth?: { isClientCredentialsConfigured: boolean } | null;+}) =>+ provider.type !== 'oauth' ||+ (provider.oauth?.isClientCredentialsConfigured ?? false);diff --git a/packages/twenty-front/src/modules/settings/applications/utils/isApplicationConnectionReconnectNeeded.ts b/packages/twenty-front/src/modules/settings/applications/utils/isApplicationConnectionReconnectNeeded.tsnew file mode 100644index 00000000000..c6cbedc1f57--- /dev/null+++ b/packages/twenty-front/src/modules/settings/applications/utils/isApplicationConnectionReconnectNeeded.ts@@ -0,0 +1,7 @@+import { type ConnectedAccount } from '@/accounts/types/ConnectedAccount';+import { isDefined } from 'twenty-shared/utils';++export const isApplicationConnectionReconnectNeeded = (+ connection: Partial<Pick<ConnectedAccount, 'authFailedAt' | 'archivedAt'>>,+): boolean =>+ isDefined(connection.authFailedAt) && !isDefined(connection.archivedAt);diff --git a/packages/twenty-front/src/modules/ui/layout/dialog/components/ConfirmationDialog.tsx b/packages/twenty-front/src/modules/ui/layout/dialog/components/ConfirmationDialog.tsxindex d3c3c2a4013..8184669766f 100644--- a/packages/twenty-front/src/modules/ui/layout/dialog/components/ConfirmationDialog.tsx+++ b/packages/twenty-front/src/modules/ui/layout/dialog/components/ConfirmationDialog.tsx@@ -27,6 +27,7 @@ export const ConfirmationDialog = ({confirmButtonColor = 'danger',AdditionalButtons,hideCancelButton = false,+ shouldWaitForConfirmBeforeClosing = false,}: ConfirmationDialogProps) => {const { i18n, t } = useLingui();const translatedConfirmButtonText =@@ -46,18 +47,35 @@ export const ConfirmationDialog = ({closeDialog(dialogId);};- const handleConfirmClick = () => {- handleClose();- onConfirmClick();+ const [isConfirming, setIsConfirming] = useState(false);++ const handleConfirmClick = async () => {+ if (!shouldWaitForConfirmBeforeClosing) {+ handleClose();+ onConfirmClick();++ return;+ }++ setIsConfirming(true);++ try {+ await onConfirmClick();+ } finally {+ setIsConfirming(false);+ handleClose();+ }};+ const isLoading = (loading ?? false) || isConfirming;+const handleCancelClick = () => {handleClose();onClose?.();};const handleEnter = () => {- if (isValidValue && !loading) {+ if (isValidValue && !isLoading) {handleConfirmClick();}};@@ -111,7 +129,8 @@ export const ConfirmationDialog = ({<ButtononClick={handleConfirmClick}- disabled={!isValidValue || loading}+ disabled={!isValidValue || isLoading}+ loading={shouldWaitForConfirmBeforeClosing && isConfirming}fullWidthdata-testid="confirmation-modal-confirm-button"variant={confirmButtonColor === 'neutral' ? 'outline' : 'solid'}diff --git a/packages/twenty-front/src/modules/ui/layout/dialog/components/__stories__/ConfirmationDialog.stories.tsx b/packages/twenty-front/src/modules/ui/layout/dialog/components/__stories__/ConfirmationDialog.stories.tsxindex d3531e876c0..c53b8bb8be6 100644--- a/packages/twenty-front/src/modules/ui/layout/dialog/components/__stories__/ConfirmationDialog.stories.tsx+++ b/packages/twenty-front/src/modules/ui/layout/dialog/components/__stories__/ConfirmationDialog.stories.tsx@@ -367,6 +367,47 @@ export const PreventConfirmationWhileLoading: Story = {},};+let resolvePendingConfirm: () => void = () => {};++export const WaitsForConfirmBeforeClosing: Story = {+ args: {+ ...Default.args,+ shouldWaitForConfirmBeforeClosing: true,+ onConfirmClick: fn(+ () =>+ new Promise<void>((resolve) => {+ resolvePendingConfirm = resolve;+ }),+ ),+ },+ play: async ({ canvasElement, args }) => {+ const body = within(canvasElement.ownerDocument.body);+ const dialog = await body.findByRole('dialog', {+ name: 'Pariatur labore.',+ });+ const confirmButton = within(dialog).getByTestId(+ 'confirmation-modal-confirm-button',+ );++ await userEvent.click(confirmButton);++ await waitFor(() =>+ expect(confirmButton).toHaveAttribute('aria-busy', 'true'),+ );+ expect(confirmButton).toBeDisabled();+ expect(args.onConfirmClick).toHaveBeenCalledTimes(1);+ expect(dialog).toBeInTheDocument();++ resolvePendingConfirm();++ await waitFor(() =>+ expect(+ body.queryByRole('dialog', { name: 'Pariatur labore.' }),+ ).not.toBeInTheDocument(),+ );+ },+};+export const AdditionalActions: Story = {args: {...Default.args,diff --git a/packages/twenty-front/src/modules/ui/layout/dialog/types/ConfirmationDialogProps.ts b/packages/twenty-front/src/modules/ui/layout/dialog/types/ConfirmationDialogProps.tsindex 26380b30efe..5f1c4b3760d 100644--- a/packages/twenty-front/src/modules/ui/layout/dialog/types/ConfirmationDialogProps.ts+++ b/packages/twenty-front/src/modules/ui/layout/dialog/types/ConfirmationDialogProps.ts@@ -8,7 +8,8 @@ export type ConfirmationDialogProps = {isConfirmButtonDisabled?: boolean;subtitle: ReactNode;onClose?: () => void;- onConfirmClick: () => void;+ onConfirmClick: () => void | Promise<void>;+ shouldWaitForConfirmBeforeClosing?: boolean;confirmButtonText?: string;confirmationPlaceholder?: string;confirmationValue?: string;diff --git a/packages/twenty-front/src/pages/settings/accounts/SettingsApplicationPreferencesDetail.tsx b/packages/twenty-front/src/pages/settings/accounts/SettingsApplicationPreferencesDetail.tsxindex 92a2fa32c9b..66c1556ebff 100644--- a/packages/twenty-front/src/pages/settings/accounts/SettingsApplicationPreferencesDetail.tsx+++ b/packages/twenty-front/src/pages/settings/accounts/SettingsApplicationPreferencesDetail.tsx@@ -2,6 +2,8 @@ import { AppChip } from '@/applications/components/AppChip';import { CurrentApplicationContext } from '@/applications/contexts/CurrentApplicationContext';import { getApplicationDisplayName } from '@/applications/utils/getApplicationDisplayName';import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';+import { SettingsAppPreferencesConnectionsTab } from '@/settings/app-preferences/components/SettingsAppPreferencesConnectionsTab';+import { APPLICATION_PREFERENCES_CONNECTIONS_TAB_ID } from '@/settings/app-preferences/constants/ApplicationPreferencesConnectionsTabId';import { SETTINGS_APPLICATION_PREFERENCES_TAB_LIST_COMPONENT_ID } from '@/settings/app-preferences/constants/SettingsApplicationPreferencesTabListComponentId';import { type ApplicationWithPreferences } from '@/settings/app-preferences/types/ApplicationWithPreferences';import { APPLICATION_VARIABLES_TAB_ID } from '@/settings/applications/constants/ApplicationVariablesTabId';@@ -22,7 +24,12 @@ import {isDefined,isNonEmptyArray,} from 'twenty-shared/utils';-import { IconDeviceFloppy, IconVariable, useIcons } from 'twenty-ui/icon';+import {+ IconDeviceFloppy,+ IconSettings,+ IconVariable,+ useIcons,+} from 'twenty-ui/icon';import { Button } from 'twenty-ui/primitives/input';import {ApplicationVariableScope,@@ -44,6 +51,7 @@ export const SettingsApplicationPreferencesDetail = ({settingsMenuItems,variables,missingRequiredVariables,+ connectionProviders,},refetchApplicationsWithPreferences,}: SettingsApplicationPreferencesDetailProps) => {@@ -98,6 +106,15 @@ export const SettingsApplicationPreferencesDetail = ({title: settingsMenuItem.title,Icon: getIcon(settingsMenuItem.icon, 'IconAdjustments'),})),+ ...(isNonEmptyArray(connectionProviders)+ ? [+ {+ id: APPLICATION_PREFERENCES_CONNECTIONS_TAB_ID,+ title: t`General`,+ Icon: IconSettings,+ },+ ]+ : []),];const tabListComponentInstanceId = `${SETTINGS_APPLICATION_PREFERENCES_TAB_LIST_COMPONENT_ID}-${application.id}`;@@ -152,11 +169,13 @@ export const SettingsApplicationPreferencesDetail = ({) : undefined}secondaryBar={- <SettingsTabBar- aria-label={t`${appName} preferences`}- tabs={tabs}- componentInstanceId={tabListComponentInstanceId}- />+ tabs.length > 1 ? (+ <SettingsTabBar+ aria-label={t`${appName} preferences`}+ tabs={tabs}+ componentInstanceId={tabListComponentInstanceId}+ />+ ) : undefined}><SettingsPageContainer overflow="visible">@@ -183,6 +202,12 @@ export const SettingsApplicationPreferencesDetail = ({onVariableClear={clearApplicationVariableValue}/>)}+ {activeTabId === APPLICATION_PREFERENCES_CONNECTIONS_TAB_ID && (+ <SettingsAppPreferencesConnectionsTab+ applicationId={application.id}+ connectionProviders={connectionProviders}+ />+ )}{isDefined(activeSettingsMenuItem) && (<SettingsApplicationCustomSettingsSectionfrontComponentId={activeSettingsMenuItem.frontComponentId}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 773646c37a7..c4671582d57 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@@ -31,6 +31,7 @@ import {failNextApplicationPreferencesRequest,seedApplicationPreferencesStory,} from '~/pages/settings/accounts/__stories__/mockedApplicationPreferences';+import { unconfigureLinearClientCredentials } from '~/pages/settings/accounts/__stories__/mockedLinearApplicationPreferences';const meta: Meta<PageDecoratorArgs> = {title: 'Pages/Settings/Accounts/SettingsAccounts',@@ -355,6 +356,7 @@ export const AppPreferencesListInstalledApps: Story = {`/settings/accounts/applications/${FATHOM_APPLICATION_ID}`,);expect(canvas.getByText('Granola')).toBeVisible();+ expect(canvas.getByText('Linear')).toBeVisible();expect(canvas.queryByText('Blocklist')).not.toBeInTheDocument();const outlookRow = canvas@@ -414,6 +416,33 @@ export const AppPreferencesListFlagsMissingConfiguration: Story = {'Missing configuration',),).not.toBeInTheDocument();+ expect(+ getTableRow(canvasElement, 'Linear').queryByText('Missing configuration'),+ ).not.toBeInTheDocument();+ expect(+ await getTableRow(canvasElement, 'Linear').findByText('Missing account'),+ ).toBeVisible();+ },+};++export const AppsWhoseProviderIsNotSetUpShowNoMissingAccount: Story = {+ ...accountGroupsStory,+ beforeEach: async () => {+ await seedApplicationPreferencesStory();+ unconfigureLinearClientCredentials();+ },+ parameters: {+ msw: { handlers: APPLICATION_PREFERENCES_GRAPHQL_HANDLERS },+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ await canvas.findByText('Linear', undefined, { timeout: 3000 });+ await canvas.findByText('[email protected]');++ expect(+ getTableRow(canvasElement, 'Linear').queryByText('Missing account'),+ ).not.toBeInTheDocument();},};diff --git a/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsApplicationPreferences.stories.tsx b/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsApplicationPreferences.stories.tsxindex cf443a379fe..58c70a439ed 100644--- a/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsApplicationPreferences.stories.tsx+++ b/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsApplicationPreferences.stories.tsx@@ -7,15 +7,18 @@ import {} from '~/testing/decorators/PageDecorator';import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';+import { ErrorMessageEffect } from '@/error-handler/components/ErrorMessageEffect';+import { useLocation } from 'react-router-dom';import { jotaiStore } from '@/ui/utilities/state/jotai/jotaiStore';import { isDefined } from 'twenty-shared/utils';+import { Toaster } from 'twenty-ui/components/feedback';import { SettingsApplicationPreferences } from '~/pages/settings/accounts/SettingsApplicationPreferences';import {FATHOM_APPLICATION_ID,GRANOLA_APPLICATION_ID,} from '~/pages/settings/accounts/__stories__/mockedAccountGroups';import {- APPLICATION_PREFERENCES_GRAPHQL_HANDLERS,+ APPLICATION_PREFERENCES_DETAIL_GRAPHQL_HANDLERS,GRANOLA_USER_SETTINGS_FRONT_COMPONENT_ID,failNextApplicationPreferencesRequest,findApplicationsGatedQuery,@@ -36,7 +39,7 @@ const meta: Meta<PageDecoratorArgs> = {beforeEach: seedApplicationPreferencesStory,parameters: {layout: 'fullscreen',- msw: { handlers: APPLICATION_PREFERENCES_GRAPHQL_HANDLERS },+ msw: { handlers: APPLICATION_PREFERENCES_DETAIL_GRAPHQL_HANDLERS },},};@@ -256,29 +259,81 @@ export const SavedSecretCanBeCleared: Story = {},};-export const SettingsTabReplacesVariablesTab: Story = {+export const SettingsOnlyAppShowsItsSettingsWithoutTabs: Story = {args: {routeParams: { ':applicationId': GRANOLA_APPLICATION_ID },},play: async ({ canvasElement }) => {const canvas = within(canvasElement);+ await waitFor(+ () =>+ expect(findOneFrontComponent).toHaveBeenCalledWith(+ GRANOLA_USER_SETTINGS_FRONT_COMPONENT_ID,+ ),+ { timeout: 3000 },+ );expect(- await canvas.findByRole('link', { name: 'My notes' }, { timeout: 3000 }),- ).toBeVisible();+ canvas.queryByRole('link', { name: 'My notes' }),+ ).not.toBeInTheDocument();expect(canvas.queryByRole('link', { name: 'Variables' }),).not.toBeInTheDocument();+ expect(canvas.queryByText('Language')).not.toBeInTheDocument();expect(canvas.queryByRole('button', { name: 'Save settings' }),).not.toBeInTheDocument();+ expect(findApplicationsGatedQuery).not.toHaveBeenCalled();+ },+};++const FAILED_OAUTH_ERROR_MESSAGE =+ 'Failed to exchange the authorization code for an access token.';++const LocationProbe = () => {+ const { search, hash } = useLocation();++ return <div data-testid="location-probe">{`${search}${hash}`}</div>;+};++export const FailedOAuthReturnShowsItsMessage: Story = {+ args: {+ routeParams: { ':applicationId': FATHOM_APPLICATION_ID },+ searchParams: { errorMessage: FAILED_OAUTH_ERROR_MESSAGE },+ routeHash: '#connections',+ },+ decorators: [+ (Story) => (+ <>+ <ErrorMessageEffect />+ <LocationProbe />+ <Story />+ <Toaster getToastProps={() => ({ progress: 100 })} />+ </>+ ),+ ],+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const body = within(canvasElement.ownerDocument.body);+ expect(+ await body.findByText(FAILED_OAUTH_ERROR_MESSAGE, undefined, {+ timeout: 3000,+ }),+ ).toBeVisible();await waitFor(() =>- expect(findOneFrontComponent).toHaveBeenCalledWith(- GRANOLA_USER_SETTINGS_FRONT_COMPONENT_ID,+ expect(canvas.getByTestId('location-probe')).toHaveTextContent(+ /^#connections$/,),);- expect(findApplicationsGatedQuery).not.toHaveBeenCalled();+ expect(+ await canvas.findByText(+ 'Connect your own Fathom account for this app to use on your behalf.',+ ),+ ).toBeVisible();+ expect(canvas.queryByText('Record my meetings')).not.toBeInTheDocument();+ expect(canvas.getByRole('link', { name: 'Variables' })).toBeVisible();+ expect(canvas.getByRole('link', { name: 'General' })).toBeVisible();},};diff --git a/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsApplicationPreferencesConnections.stories.tsx b/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsApplicationPreferencesConnections.stories.tsxnew file mode 100644index 00000000000..f01ce251626--- /dev/null+++ b/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsApplicationPreferencesConnections.stories.tsx@@ -0,0 +1,343 @@+import { type Meta, type StoryObj } from '@storybook/react-vite';+import { expect, userEvent, waitFor, within } from 'storybook/test';++import {+ PageDecorator,+ type PageDecoratorArgs,+} from '~/testing/decorators/PageDecorator';++import { REACT_APP_SERVER_BASE_URL } from '~/config';+import { SettingsApplicationPreferences } from '~/pages/settings/accounts/SettingsApplicationPreferences';+import { deleteConnectedAccount } from '~/pages/settings/accounts/__stories__/mockedAccountGroups';+import {+ APPLICATION_PREFERENCES_DETAIL_GRAPHQL_HANDLERS,+ APPLICATION_PREFERENCES_GRAPHQL_HANDLERS,+ failNextConnectedAccountsRequest,+ findApplicationsGatedQuery,+ seedApplicationPreferencesStory,+} from '~/pages/settings/accounts/__stories__/mockedApplicationPreferences';+import {+ LINEAR_APPLICATION_ID,+ LINEAR_CONNECTIONS_REDIRECT_LOCATION,+ LINEAR_RECONNECT_NEEDED_ACCOUNT_ID,+ MOCKED_TRANSIENT_TOKEN,+ generateTransientToken,+ unconfigureLinearClientCredentials,+} from '~/pages/settings/accounts/__stories__/mockedLinearApplicationPreferences';+import { clickAndCaptureOAuthRedirect } from '~/pages/settings/accounts/__stories__/clickAndCaptureOAuthRedirect';+import { withinTableRowOrThrow } from '~/testing/utils/withinTableRowOrThrow';++const meta: Meta<PageDecoratorArgs> = {+ title: 'Pages/Settings/Accounts/SettingsApplicationPreferencesConnections',+ component: SettingsApplicationPreferences,+ decorators: [PageDecorator],+ args: {+ routePath: '/settings/accounts/applications/:applicationId',+ routeParams: { ':applicationId': LINEAR_APPLICATION_ID },+ additionalRoutes: ['/settings/accounts'],+ },+ beforeEach: seedApplicationPreferencesStory,+ parameters: {+ layout: 'fullscreen',+ msw: { handlers: APPLICATION_PREFERENCES_DETAIL_GRAPHQL_HANDLERS },+ },+};++export default meta;++export type Story = StoryObj<typeof SettingsApplicationPreferences>;++export const ConnectionOnlyAppListsMyConnectionsWithoutTabs: Story = {+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const body = within(canvasElement.ownerDocument.body);++ expect(+ await canvas.findByText('Work Linear', undefined, { timeout: 3000 }),+ ).toBeVisible();+ expect(+ canvas.queryByRole('link', { name: 'General' }),+ ).not.toBeInTheDocument();+ expect(+ canvas.queryByRole('link', { name: 'Variables' }),+ ).not.toBeInTheDocument();++ expect(+ withinTableRowOrThrow({ canvasElement, text: 'Work Linear' }).getByText(+ '[email protected]',+ ),+ ).toBeVisible();+ expect(+ withinTableRowOrThrow({ canvasElement, text: 'Work Linear' }).getByText(+ 'Connected',+ ),+ ).toBeVisible();++ const reconnectNeededRow = withinTableRowOrThrow({+ canvasElement,+ text: '[email protected]',+ });++ expect(reconnectNeededRow.getByText('Reconnect needed')).toBeVisible();++ const archivedRow = withinTableRowOrThrow({+ canvasElement,+ text: '[email protected]',+ });++ expect(archivedRow.getByText('Disconnected')).toBeVisible();++ const archivedAfterFailureRow = withinTableRowOrThrow({+ canvasElement,+ text: '[email protected]',+ });++ expect(archivedAfterFailureRow.getByText('Disconnected')).toBeVisible();++ for (const { text, canReconnect } of [+ { text: 'Work Linear', canReconnect: false },+ { text: '[email protected]', canReconnect: true },+ { text: '[email protected]', canReconnect: false },+ { text: '[email protected]', canReconnect: false },+ ]) {+ await userEvent.click(+ withinTableRowOrThrow({ canvasElement, text }).getByRole('button', {+ name: 'More options',+ }),+ );++ expect(+ await body.findByRole('menuitem', { name: 'Remove' }),+ ).toBeVisible();++ if (canReconnect) {+ expect(body.getByRole('menuitem', { name: 'Reconnect' })).toBeVisible();+ } else {+ expect(+ body.queryByRole('menuitem', { name: 'Reconnect' }),+ ).not.toBeInTheDocument();+ }++ await userEvent.keyboard('{Escape}');+ await waitFor(() =>+ expect(body.queryByRole('menu')).not.toBeInTheDocument(),+ );+ }++ expect(canvas.queryByText('[email protected]')).not.toBeInTheDocument();+ expect(findApplicationsGatedQuery).not.toHaveBeenCalled();+ },+};++export const AddConnectionStartsTheOAuthFlow: Story = {+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ const redirectUrl = await clickAndCaptureOAuthRedirect(+ await canvas.findByRole(+ 'button',+ { name: 'Add connection' },+ { timeout: 3000 },+ ),+ );++ expect(generateTransientToken).toHaveBeenCalledTimes(1);+ expect(`${redirectUrl.origin}${redirectUrl.pathname}`).toBe(+ `${REACT_APP_SERVER_BASE_URL}/auth/apps/authorize`,+ );+ expect(Object.fromEntries(redirectUrl.searchParams)).toEqual({+ applicationId: LINEAR_APPLICATION_ID,+ providerName: 'linear',+ transientToken: MOCKED_TRANSIENT_TOKEN,+ redirectLocation: LINEAR_CONNECTIONS_REDIRECT_LOCATION,+ });+ },+};++export const ReconnectStartsTheOAuthFlow: Story = {+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const body = within(canvasElement.ownerDocument.body);++ await canvas.findByText('[email protected]', undefined, {+ timeout: 3000,+ });++ await userEvent.click(+ withinTableRowOrThrow({+ canvasElement,+ text: '[email protected]',+ }).getByRole('button', { name: 'More options' }),+ );++ const redirectUrl = await clickAndCaptureOAuthRedirect(+ await body.findByRole('menuitem', { name: 'Reconnect' }),+ );++ expect(generateTransientToken).toHaveBeenCalledTimes(1);+ expect(`${redirectUrl.origin}${redirectUrl.pathname}`).toBe(+ `${REACT_APP_SERVER_BASE_URL}/auth/apps/authorize`,+ );+ expect(Object.fromEntries(redirectUrl.searchParams)).toEqual({+ applicationId: LINEAR_APPLICATION_ID,+ providerName: 'linear',+ transientToken: MOCKED_TRANSIENT_TOKEN,+ reconnectingConnectedAccountId: LINEAR_RECONNECT_NEEDED_ACCOUNT_ID,+ redirectLocation: LINEAR_CONNECTIONS_REDIRECT_LOCATION,+ });+ },+};++export const RowRemoveDeletesTheConnection: Story = {+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const body = within(canvasElement.ownerDocument.body);++ await canvas.findByText('[email protected]', undefined, {+ timeout: 3000,+ });++ await userEvent.click(+ withinTableRowOrThrow({+ canvasElement,+ text: '[email protected]',+ }).getByRole('button', { name: 'More options' }),+ );+ await userEvent.click(+ await body.findByRole('menuitem', { name: 'Remove' }),+ );+ await userEvent.click(+ await within(+ await body.findByRole('dialog', { name: 'Remove connection?' }),+ ).findByRole('button', { name: 'Remove' }),+ );++ await waitFor(() =>+ expect(deleteConnectedAccount.mock.calls).toEqual([+ [LINEAR_RECONNECT_NEEDED_ACCOUNT_ID],+ ]),+ );+ await waitFor(() =>+ expect(canvas.queryByText('[email protected]')).not.toBeInTheDocument(),+ );+ await waitFor(() =>+ expect(+ body.queryByRole('dialog', { name: 'Remove connection?' }),+ ).not.toBeInTheDocument(),+ );+ expect(canvas.getByText('Work Linear')).toBeVisible();+ },+};++export const UnconfiguredProviderExplainsWhoMustSetItUp: Story = {+ beforeEach: async () => {+ await seedApplicationPreferencesStory();+ unconfigureLinearClientCredentials();+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const body = within(canvasElement.ownerDocument.body);++ expect(+ await canvas.findByText(+ 'Linear OAuth is not yet set up by your server administrator. They need to fill in the OAuth client ID and secret on the application registration before you can add a connection.',+ undefined,+ { timeout: 3000 },+ ),+ ).toBeVisible();+ expect(+ canvas.queryByRole('button', { name: 'Add connection' }),+ ).not.toBeInTheDocument();+ await canvas.findByText('[email protected]', undefined, {+ timeout: 3000,+ });+ await userEvent.click(+ withinTableRowOrThrow({+ canvasElement,+ text: '[email protected]',+ }).getByRole('button', { name: 'More options' }),+ );+ expect(await body.findByRole('menuitem', { name: 'Remove' })).toBeVisible();+ expect(+ body.queryByRole('menuitem', { name: 'Reconnect' }),+ ).not.toBeInTheDocument();+ },+};++export const ProviderWithoutConnectionsSaysSo: Story = {+ parameters: {+ msw: { handlers: APPLICATION_PREFERENCES_GRAPHQL_HANDLERS },+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ expect(+ await canvas.findByText('You have no Linear connection yet.', undefined, {+ timeout: 3000,+ }),+ ).toBeVisible();+ expect(+ canvas.getByRole('button', { name: 'Add connection' }),+ ).toBeVisible();+ },+};++export const UnconfiguredProviderWithoutConnectionsShowsOnlyTheBanner: Story = {+ beforeEach: async () => {+ await seedApplicationPreferencesStory();+ unconfigureLinearClientCredentials();+ },+ parameters: {+ msw: { handlers: APPLICATION_PREFERENCES_GRAPHQL_HANDLERS },+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ expect(+ await canvas.findByText(/Linear OAuth is not yet set up/, undefined, {+ timeout: 3000,+ }),+ ).toBeVisible();+ expect(+ canvas.queryByText('You have no Linear connection yet.'),+ ).not.toBeInTheDocument();+ },+};++export const LoadErrorOffersRetryInsteadOfTheEmptyState: Story = {+ beforeEach: async () => {+ await seedApplicationPreferencesStory();+ failNextConnectedAccountsRequest();+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ expect(+ await canvas.findByText(+ 'Your connections could not be loaded. Check your connection and try again.',+ undefined,+ { timeout: 3000 },+ ),+ ).toBeVisible();+ expect(+ canvas.queryByText('You have no Linear connection yet.'),+ ).not.toBeInTheDocument();+ expect(+ canvas.queryByRole('button', { name: 'Add connection' }),+ ).not.toBeInTheDocument();++ await userEvent.click(canvas.getByRole('button', { name: 'Retry' }));++ expect(+ await canvas.findByText('Work Linear', undefined, { timeout: 3000 }),+ ).toBeVisible();+ expect(+ canvas.getByRole('button', { name: 'Add connection' }),+ ).toBeVisible();+ expect(+ canvas.queryByText(+ 'Your connections could not be loaded. Check your connection and try again.',+ ),+ ).not.toBeInTheDocument();+ },+};diff --git a/packages/twenty-front/src/pages/settings/accounts/__stories__/clickAndCaptureOAuthRedirect.ts b/packages/twenty-front/src/pages/settings/accounts/__stories__/clickAndCaptureOAuthRedirect.tsnew file mode 100644index 00000000000..da91c624a4b--- /dev/null+++ b/packages/twenty-front/src/pages/settings/accounts/__stories__/clickAndCaptureOAuthRedirect.ts@@ -0,0 +1,18 @@+import { expect, spyOn, userEvent, waitFor } from 'storybook/test';++export const clickAndCaptureOAuthRedirect = async (element: HTMLElement) => {+ const openWindow = spyOn(window, 'open').mockImplementation(() => null);++ try {+ await userEvent.click(element);+ await waitFor(() => expect(openWindow).toHaveBeenCalledTimes(1));++ const [redirectUrl, target] = openWindow.mock.calls[0];++ expect(target).toBe('_self');++ return new URL(String(redirectUrl));+ } finally {+ openWindow.mockRestore();+ }+};diff --git a/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedAccountGroups.ts b/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedAccountGroups.tsindex e7e9cd07290..4dd990c53ae 100644--- a/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedAccountGroups.ts+++ b/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedAccountGroups.ts@@ -18,8 +18,9 @@ import {mockedWorkspaceMemberData,} from '~/testing/mock-data/users';-const MY_USER_WORKSPACE_ID = '20202020-1a2b-4c3d-8e4f-000000000001';-const TEAMMATE_USER_WORKSPACE_ID = '20202020-1a2b-4c3d-8e4f-000000000002';+export const MY_USER_WORKSPACE_ID = '20202020-1a2b-4c3d-8e4f-000000000001';+export const TEAMMATE_USER_WORKSPACE_ID =+ '20202020-1a2b-4c3d-8e4f-000000000002';export const FATHOM_APPLICATION_ID = '20202020-1a2b-4c3d-8e4f-000000000021';export const GRANOLA_APPLICATION_ID = '20202020-1a2b-4c3d-8e4f-000000000022';const CREATED_AT = '2026-09-01T00:00:00.000Z';@@ -33,12 +34,16 @@ const TEAMMATE_ACCOUNT_ID = '20202020-1a2b-4c3d-8e4f-000000000016';const EMAIL_GROUP_ACCOUNT_ID = '20202020-1a2b-4c3d-8e4f-000000000017';const SECOND_GOOGLE_ACCOUNT_ID = '20202020-1a2b-4c3d-8e4f-000000000018';-const buildConnectedAccount = (account: {+export const buildConnectedAccount = (account: {id: string;handle: string;provider: string;userWorkspaceId: string;applicationId?: string;+ connectionProviderId?: string;+ name?: string;+ authFailedAt?: string;+ archivedAt?: string;scope?: string;scopes?: string[];}) => ({@@ -215,7 +220,12 @@ export const CALENDAR_CHANNELS = [const deletedAccountIds = new Set<string>();+export const withoutDeletedAccounts = <TAccount extends { id: string }>(+ accounts: TAccount[],+) => accounts.filter((account) => !deletedAccountIds.has(account.id));+export const deleteConnectedAccount = fn();+export const myApplicationPreferencesRequested = fn();export const ACCOUNT_GROUPS_GRAPHQL_HANDLERS = [graphql.query('MyConnectedAccounts', () =>@@ -258,9 +268,11 @@ export const ACCOUNT_GROUPS_GRAPHQL_HANDLERS = [},});}),- graphql.query('MyApplicationPreferences', () =>- HttpResponse.json({ data: { myApplicationPreferences: [] } }),- ),+ graphql.query('MyApplicationPreferences', () => {+ myApplicationPreferencesRequested();++ return HttpResponse.json({ data: { myApplicationPreferences: [] } });+ }),graphql.query('FindManyBlocklists', () =>HttpResponse.json({data: {@@ -279,6 +291,7 @@ export const ACCOUNT_GROUPS_GRAPHQL_HANDLERS = [export const seedAccountGroupsStory = async () => {deletedAccountIds.clear();deleteConnectedAccount.mockClear();+ myApplicationPreferencesRequested.mockClear();await mockedApolloClient.clearStore();jotaiStore.set(isGoogleMessagingEnabledState.atom, true);diff --git a/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedApplicationPreferences.ts b/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedApplicationPreferences.tsindex b36664de9d4..7bc1e1f1c4d 100644--- a/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedApplicationPreferences.ts+++ b/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedApplicationPreferences.ts@@ -4,12 +4,22 @@ import { getWorker } from 'msw-storybook-addon';import { fn } from 'storybook/test';import { isDefined } from 'twenty-shared/utils';+import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';+import { jotaiStore } from '@/ui/utilities/state/jotai/jotaiStore';import {ACCOUNT_GROUPS_GRAPHQL_HANDLERS,FATHOM_APPLICATION_ID,GRANOLA_APPLICATION_ID,+ myApplicationPreferencesRequested,seedAccountGroupsStory,} from '~/pages/settings/accounts/__stories__/mockedAccountGroups';+import {+ GENERATE_TRANSIENT_TOKEN_GRAPHQL_HANDLER,+ LINEAR_CONNECTED_ACCOUNTS_GRAPHQL_HANDLER,+ LINEAR_INSTALLED_APPLICATION,+ buildLinearApplicationPreferences,+ resetLinearApplicationPreferencesMocks,+} from '~/pages/settings/accounts/__stories__/mockedLinearApplicationPreferences';export const GRANOLA_USER_SETTINGS_FRONT_COMPONENT_ID ='20202020-1a2b-4c3d-8e4f-000000000051';@@ -72,6 +82,22 @@ const buildSettingsMenuItem = ({const savedValueByKey = new Map<string, string>();+const FATHOM_CONNECTION_PROVIDER = {+ __typename: 'ApplicationConnectionProvider',+ id: '20202020-1a2b-4c3d-8e4f-000000000072',+ applicationId: FATHOM_APPLICATION_ID,+ type: 'oauth',+ name: 'fathom',+ displayName: 'Fathom',+ scope: 'USER',+ logoUrl: null,+ oauth: {+ __typename: 'ApplicationConnectionProviderOAuthConfig',+ scopes: ['read'],+ isClientCredentialsConfigured: true,+ },+};+const SAVED_PERSONAL_API_KEY = 'sk-1abcdefghijklmnopqrstuvwxyz0123456789';// Same masking as the server's SecretEncryptionService.maskDecryptedValue.@@ -96,6 +122,7 @@ const buildApplicationPreferences = () => [{__typename: 'ApplicationPreferences',applicationId: FATHOM_APPLICATION_ID,+ connectionProviders: [FATHOM_CONNECTION_PROVIDER],settingsMenuItems: [],variables: [buildUserApplicationVariable({@@ -125,6 +152,7 @@ const buildApplicationPreferences = () => [{__typename: 'ApplicationPreferences',applicationId: GRANOLA_APPLICATION_ID,+ connectionProviders: [],settingsMenuItems: [buildSettingsMenuItem({universalIdentifier: GRANOLA_USER_SETTINGS_MENU_ITEM_ID,@@ -146,6 +174,7 @@ const buildApplicationPreferences = () => [{__typename: 'ApplicationPreferences',applicationId: NOT_INSTALLED_APPLICATION_ID,+ connectionProviders: [],settingsMenuItems: [],variables: [buildUserApplicationVariable({@@ -155,6 +184,7 @@ const buildApplicationPreferences = () => [}),],},+ buildLinearApplicationPreferences(),];export const failNextApplicationPreferencesRequest = () => {@@ -175,8 +205,28 @@ export const failNextApplicationPreferencesRequest = () => {);};+export const failNextConnectedAccountsRequest = () => {+ getWorker().use(+ graphql.query(+ 'MyConnectedAccounts',+ () =>+ HttpResponse.json({+ errors: [+ {+ message: 'Internal server error',+ extensions: { code: 'INTERNAL_SERVER_ERROR' },+ },+ ],+ }),+ { once: true },+ ),+ );+};+export const APPLICATION_PREFERENCES_GRAPHQL_HANDLERS = [graphql.query('MyApplicationPreferences', () => {+ myApplicationPreferencesRequested();+return HttpResponse.json({data: { myApplicationPreferences: buildApplicationPreferences() },});@@ -194,6 +244,7 @@ export const APPLICATION_PREFERENCES_GRAPHQL_HANDLERS = [data: { updateMyUserApplicationVariable: true },});}),+ GENERATE_TRANSIENT_TOKEN_GRAPHQL_HANDLER,graphql.query('FindOneFrontComponent', ({ variables }) => {findOneFrontComponent(variables.id);@@ -211,12 +262,30 @@ export const APPLICATION_PREFERENCES_GRAPHQL_HANDLERS = [...ACCOUNT_GROUPS_GRAPHQL_HANDLERS,];+export const APPLICATION_PREFERENCES_DETAIL_GRAPHQL_HANDLERS = [+ LINEAR_CONNECTED_ACCOUNTS_GRAPHQL_HANDLER,+ ...APPLICATION_PREFERENCES_GRAPHQL_HANDLERS,+];+export const seedApplicationPreferencesStory = async () => {savedValueByKey.clear();savedValueByKey.set('PERSONAL_API_KEY', SAVED_PERSONAL_API_KEY);+ resetLinearApplicationPreferencesMocks();updateMyUserApplicationVariable.mockClear();findOneFrontComponent.mockClear();findApplicationsGatedQuery.mockClear();await seedAccountGroupsStory();++ const currentWorkspace = jotaiStore.get(currentWorkspaceState.atom);++ if (isDefined(currentWorkspace)) {+ jotaiStore.set(currentWorkspaceState.atom, {+ ...currentWorkspace,+ installedApplications: [+ ...currentWorkspace.installedApplications,+ LINEAR_INSTALLED_APPLICATION,+ ],+ });+ }};diff --git a/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedLinearApplicationPreferences.ts b/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedLinearApplicationPreferences.tsnew file mode 100644index 00000000000..3c191c6f5b5--- /dev/null+++ b/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedLinearApplicationPreferences.ts@@ -0,0 +1,142 @@+import { HttpResponse, graphql } from 'msw';+import { fn } from 'storybook/test';++import {+ CONNECTED_ACCOUNTS,+ MY_USER_WORKSPACE_ID,+ TEAMMATE_USER_WORKSPACE_ID,+ buildConnectedAccount,+ withoutDeletedAccounts,+} from '~/pages/settings/accounts/__stories__/mockedAccountGroups';++export const LINEAR_APPLICATION_ID = '20202020-1a2b-4c3d-8e4f-000000000024';+export const LINEAR_CONNECTIONS_REDIRECT_LOCATION = `/settings/accounts/applications/${LINEAR_APPLICATION_ID}#connections`;+const LINEAR_CONNECTION_PROVIDER_ID = '20202020-1a2b-4c3d-8e4f-000000000071';+export const LINEAR_RECONNECT_NEEDED_ACCOUNT_ID =+ '20202020-1a2b-4c3d-8e4f-000000000081';+export const MOCKED_TRANSIENT_TOKEN = 'mocked-transient-token';++export const generateTransientToken = fn();++let isLinearClientCredentialsConfigured = true;++export const unconfigureLinearClientCredentials = () => {+ isLinearClientCredentialsConfigured = false;+};++export const LINEAR_INSTALLED_APPLICATION = {+ id: LINEAR_APPLICATION_ID,+ universalIdentifier: LINEAR_APPLICATION_ID,+ name: 'Linear',+ logoUrl: null,+ createdAt: '2024-01-01T00:00:00.000Z',+};++const buildLinearConnectionProvider = () => ({+ __typename: 'ApplicationConnectionProvider',+ id: LINEAR_CONNECTION_PROVIDER_ID,+ applicationId: LINEAR_APPLICATION_ID,+ type: 'oauth',+ name: 'linear',+ displayName: 'Linear',+ scope: 'USER',+ logoUrl: null,+ oauth: {+ __typename: 'ApplicationConnectionProviderOAuthConfig',+ scopes: ['read'],+ isClientCredentialsConfigured: isLinearClientCredentialsConfigured,+ },+});++export const buildLinearApplicationPreferences = () => ({+ __typename: 'ApplicationPreferences',+ applicationId: LINEAR_APPLICATION_ID,+ connectionProviders: [buildLinearConnectionProvider()],+ settingsMenuItems: [],+ variables: [],+});++const LINEAR_CONNECTED_ACCOUNTS = [+ buildConnectedAccount({+ id: '20202020-1a2b-4c3d-8e4f-000000000082',+ handle: '[email protected]',+ name: 'Work Linear',+ provider: 'app',+ userWorkspaceId: MY_USER_WORKSPACE_ID,+ applicationId: LINEAR_APPLICATION_ID,+ connectionProviderId: LINEAR_CONNECTION_PROVIDER_ID,+ }),+ buildConnectedAccount({+ id: LINEAR_RECONNECT_NEEDED_ACCOUNT_ID,+ handle: '[email protected]',+ provider: 'app',+ userWorkspaceId: MY_USER_WORKSPACE_ID,+ applicationId: LINEAR_APPLICATION_ID,+ connectionProviderId: LINEAR_CONNECTION_PROVIDER_ID,+ authFailedAt: '2026-09-02T00:00:00.000Z',+ }),+ buildConnectedAccount({+ id: '20202020-1a2b-4c3d-8e4f-000000000085',+ handle: '[email protected]',+ provider: 'app',+ userWorkspaceId: MY_USER_WORKSPACE_ID,+ applicationId: LINEAR_APPLICATION_ID,+ connectionProviderId: LINEAR_CONNECTION_PROVIDER_ID,+ archivedAt: '2026-09-03T00:00:00.000Z',+ }),+ buildConnectedAccount({+ id: '20202020-1a2b-4c3d-8e4f-000000000086',+ handle: '[email protected]',+ provider: 'app',+ userWorkspaceId: MY_USER_WORKSPACE_ID,+ applicationId: LINEAR_APPLICATION_ID,+ connectionProviderId: LINEAR_CONNECTION_PROVIDER_ID,+ authFailedAt: '2026-09-01T00:00:00.000Z',+ archivedAt: '2026-09-03T00:00:00.000Z',+ }),+ buildConnectedAccount({+ id: '20202020-1a2b-4c3d-8e4f-000000000084',+ handle: '[email protected]',+ provider: 'app',+ userWorkspaceId: TEAMMATE_USER_WORKSPACE_ID,+ applicationId: LINEAR_APPLICATION_ID,+ connectionProviderId: LINEAR_CONNECTION_PROVIDER_ID,+ }),+];++export const LINEAR_CONNECTED_ACCOUNTS_GRAPHQL_HANDLER = graphql.query(+ 'MyConnectedAccounts',+ () =>+ HttpResponse.json({+ data: {+ myConnectedAccounts: withoutDeletedAccounts([+ ...CONNECTED_ACCOUNTS,+ ...LINEAR_CONNECTED_ACCOUNTS,+ ]),+ },+ }),+);++export const GENERATE_TRANSIENT_TOKEN_GRAPHQL_HANDLER = graphql.mutation(+ 'generateTransientToken',+ () => {+ generateTransientToken();++ return HttpResponse.json({+ data: {+ generateTransientToken: {+ __typename: 'TransientTokenDTO',+ transientToken: {+ __typename: 'AuthToken',+ token: MOCKED_TRANSIENT_TOKEN,+ },+ },+ },+ });+ },+);++export const resetLinearApplicationPreferencesMocks = () => {+ isLinearClientCredentialsConfigured = true;+ generateTransientToken.mockClear();+};diff --git a/packages/twenty-front/src/pages/settings/applications/SettingsApplicationConnectionDetail.tsx b/packages/twenty-front/src/pages/settings/applications/SettingsApplicationConnectionDetail.tsxindex ab30fca00f6..587b1085741 100644--- a/packages/twenty-front/src/pages/settings/applications/SettingsApplicationConnectionDetail.tsx+++ b/packages/twenty-front/src/pages/settings/applications/SettingsApplicationConnectionDetail.tsx@@ -34,7 +34,7 @@ import {type ApplicationConnectedAccount,useApplicationConnectedAccounts,} from '~/pages/settings/applications/hooks/useApplicationConnectedAccounts';-import { useTriggerAppOAuth } from '~/pages/settings/applications/hooks/useTriggerAppOAuth';+import { useTriggerAppOAuth } from '@/settings/applications/hooks/useTriggerAppOAuth';import { type FrontendApplicationConnectionProvider } from '~/pages/settings/applications/types/FrontendApplicationConnectionProvider';const DETAIL_GRID_TEMPLATE = '220px 1fr';diff --git a/packages/twenty-front/src/pages/settings/applications/__tests__/SettingsApplicationConnectionDetail.test.tsx b/packages/twenty-front/src/pages/settings/applications/__tests__/SettingsApplicationConnectionDetail.test.tsxindex a3e6ff05782..d313b0ec2b9 100644--- a/packages/twenty-front/src/pages/settings/applications/__tests__/SettingsApplicationConnectionDetail.test.tsx+++ b/packages/twenty-front/src/pages/settings/applications/__tests__/SettingsApplicationConnectionDetail.test.tsx@@ -34,7 +34,7 @@ jest.mock(}),);-jest.mock('~/pages/settings/applications/hooks/useTriggerAppOAuth', () => ({+jest.mock('@/settings/applications/hooks/useTriggerAppOAuth', () => ({useTriggerAppOAuth: jest.fn(() => ({triggerAppOAuth: mockTriggerAppOAuth,})),diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationConnectionsSection.tsx b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationConnectionsSection.tsxindex 5f870ed30d2..50efff9516a 100644--- a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationConnectionsSection.tsx+++ b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationConnectionsSection.tsx@@ -1,38 +1,26 @@-import { styled } from '@linaria/react';import { useLingui } from '@lingui/react/macro';-import { isNonEmptyString } from '@sniptt/guards';import { SettingsPath } from 'twenty-shared/types';import { getSettingsPath } from 'twenty-shared/utils';+import { SettingsApplicationAddConnectionButton } from '@/settings/applications/components/SettingsApplicationAddConnectionButton';+import { SettingsApplicationConnectionProviderSection } from '@/settings/applications/components/SettingsApplicationConnectionProviderSection';+import { SettingsApplicationConnectionName } from '@/settings/applications/components/SettingsApplicationConnectionName';+import { SettingsApplicationConnectionStatus } from '@/settings/applications/components/SettingsApplicationConnectionStatus';+import { SettingsApplicationConnectionTableRows } from '@/settings/applications/components/SettingsApplicationConnectionTableRows';+import { canStartConnectionProviderAuthorization } from '@/settings/applications/utils/canStartConnectionProviderAuthorization';import { Table } from '@/ui/layout/table/components/Table';import { TableCell } from '@/ui/layout/table/components/TableCell';import { TableHeader } from '@/ui/layout/table/components/TableHeader';import { TableRow } from '@/ui/layout/table/components/TableRow';-import { InlineBanner } from 'twenty-ui/components/feedback';-import { Section } from 'twenty-ui/components/layout';-import { IconChevronRight, IconPlus } from 'twenty-ui/icon';-import { Avatar, Status } from 'twenty-ui/primitives/data-display';-import { Button } from 'twenty-ui/primitives/input';+import { IconChevronRight } from 'twenty-ui/icon';+import { Status } from 'twenty-ui/primitives/data-display';import { useTheme, themeCssVariables } from 'twenty-ui/theme';import { useApplicationConnectedAccounts } from '~/pages/settings/applications/hooks/useApplicationConnectedAccounts';import { useFindApplicationConnectionProviders } from '~/pages/settings/applications/hooks/useFindApplicationConnectionProviders';-import { useTriggerAppOAuth } from '~/pages/settings/applications/hooks/useTriggerAppOAuth';-import { getAbsoluteImageUrl } from '~/utils/image/getAbsoluteImageUrl';const CONNECTION_TABLE_ROW_GRID_TEMPLATE_COLUMNS ='minmax(0, 1fr) 160px 180px 36px';-const StyledFooter = styled.div`- display: flex;- justify-content: flex-start;- margin-top: ${themeCssVariables.spacing[2]};-`;--const StyledTableRowsContainer = styled.div`- border-bottom: 1px solid ${themeCssVariables.border.color.light};- padding: ${themeCssVariables.spacing[2]} 0;-`;-export const SettingsApplicationConnectionsSection = ({applicationId,}: {@@ -40,7 +28,6 @@ export const SettingsApplicationConnectionsSection = ({}) => {const { t } = useLingui();const theme = useTheme();- const { triggerAppOAuth } = useTriggerAppOAuth();const { connectionProviders, loading } =useFindApplicationConnectionProviders(applicationId);const { accounts: connectedAccounts, loading: accountsLoading } =@@ -53,10 +40,8 @@ export const SettingsApplicationConnectionsSection = ({return (<>{connectionProviders.map((provider) => {- const isOAuth = provider.type === 'oauth';- const isClientCredentialsConfigured =- provider.oauth?.isClientCredentialsConfigured ?? false;- const canStartAuthorization = !isOAuth || isClientCredentialsConfigured;+ const canStartAuthorization =+ canStartConnectionProviderAuthorization(provider);const canAddConnection = provider.scope === 'WORKSPACE';const providerConnections = connectedAccounts.filter(@@ -68,27 +53,15 @@ export const SettingsApplicationConnectionsSection = ({}return (- <Section.Root key={provider.id}>- <Section.Header- title={provider.displayName}- description={t`Manage connections used by this app to call ${provider.displayName}.`}- actions={- isNonEmptyString(provider.logoUrl) ? (- <Avatar- shape="square"- variant="outline"- src={getAbsoluteImageUrl(provider.logoUrl)}- name={provider.displayName}- />- ) : undefined- }- />- {canAddConnection && isOAuth && !isClientCredentialsConfigured && (- <InlineBanner- layout="compact"- status="error"- >{t`${provider.displayName} OAuth is not yet set up by your server administrator. They need to fill in the OAuth client ID and secret on the application registration before you can add a connection.`}</InlineBanner>- )}+ <SettingsApplicationConnectionProviderSection+ key={provider.id}+ providerDisplayName={provider.displayName}+ providerLogoUrl={provider.logoUrl}+ description={t`Manage connections used by this app to call ${provider.displayName}.`}+ shouldShowMissingCredentialsBanner={+ canAddConnection && !canStartAuthorization+ }+ >{providerConnections.length > 0 && (<Table><TableRow@@ -101,7 +74,7 @@ export const SettingsApplicationConnectionsSection = ({<TableHeader>{t`Visibility`}</TableHeader><TableHeader /></TableRow>- <StyledTableRowsContainer>+ <SettingsApplicationConnectionTableRows>{providerConnections.map((connection) => (<TableRowkey={connection.id}@@ -124,14 +97,14 @@ export const SettingsApplicationConnectionsSection = ({textOverflow="ellipsis"whiteSpace="nowrap">- {connection.name ?? connection.handle}+ <SettingsApplicationConnectionName+ connection={connection}+ /></TableCell><TableCell clickable>- {connection.authFailedAt ? (- <Status color="red">{t`Reconnect needed`}</Status>- ) : (- <Status color="green">{t`Connected`}</Status>- )}+ <SettingsApplicationConnectionStatus+ connection={connection}+ /></TableCell><TableCell clickable><Status@@ -157,25 +130,16 @@ export const SettingsApplicationConnectionsSection = ({</TableCell></TableRow>))}- </StyledTableRowsContainer>+ </SettingsApplicationConnectionTableRows></Table>)}{canAddConnection && canStartAuthorization && (- <StyledFooter>- <Button- startIcon={<IconPlus />}- size="sm"- onClick={() =>- triggerAppOAuth({- applicationId,- providerName: provider.name,- })- }- variant="outline"- >{t`Add connection`}</Button>- </StyledFooter>+ <SettingsApplicationAddConnectionButton+ applicationId={applicationId}+ providerName={provider.name}+ />)}- </Section.Root>+ </SettingsApplicationConnectionProviderSection>);})}</>diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/__tests__/SettingsApplicationConnectionsSection.test.tsx b/packages/twenty-front/src/pages/settings/applications/tabs/__tests__/SettingsApplicationConnectionsSection.test.tsxindex a4414effbbc..0b5098afd27 100644--- a/packages/twenty-front/src/pages/settings/applications/tabs/__tests__/SettingsApplicationConnectionsSection.test.tsx+++ b/packages/twenty-front/src/pages/settings/applications/tabs/__tests__/SettingsApplicationConnectionsSection.test.tsx@@ -25,7 +25,7 @@ jest.mock(}),);-jest.mock('~/pages/settings/applications/hooks/useTriggerAppOAuth', () => ({+jest.mock('@/settings/applications/hooks/useTriggerAppOAuth', () => ({useTriggerAppOAuth: jest.fn(() => ({triggerAppOAuth: mockTriggerAppOAuth,})),diff --git a/packages/twenty-front/src/testing/decorators/ComponentWithRouterDecorator.tsx b/packages/twenty-front/src/testing/decorators/ComponentWithRouterDecorator.tsxindex d27ebae3760..675d7d16d93 100644--- a/packages/twenty-front/src/testing/decorators/ComponentWithRouterDecorator.tsx+++ b/packages/twenty-front/src/testing/decorators/ComponentWithRouterDecorator.tsx@@ -56,7 +56,12 @@ export const ComponentWithRouterDecorator: Decorator = (Story, { args }) => {args.routePath &&typeof args.routePath === 'string' &&(args.routeParams === undefined || isRouteParams(args.routeParams))- ? [computeLocation(args.routePath, args.routeParams)]+ ? [+ computeLocation({+ routePath: args.routePath,+ routeParams: args.routeParams,+ }),+ ]: [{ pathname: '/' }],});diff --git a/packages/twenty-front/src/testing/decorators/PageDecorator.tsx b/packages/twenty-front/src/testing/decorators/PageDecorator.tsxindex b39b0e256a4..0547fc34282 100644--- a/packages/twenty-front/src/testing/decorators/PageDecorator.tsx+++ b/packages/twenty-front/src/testing/decorators/PageDecorator.tsx@@ -40,6 +40,7 @@ export type PageDecoratorArgs = {routeParams: RouteParams;additionalRoutes?: string[];searchParams?: RouteParams;+ routeHash?: string;};export type RouteParams = {@@ -54,11 +55,15 @@ export const isRouteParams = (obj: any): obj is RouteParams => {return Object.keys(obj).every((key) => typeof obj[key] === 'string');};-export const computeLocation = (- routePath: string,- routeParams?: RouteParams,- searchParams?: RouteParams,-) => {+export const computeLocation = ({+ routePath,+ routeParams,+ searchParams,+ routeHash = '',+}: Pick<PageDecoratorArgs, 'routePath'> &+ Partial<+ Pick<PageDecoratorArgs, 'routeParams' | 'searchParams' | 'routeHash'>+ >) => {const search = searchParams? `?${new URLSearchParams(searchParams).toString()}`: '';@@ -69,6 +74,7 @@ export const computeLocation = ((paramName) => routeParams?.[paramName] ?? '',),search,+ hash: routeHash,};};@@ -138,6 +144,8 @@ const createRouter = ({};initialEntries?: {pathname: string;+ search?: string;+ hash?: string;}[];initialIndex?: number;}) => {@@ -170,12 +178,18 @@ export const PageDecorator: Decorator<{routeParams: RouteParams;additionalRoutes?: string[];searchParams?: RouteParams;+ routeHash?: string;}> = (Story, { args }) => {const router = createRouter({Story,args,initialEntries: [- computeLocation(args.routePath, args.routeParams, args.searchParams),+ computeLocation({+ routePath: args.routePath,+ routeParams: args.routeParams,+ searchParams: args.searchParams,+ routeHash: args.routeHash,+ }),],});diff --git a/packages/twenty-front/src/testing/utils/withinTableRowOrThrow.ts b/packages/twenty-front/src/testing/utils/withinTableRowOrThrow.tsnew file mode 100644index 00000000000..aedc899adf6--- /dev/null+++ b/packages/twenty-front/src/testing/utils/withinTableRowOrThrow.ts@@ -0,0 +1,20 @@+import { within } from 'storybook/test';+import { isDefined } from 'twenty-shared/utils';++export const withinTableRowOrThrow = ({+ canvasElement,+ text,+}: {+ canvasElement: HTMLElement;+ text: string;+}) => {+ const row = within(canvasElement)+ .getByText(text)+ .closest<HTMLElement>('[data-table-row]');++ if (!isDefined(row)) {+ throw new Error(`No table row for ${text}`);+ }++ return within(row);+};diff --git a/packages/twenty-server/src/engine/core-modules/application/application-preferences/application-preferences.module.ts b/packages/twenty-server/src/engine/core-modules/application/application-preferences/application-preferences.module.tsindex f3d64f32247..afa52173308 100644--- a/packages/twenty-server/src/engine/core-modules/application/application-preferences/application-preferences.module.ts+++ b/packages/twenty-server/src/engine/core-modules/application/application-preferences/application-preferences.module.ts@@ -4,6 +4,7 @@ import { ApplicationPreferencesResolver } from 'src/engine/core-modules/applicatimport { ApplicationPreferencesService } from 'src/engine/core-modules/application/application-preferences/application-preferences.service';import { ApplicationVariableEntityModule } from 'src/engine/core-modules/application/application-variable/application-variable.module';import { ApplicationModule } from 'src/engine/core-modules/application/application.module';+import { ConnectionProviderModule } from 'src/engine/core-modules/application/connection-provider/connection-provider.module';import { PermissionsModule } from 'src/engine/metadata-modules/permissions/permissions.module';import { WorkspaceCacheModule } from 'src/engine/workspace-cache/workspace-cache.module';@@ -11,6 +12,7 @@ import { WorkspaceCacheModule } from 'src/engine/workspace-cache/workspace-cacheimports: [ApplicationModule,ApplicationVariableEntityModule,+ ConnectionProviderModule,PermissionsModule,WorkspaceCacheModule,],diff --git a/packages/twenty-server/src/engine/core-modules/application/application-preferences/application-preferences.service.ts b/packages/twenty-server/src/engine/core-modules/application/application-preferences/application-preferences.service.tsindex 6cfab349323..39e64fb9522 100644--- a/packages/twenty-server/src/engine/core-modules/application/application-preferences/application-preferences.service.ts+++ b/packages/twenty-server/src/engine/core-modules/application/application-preferences/application-preferences.service.ts@@ -5,6 +5,7 @@ import { isNonEmptyArray } from 'twenty-shared/utils';import { type ApplicationPreferencesDTO } from 'src/engine/core-modules/application/application-preferences/dtos/application-preferences.dto';import { UserApplicationVariableValueService } from 'src/engine/core-modules/application/application-variable/user-application-variable-value.service';import { ApplicationService } from 'src/engine/core-modules/application/application.service';+import { ConnectionProviderService } from 'src/engine/core-modules/application/connection-provider/connection-provider.service';import { findFlatEntitiesByApplicationId } from 'src/engine/metadata-modules/flat-entity/utils/find-flat-entities-by-application-id.util';import { fromFlatSettingsMenuItemToSettingsMenuItemDto } from 'src/engine/metadata-modules/flat-settings-menu-item/utils/from-flat-settings-menu-item-to-settings-menu-item-dto.util';import { WorkspaceCacheService } from 'src/engine/workspace-cache/services/workspace-cache.service';@@ -13,6 +14,7 @@ import { WorkspaceCacheService } from 'src/engine/workspace-cache/services/worksexport class ApplicationPreferencesService {constructor(private readonly applicationService: ApplicationService,+ private readonly connectionProviderService: ConnectionProviderService,private readonly userApplicationVariableValueService: UserApplicationVariableValueService,private readonly workspaceCacheService: WorkspaceCacheService,) {}@@ -32,14 +34,25 @@ export class ApplicationPreferencesService {]),]);- const myUserApplicationVariableValuesByApplicationId =- await this.userApplicationVariableValueService.findMyUserApplicationVariableValuesByApplicationId(+ const applicationIds = installedFlatApplications.map(({ id }) => id);++ const [+ myUserApplicationVariableValuesByApplicationId,+ connectionProviders,+ ] = await Promise.all([+ this.userApplicationVariableValueService.findMyUserApplicationVariableValuesByApplicationId({workspaceId,- applicationIds: installedFlatApplications.map(({ id }) => id),+ applicationIds,userWorkspaceId,},- );+ ),+ this.connectionProviderService.findManyDtosByApplications({+ applicationIds,+ workspaceId,+ scope: 'USER',+ }),+ ]);return installedFlatApplications.map(({ id: applicationId }): ApplicationPreferencesDTO => ({@@ -52,10 +65,16 @@ export class ApplicationPreferencesService {.map(fromFlatSettingsMenuItemToSettingsMenuItemDto),variables:myUserApplicationVariableValuesByApplicationId[applicationId],+ connectionProviders: connectionProviders.filter(+ (connectionProvider) =>+ connectionProvider.applicationId === applicationId,+ ),})).filter(- ({ settingsMenuItems, variables }) =>- isNonEmptyArray(settingsMenuItems) || isNonEmptyArray(variables),+ ({ settingsMenuItems, variables, connectionProviders }) =>+ isNonEmptyArray(settingsMenuItems) ||+ isNonEmptyArray(variables) ||+ isNonEmptyArray(connectionProviders),);}}diff --git a/packages/twenty-server/src/engine/core-modules/application/application-preferences/dtos/application-preferences.dto.ts b/packages/twenty-server/src/engine/core-modules/application/application-preferences/dtos/application-preferences.dto.tsindex dc9f9f42b45..a11be672d28 100644--- a/packages/twenty-server/src/engine/core-modules/application/application-preferences/dtos/application-preferences.dto.ts+++ b/packages/twenty-server/src/engine/core-modules/application/application-preferences/dtos/application-preferences.dto.ts@@ -4,6 +4,7 @@ import { IsUUID } from 'class-validator';import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/graphql-types/scalars';import { UserApplicationVariableValueDTO } from 'src/engine/core-modules/application/application-variable/dtos/user-application-variable-value.dto';+import { ApplicationConnectionProviderDTO } from 'src/engine/core-modules/application/connection-provider/dtos/application-connection-provider.dto';import { SettingsMenuItemDTO } from 'src/engine/metadata-modules/settings-menu-item/dtos/settings-menu-item.dto';@ObjectType('ApplicationPreferences')@@ -17,4 +18,7 @@ export class ApplicationPreferencesDTO {@Field(() => [UserApplicationVariableValueDTO])variables: UserApplicationVariableValueDTO[];++ @Field(() => [ApplicationConnectionProviderDTO])+ connectionProviders: ApplicationConnectionProviderDTO[];}diff --git a/packages/twenty-server/src/engine/core-modules/application/connection-provider/application-connection-provider.resolver.ts b/packages/twenty-server/src/engine/core-modules/application/connection-provider/application-connection-provider.resolver.tsindex a5b7ab6143a..04cbb93bdfb 100644--- a/packages/twenty-server/src/engine/core-modules/application/connection-provider/application-connection-provider.resolver.ts+++ b/packages/twenty-server/src/engine/core-modules/application/connection-provider/application-connection-provider.resolver.ts@@ -47,34 +47,10 @@ export class ApplicationConnectionProviderResolver {applicationId: string,@AuthWorkspace() workspace: WorkspaceEntity,): Promise<ApplicationConnectionProviderDTO[]> {- const providers = await this.oauthProviderService.findManyByApplication({- applicationId,+ return this.oauthProviderService.findManyDtosByApplications({+ applicationIds: [applicationId],workspaceId: workspace.id,});-- const credentialsConfiguredByProviderId =- await this.oauthProviderService.areClientCredentialsConfiguredBatch({- providers,- workspaceId: workspace.id,- });-- return providers.map((provider) => ({- id: provider.id,- applicationId: provider.applicationId,- type: provider.type,- name: provider.name,- displayName: provider.displayName,- scope: provider.scope,- logo: provider.logo,- oauth:- provider.type === 'oauth' && provider.oauthConfig- ? {- scopes: provider.oauthConfig.scopes,- isClientCredentialsConfigured:- credentialsConfiguredByProviderId.get(provider.id) ?? false,- }- : null,- }));}@ResolveField(() => String, { nullable: true })diff --git a/packages/twenty-server/src/engine/core-modules/application/connection-provider/connection-provider.service.ts b/packages/twenty-server/src/engine/core-modules/application/connection-provider/connection-provider.service.tsindex 2118c38899a..6bb1bf6fa35 100644--- a/packages/twenty-server/src/engine/core-modules/application/connection-provider/connection-provider.service.ts+++ b/packages/twenty-server/src/engine/core-modules/application/connection-provider/connection-provider.service.ts@@ -1,7 +1,8 @@import { Injectable } from '@nestjs/common';import { InjectRepository } from '@nestjs/typeorm';-import { isDefined } from 'twenty-shared/utils';+import { type ConnectionProviderScope } from 'twenty-shared/application';+import { isDefined, isNonEmptyArray } from 'twenty-shared/utils';import { In, Repository } from 'typeorm';import { ApplicationRegistrationVariableEntity } from 'src/engine/core-modules/application/application-registration-variable/application-registration-variable.entity';@@ -9,6 +10,7 @@ import { ApplicationEntity } from 'src/engine/core-modules/application/applicatiimport { ConnectionProviderExceptionCode } from 'src/engine/core-modules/application/connection-provider/connection-provider-exception-code.enum';import { ConnectionProviderEntity } from 'src/engine/core-modules/application/connection-provider/connection-provider.entity';import { ConnectionProviderException } from 'src/engine/core-modules/application/connection-provider/connection-provider.exception';+import { type ApplicationConnectionProviderDTO } from 'src/engine/core-modules/application/connection-provider/dtos/application-connection-provider.dto';import { assertOAuthProvider } from 'src/engine/core-modules/application/connection-provider/utils/assert-oauth-provider.util';import { SecretEncryptionService } from 'src/engine/core-modules/secret-encryption/secret-encryption.service';import { InjectWorkspaceScopedRepository } from 'src/engine/twenty-orm/workspace-scoped-repository/inject-workspace-scoped-repository.decorator';@@ -217,15 +219,51 @@ export class ConnectionProviderService {return provider;}- async findManyByApplication({- applicationId,+ async findManyDtosByApplications({+ applicationIds,workspaceId,+ scope,}: {- applicationId: string;+ applicationIds: string[];workspaceId: string;- }): Promise<ConnectionProviderEntity[]> {- return this.connectionProviderRepository.find(workspaceId, {- where: { applicationId },- });+ scope?: ConnectionProviderScope;+ }): Promise<ApplicationConnectionProviderDTO[]> {+ if (!isNonEmptyArray(applicationIds)) {+ return [];+ }++ const providers = await this.connectionProviderRepository.find(+ workspaceId,+ {+ where: {+ applicationId: In(applicationIds),+ ...(isDefined(scope) ? { scope } : {}),+ },+ },+ );++ const credentialsConfiguredByProviderId =+ await this.areClientCredentialsConfiguredBatch({+ providers,+ workspaceId,+ });++ return providers.map((provider) => ({+ id: provider.id,+ applicationId: provider.applicationId,+ type: provider.type,+ name: provider.name,+ displayName: provider.displayName,+ scope: provider.scope,+ logo: provider.logo,+ oauth:+ provider.type === 'oauth' && isDefined(provider.oauthConfig)+ ? {+ scopes: provider.oauthConfig.scopes,+ isClientCredentialsConfigured:+ credentialsConfiguredByProviderId.get(provider.id) ?? false,+ }+ : null,+ }));}}diff --git a/packages/twenty-server/test/integration/metadata/suites/application/successful-application-preferences.integration-spec.ts b/packages/twenty-server/test/integration/metadata/suites/application/successful-application-preferences.integration-spec.tsindex c8139b93a09..6ac19d33a3d 100644--- a/packages/twenty-server/test/integration/metadata/suites/application/successful-application-preferences.integration-spec.ts+++ b/packages/twenty-server/test/integration/metadata/suites/application/successful-application-preferences.integration-spec.ts@@ -11,10 +11,13 @@ import { setupApplicationForSync } from 'test/integration/metadata/suites/applicimport { syncApplication } from 'test/integration/metadata/suites/application/utils/sync-application.util';import { updateMyUserApplicationVariable } from 'test/integration/metadata/suites/application/utils/update-my-user-application-variable.util';import { uploadBuiltFrontComponentFile } from 'test/integration/metadata/suites/application/utils/upload-built-front-component-file.util';+import { type ConnectionProviderManifest } from 'twenty-shared/application';import { v4 as uuidv4 } from 'uuid';import { type ApplicationPreferencesDTO } from 'src/engine/core-modules/application/application-preferences/dtos/application-preferences.dto';import { SECRET_APPLICATION_VARIABLE_MASK } from 'src/engine/core-modules/application/application-variable/constants/secret-application-variable-mask.constant';+import { ConfigVariables } from 'src/engine/core-modules/twenty-config/config-variables';+import { SEED_APPLE_WORKSPACE_ID } from 'src/engine/workspace-manager/dev-seeder/core/constants/seeder-workspaces.constant';const APPLICATION_UNIVERSAL_IDENTIFIER = uuidv4();const ROLE_UNIVERSAL_IDENTIFIER = uuidv4();@@ -23,8 +26,53 @@ const WORKSPACE_FRONT_COMPONENT_UNIVERSAL_IDENTIFIER = uuidv4();const USER_SETTINGS_MENU_ITEM_UNIVERSAL_IDENTIFIER = uuidv4();const WORKSPACE_SETTINGS_MENU_ITEM_UNIVERSAL_IDENTIFIER = uuidv4();+const CONNECTION_ONLY_APPLICATION_UNIVERSAL_IDENTIFIER = uuidv4();+const CONNECTION_ONLY_ROLE_UNIVERSAL_IDENTIFIER = uuidv4();+const APPLICATION_NAME = 'Application preferences A';+const buildOAuthConnectionProvider = ({+ name,+ displayName,+ scope,+ logo,+}: Pick<+ ConnectionProviderManifest,+ 'name' | 'displayName' | 'scope' | 'logo'+>): ConnectionProviderManifest => ({+ universalIdentifier: uuidv4(),+ name,+ displayName,+ type: 'oauth',+ scope,+ logo,+ oauth: {+ authorizationEndpoint: `https://${name}.example.com/oauth/authorize`,+ tokenEndpoint: `https://${name}.example.com/oauth/token`,+ scopes: ['read'],+ clientIdVariable: `${name.toUpperCase()}_CLIENT_ID`,+ clientSecretVariable: `${name.toUpperCase()}_CLIENT_SECRET`,+ },+});++const buildExpectedUserConnectionProvider = ({+ name,+ displayName,+ logoUrl = null,+}: {+ name: string;+ displayName: string;+ logoUrl?: string | null;+}) => ({+ id: expect.any(String),+ name,+ displayName,+ scope: 'USER',+ type: 'oauth',+ logoUrl,+ oauth: { scopes: ['read'], isClientCredentialsConfigured: false },+});+const findPreferencesOf = (applicationPreferences: ApplicationPreferencesDTO[],applicationId: string,@@ -42,6 +90,7 @@ const sortByApplicationId = <PreferencesLike extends { applicationId: string }>(describe('My application preferences should succeed', () => {let applicationId: string;+ let connectionOnlyApplicationId: string;let otherUserApplication: ApplicationWithVariable;let workspaceOnlyApplication: ApplicationWithVariable;@@ -125,6 +174,18 @@ describe('My application preferences should succeed', () => {position: 2,},],+ connectionProviders: [+ buildOAuthConnectionProvider({+ name: 'linear',+ displayName: 'Linear',+ scope: 'USER',+ }),+ buildOAuthConnectionProvider({+ name: 'slack',+ displayName: 'Slack',+ scope: 'WORKSPACE',+ }),+ ],},}),expectToFail: false,@@ -147,6 +208,50 @@ describe('My application preferences should succeed', () => {name: 'Application preferences C',variableKey: 'RECORD_ALL_MEETINGS',});++ await setupApplicationForSync({+ applicationUniversalIdentifier:+ CONNECTION_ONLY_APPLICATION_UNIVERSAL_IDENTIFIER,+ name: 'Application preferences D',+ description: 'App whose only user preference is a connection',+ sourcePath: 'application-preferences-connection-only',+ });+ await syncApplication({+ manifest: buildBaseManifest({+ appId: CONNECTION_ONLY_APPLICATION_UNIVERSAL_IDENTIFIER,+ roleId: CONNECTION_ONLY_ROLE_UNIVERSAL_IDENTIFIER,+ overrides: {+ roles: [+ {+ universalIdentifier: CONNECTION_ONLY_ROLE_UNIVERSAL_IDENTIFIER,+ label: 'Application preferences D role',+ description: 'A test role',+ },+ ],+ connectionProviders: [+ buildOAuthConnectionProvider({+ name: 'github',+ displayName: 'GitHub',+ scope: 'USER',+ logo: 'public/github-logomark.svg',+ }),+ ],+ },+ }),+ expectToFail: false,+ });+ jest.useRealTimers();++ const { data: connectionOnlyApplicationData } = await findOneApplication({+ input: {+ universalIdentifier: CONNECTION_ONLY_APPLICATION_UNIVERSAL_IDENTIFIER,+ },+ gqlFields: 'id',+ expectToFail: false,+ });++ connectionOnlyApplicationId =+ connectionOnlyApplicationData.findOneApplication.id;}, 180000);afterAll(async () => {@@ -160,6 +265,10 @@ describe('My application preferences should succeed', () => {applicationUniversalIdentifier:workspaceOnlyApplication.universalIdentifier,});+ await cleanupApplicationAndAppRegistration({+ applicationUniversalIdentifier:+ CONNECTION_ONLY_APPLICATION_UNIVERSAL_IDENTIFIER,+ });});it('should give a member without the Workspace Apps permission the user settings and defaults of every application that has some', async () => {@@ -173,6 +282,7 @@ describe('My application preferences should succeed', () => {applicationId,otherUserApplication.id,workspaceOnlyApplication.id,+ connectionOnlyApplicationId,];expect(@@ -201,6 +311,12 @@ describe('My application preferences should succeed', () => {{ key: 'PERSONAL_API_KEY', value: '', isSecret: true },{ key: 'LANGUAGE', value: 'en', isSecret: false },]),+ connectionProviders: [+ buildExpectedUserConnectionProvider({+ name: 'linear',+ displayName: 'Linear',+ }),+ ],},{applicationId: otherUserApplication.id,@@ -208,6 +324,19 @@ describe('My application preferences should succeed', () => {variables: [{ key: 'RECORD_MY_MEETINGS', value: '', isSecret: false },],+ connectionProviders: [],+ },+ {+ applicationId: connectionOnlyApplicationId,+ settingsMenuItems: [],+ variables: [],+ connectionProviders: [+ buildExpectedUserConnectionProvider({+ name: 'github',+ displayName: 'GitHub',+ logoUrl: `${process.env.SERVER_URL ?? new ConfigVariables().SERVER_URL}/public-assets/${SEED_APPLE_WORKSPACE_ID}/${connectionOnlyApplicationId}/public/github-logomark.svg`,+ }),+ ],},]),);diff --git a/packages/twenty-server/test/integration/metadata/suites/application/utils/my-application-preferences-query-factory.util.ts b/packages/twenty-server/test/integration/metadata/suites/application/utils/my-application-preferences-query-factory.util.tsindex c0b30124f49..fceaf5d2cb0 100644--- a/packages/twenty-server/test/integration/metadata/suites/application/utils/my-application-preferences-query-factory.util.ts+++ b/packages/twenty-server/test/integration/metadata/suites/application/utils/my-application-preferences-query-factory.util.ts@@ -18,6 +18,18 @@ const DEFAULT_MY_APPLICATION_PREFERENCES_GQL_FIELDS = `valueisSecret}+ connectionProviders {+ id+ name+ displayName+ scope+ type+ logoUrl+ oauth {+ scopes+ isClientCredentialsConfigured+ }+ }`;export const myApplicationPreferencesQueryFactory = ({