Skip to content

The open alternative to Salesforce, designed for AI.

Split Apps preferences into Apps and Accounts tabs (#28987)

nitin636b32918d35
diff --git a/packages/twenty-agent-skills/references/develop-app/layout.md b/packages/twenty-agent-skills/references/develop-app/layout.md
index 37a6c6eea8f..e5242151fbb 100644
--- a/packages/twenty-agent-skills/references/develop-app/layout.md
+++ b/packages/twenty-agent-skills/references/develop-app/layout.md
@@ -60,7 +60,7 @@ To add an entry to an app's settings menu, declare it with `defineSettingsMenuIt
The menu item points at the component, not the reverse, so one component can back several items. Declare as many as the app needs. Each renders as a tab on the app's page under Settings > Apps, after the built-in General tab, in `position` order.
-`scope` is `WORKSPACE` (configured once for the whole workspace, the default) or `USER` (configured by each member for themselves). A `USER` item renders as a tab on the app's page under the member's Settings > App preferences, but that page is not enabled in every workspace yet — where it is not, the item is persisted and synced but nothing displays it, so say so rather than relying on a `USER` item for a settings entry every workspace needs visible now. To store something per person, a `USER` item should use an application variable declared with `scope: 'USER'`, which `getApplicationVariable` returns with the viewing member's value unless it is secret; the component saves it with `updateMyUserApplicationVariable`, which writes the viewing member's value only (an empty value resets it to the variable's default), refuses a token with nobody behind it, and needs `SystemPermissionFlag.CONNECTED_ACCOUNTS` in the app's default role, if it declares one (and in the member's role, since the component's token is the intersection of both), and since a `USER` item replaces the generated Variables form like a `WORKSPACE` item does, it should let the member set every user variable the app needs; a variable without that scope holds one value shared by the whole workspace.
+`scope` is `WORKSPACE` (configured once for the whole workspace, the default) or `USER` (configured by each member for themselves). A `USER` item renders as a tab on the app's page under the member's Settings > Apps preferences, but that page is not enabled in every workspace yet — where it is not, the item is persisted and synced but nothing displays it, so say so rather than relying on a `USER` item for a settings entry every workspace needs visible now. To store something per person, a `USER` item should use an application variable declared with `scope: 'USER'`, which `getApplicationVariable` returns with the viewing member's value unless it is secret; the component saves it with `updateMyUserApplicationVariable`, which writes the viewing member's value only (an empty value resets it to the variable's default), refuses a token with nobody behind it, and needs `SystemPermissionFlag.CONNECTED_ACCOUNTS` in the app's default role, if it declares one (and in the member's role, since the component's token is the intersection of both), and since a `USER` item replaces the generated Variables form like a `WORKSPACE` item does, it should let the member set every user variable the app needs; a variable without that scope holds one value shared by the whole workspace.
Items sort by ascending `position`, which is a decimal so an item can be slotted between two existing ones. Two items of one app cannot share a position in the same scope, and `General` is reserved for the built-in item.
diff --git a/packages/twenty-agent-skills/references/develop-app/logic.md b/packages/twenty-agent-skills/references/develop-app/logic.md
index e9ab48d124d..5a5987e1d4e 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 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" }`.
+- 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 > Apps 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 Providers
diff --git a/packages/twenty-docs/developers/extend/apps/config/application.mdx b/packages/twenty-docs/developers/extend/apps/config/application.mdx
index 99707d6eb9e..feb1decd449 100644
--- a/packages/twenty-docs/developers/extend/apps/config/application.mdx
+++ b/packages/twenty-docs/developers/extend/apps/config/application.mdx
@@ -163,7 +163,7 @@ A variable's scope is set when it is created and cannot change. To change it, de
User variables can be `isSecret`, `isRequired`, or both. For example, a personal API key can declare `scope: 'USER', isSecret: true, isRequired: true`. Values are encrypted at rest.
-For user variables, `isRequired` describes a per-member requirement. A member with no value for it, their own or a default, sees your app marked **Missing configuration** in App preferences, with a banner naming the variables. It does not affect the workspace configuration warning, and nothing enforces it at runtime: your code still decides what an unset value means.
+For user variables, `isRequired` describes a per-member requirement. A member with no value for it, their own or a default, sees your app marked **Missing configuration** in Apps preferences, with a banner naming the variables. It does not affect the workspace configuration warning, and nothing enforces it at runtime: your code still decides what an unset value means.
A user variable is injected with the value of the member your code runs for, or its default until they set their own:
diff --git a/packages/twenty-docs/developers/extend/apps/logic/connections.mdx b/packages/twenty-docs/developers/extend/apps/logic/connections.mdx
index ad798a4997a..76402d289c2 100644
--- a/packages/twenty-docs/developers/extend/apps/logic/connections.mdx
+++ b/packages/twenty-docs/developers/extend/apps/logic/connections.mdx
@@ -508,10 +508,10 @@ Each connection has one of two scopes:
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 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.
+- `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 > Apps 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,
+ **Apps 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>
diff --git a/packages/twenty-front/src/modules/settings/accounts/hooks/__tests__/useTriggerProviderReconnect.test.tsx b/packages/twenty-front/src/modules/settings/accounts/hooks/__tests__/useTriggerProviderReconnect.test.tsx
index 93c0ac8508f..8771d57d1e8 100644
--- a/packages/twenty-front/src/modules/settings/accounts/hooks/__tests__/useTriggerProviderReconnect.test.tsx
+++ b/packages/twenty-front/src/modules/settings/accounts/hooks/__tests__/useTriggerProviderReconnect.test.tsx
@@ -126,7 +126,7 @@ describe('useTriggerProviderReconnect', () => {
expect(mockNavigate).not.toHaveBeenCalled();
});
- it('should trigger OAuth for Google provider with options', async () => {
+ it('should let the caller pick where Google OAuth returns', async () => {
const { result } = renderHook(() => useTriggerProviderReconnect());
const options = {
@@ -146,15 +146,12 @@ describe('useTriggerProviderReconnect', () => {
expect(mockTriggerApisOAuth).toHaveBeenCalledWith(
ConnectedAccountProvider.GOOGLE,
- {
- ...options,
- redirectLocation: '/settings/accounts',
- },
+ options,
);
expect(mockNavigate).not.toHaveBeenCalled();
});
- it('should trigger OAuth for Microsoft provider with options', async () => {
+ it('should let the caller pick where Microsoft OAuth returns', async () => {
const { result } = renderHook(() => useTriggerProviderReconnect());
const options = {
@@ -173,10 +170,7 @@ describe('useTriggerProviderReconnect', () => {
expect(mockTriggerApisOAuth).toHaveBeenCalledWith(
ConnectedAccountProvider.MICROSOFT,
- {
- ...options,
- redirectLocation: '/settings/accounts',
- },
+ options,
);
expect(mockNavigate).not.toHaveBeenCalled();
});
diff --git a/packages/twenty-front/src/modules/settings/accounts/hooks/useAccountsConfigurationCompletionPath.ts b/packages/twenty-front/src/modules/settings/accounts/hooks/useAccountsConfigurationCompletionPath.ts
new file mode 100644
index 00000000000..9f379c508d4
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/accounts/hooks/useAccountsConfigurationCompletionPath.ts
@@ -0,0 +1,30 @@
+import { useMyConnectedAccounts } from '@/settings/accounts/hooks/useMyConnectedAccounts';
+import { BUILT_IN_ACCOUNT_APPS } from '@/settings/app-preferences/constants/BuiltInAccountApps';
+import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
+import { SettingsPath } from 'twenty-shared/types';
+import { getSettingsPath, isDefined } from 'twenty-shared/utils';
+import { FeatureFlagKey } from '~/generated-metadata/graphql';
+
+export const useAccountsConfigurationCompletionPath = (
+ connectedAccountId?: string,
+) => {
+ const isAppPreferencesEnabled = useIsFeatureEnabled(
+ FeatureFlagKey.IS_APP_PREFERENCES_ENABLED,
+ );
+ const { accounts } = useMyConnectedAccounts();
+
+ const connectedAccount = accounts.find(
+ (account) => account.id === connectedAccountId,
+ );
+ const builtInAccountApp = BUILT_IN_ACCOUNT_APPS.find(
+ (app) => app.provider === connectedAccount?.provider,
+ );
+
+ if (isAppPreferencesEnabled && isDefined(builtInAccountApp)) {
+ return getSettingsPath(SettingsPath.BuiltInAccountApp, {
+ builtInAccountAppId: builtInAccountApp.id,
+ });
+ }
+
+ return getSettingsPath(SettingsPath.Accounts);
+};
diff --git a/packages/twenty-front/src/modules/settings/accounts/hooks/useTriggerProviderReconnect.ts b/packages/twenty-front/src/modules/settings/accounts/hooks/useTriggerProviderReconnect.ts
index d7f43b74407..ae32bd4098f 100644
--- a/packages/twenty-front/src/modules/settings/accounts/hooks/useTriggerProviderReconnect.ts
+++ b/packages/twenty-front/src/modules/settings/accounts/hooks/useTriggerProviderReconnect.ts
@@ -28,8 +28,8 @@ export const useTriggerProviderReconnect = () => {
}
await triggerApisOAuth(provider, {
- ...options,
redirectLocation: getSettingsPath(SettingsPath.Accounts),
+ ...options,
});
},
[triggerApisOAuth, navigate],
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAccountGroupsEmptyState.tsx b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAccountGroupsEmptyState.tsx
new file mode 100644
index 00000000000..fc9fdb19ebd
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAccountGroupsEmptyState.tsx
@@ -0,0 +1,31 @@
+import { SettingsAppPreferencesListEmptyStateCard } from '@/settings/app-preferences/components/SettingsAppPreferencesListEmptyStateCard';
+import { type BuiltInAccountApp } from '@/settings/app-preferences/types/BuiltInAccountApp';
+import { styled } from '@linaria/react';
+import { useLingui } from '@lingui/react/macro';
+import { isDefined } from 'twenty-shared/utils';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+const StyledEmptyState = styled.div`
+ color: ${themeCssVariables.font.color.tertiary};
+ font-size: ${themeCssVariables.font.size.md};
+`;
+
+type SettingsAccountGroupsEmptyStateProps = {
+ builtInAccountApp?: BuiltInAccountApp;
+};
+
+export const SettingsAccountGroupsEmptyState = ({
+ builtInAccountApp,
+}: SettingsAccountGroupsEmptyStateProps) => {
+ const { t } = useLingui();
+
+ if (isDefined(builtInAccountApp)) {
+ return (
+ <SettingsAppPreferencesListEmptyStateCard
+ provider={builtInAccountApp.provider}
+ />
+ );
+ }
+
+ return <StyledEmptyState>{t`No accounts yet`}</StyledEmptyState>;
+};
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAccountGroupsSection.tsx b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAccountGroupsSection.tsx
index 592fc07129d..514faa6ee1f 100644
--- a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAccountGroupsSection.tsx
+++ b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAccountGroupsSection.tsx
@@ -1,17 +1,18 @@
import { SettingsAccountGroupTableRow } from '@/settings/app-preferences/components/SettingsAccountGroupTableRow';
-import { SettingsAppPreferencesListEmptyStateCard } from '@/settings/app-preferences/components/SettingsAppPreferencesListEmptyStateCard';
+import { SettingsAccountGroupsEmptyState } from '@/settings/app-preferences/components/SettingsAccountGroupsEmptyState';
import { SETTINGS_ACCOUNT_GROUP_TABLE_GRID_TEMPLATE_COLUMNS } from '@/settings/app-preferences/constants/SettingsAccountGroupTableGridTemplateColumns';
import { SETTINGS_BUILT_IN_ACCOUNT_APP_ACCOUNT_GROUP_TABLE_GRID_TEMPLATE_COLUMNS } from '@/settings/app-preferences/constants/SettingsBuiltInAccountAppAccountGroupTableGridTemplateColumns';
import { useMyAccountGroups } from '@/settings/app-preferences/hooks/useMyAccountGroups';
import { type BuiltInAccountApp } from '@/settings/app-preferences/types/BuiltInAccountApp';
import { getBuiltInAccountAppsUsingAccount } from '@/settings/app-preferences/utils/getBuiltInAccountAppsUsingAccount';
+import { useTriggerApisOAuth } from '@/settings/accounts/hooks/useTriggerApiOAuth';
import { SettingsTableRowsSkeletonLoader } from '@/settings/components/SettingsTableRowsSkeletonLoader';
import { Table } from '@/ui/layout/table/components/Table';
import { TableHeader } from '@/ui/layout/table/components/TableHeader';
import { TableRow } from '@/ui/layout/table/components/TableRow';
import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
-import { SettingsPath } from 'twenty-shared/types';
+import { ConnectedAccountProvider, SettingsPath } from 'twenty-shared/types';
import { isDefined } from 'twenty-shared/utils';
import { Section } from 'twenty-ui/components/layout';
import { IconPlus } from 'twenty-ui/icon';
@@ -40,6 +41,7 @@ export const SettingsAccountGroupsSection = ({
}: SettingsAccountGroupsSectionProps) => {
const { t } = useLingui();
const navigateSettings = useNavigateSettings();
+ const { triggerApisOAuth } = useTriggerApisOAuth();
const { groups: allGroups, loading } = useMyAccountGroups();
const groups = isDefined(builtInAccountApp)
@@ -66,6 +68,15 @@ export const SettingsAccountGroupsSection = ({
</TableRow>
);
+ const addBuiltInAccount = (app: BuiltInAccountApp) => {
+ if (app.provider === ConnectedAccountProvider.IMAP_SMTP_CALDAV) {
+ navigateSettings(SettingsPath.NewImapSmtpCaldavConnection);
+ return;
+ }
+
+ triggerApisOAuth(app.provider);
+ };
+
return (
<Section.Root>
<Section.Header
@@ -87,8 +98,8 @@ export const SettingsAccountGroupsSection = ({
/>
</Table>
) : groups.length === 0 ? (
- <SettingsAppPreferencesListEmptyStateCard
- provider={builtInAccountApp?.provider}
+ <SettingsAccountGroupsEmptyState
+ builtInAccountApp={builtInAccountApp}
/>
) : (
<>
@@ -105,14 +116,16 @@ export const SettingsAccountGroupsSection = ({
))}
</StyledTableRows>
</Table>
- <StyledAddAccountContainer>
- <Button
- startIcon={<IconPlus />}
- size="sm"
- onClick={() => navigateSettings(SettingsPath.NewAccount)}
- variant="outline"
- >{t`Add account`}</Button>
- </StyledAddAccountContainer>
+ {isDefined(builtInAccountApp) && (
+ <StyledAddAccountContainer>
+ <Button
+ startIcon={<IconPlus />}
+ size="sm"
+ onClick={() => addBuiltInAccount(builtInAccountApp)}
+ variant="outline"
+ >{t`Add account`}</Button>
+ </StyledAddAccountContainer>
+ )}
</>
)}
</Section.Root>
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAccountsTab.tsx b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAccountsTab.tsx
new file mode 100644
index 00000000000..d8509a478b9
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAccountsTab.tsx
@@ -0,0 +1,17 @@
+import { SettingsAccountsBlocklistSection } from '@/settings/accounts/components/SettingsAccountsBlocklistSection';
+import { SettingsAccountGroupsSection } from '@/settings/app-preferences/components/SettingsAccountGroupsSection';
+import { useEnabledBuiltInAccountApps } from '@/settings/app-preferences/hooks/useEnabledBuiltInAccountApps';
+import { isNonEmptyArray } from 'twenty-shared/utils';
+
+export const SettingsAppPreferencesAccountsTab = () => {
+ const { enabledBuiltInAccountApps } = useEnabledBuiltInAccountApps();
+
+ return (
+ <>
+ <SettingsAccountGroupsSection />
+ {!isNonEmptyArray(enabledBuiltInAccountApps) && (
+ <SettingsAccountsBlocklistSection />
+ )}
+ </>
+ );
+};
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAppsSection.tsx b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAppsSection.tsx
index 79d18ba0ce3..2e47b1fbb13 100644
--- a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAppsSection.tsx
+++ b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAppsSection.tsx
@@ -41,7 +41,7 @@ export const SettingsAppPreferencesAppsSection = () => {
return (
<SettingsTableListSection<AppPreferencesRow>
- title={t`App preferences`}
+ title={t`Apps`}
description={t`Choose your preferences for the apps installed on your workspace by the admin`}
toolbar={
hasApplicationsLoadError ? (
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesListEmptyStateCard.tsx b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesListEmptyStateCard.tsx
index c49df204b51..d554271d9bb 100644
--- a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesListEmptyStateCard.tsx
+++ b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesListEmptyStateCard.tsx
@@ -9,7 +9,7 @@ import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomState
import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
import { ConnectedAccountProvider, SettingsPath } from 'twenty-shared/types';
-import { getSettingsPath, isDefined } from 'twenty-shared/utils';
+import { getSettingsPath } from 'twenty-shared/utils';
import { IconAt, IconGoogle, IconMicrosoft } from 'twenty-ui/icon';
import { useTheme, themeCssVariables } from 'twenty-ui/theme';
@@ -20,7 +20,7 @@ const StyledCardsContainer = styled.div`
`;
type SettingsAppPreferencesListEmptyStateCardProps = {
- provider?: ConnectedAccountProvider;
+ provider: ConnectedAccountProvider;
};
export const SettingsAppPreferencesListEmptyStateCard = ({
@@ -51,7 +51,7 @@ export const SettingsAppPreferencesListEmptyStateCard = ({
);
const isProviderShown = (shownProvider: ConnectedAccountProvider) =>
- !isDefined(provider) || provider === shownProvider;
+ provider === shownProvider;
return (
<StyledCardsContainer>
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesRowDropdownMenu.tsx b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesRowDropdownMenu.tsx
index 17d383c62c6..e38a28202ad 100644
--- a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesRowDropdownMenu.tsx
+++ b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesRowDropdownMenu.tsx
@@ -24,7 +24,7 @@ import {
} from 'twenty-ui/icon';
import { LightIconButton } from 'twenty-ui/components/input';
import { Dropdown } from 'twenty-ui/components/navigation';
-import { Link } from 'react-router-dom';
+import { Link, useLocation } from 'react-router-dom';
import { DELETE_CONNECTED_ACCOUNT } from '@/settings/accounts/graphql/mutations/deleteConnectedAccount';
import { DISCONNECT_CONNECTED_ACCOUNT } from '@/settings/accounts/graphql/mutations/disconnectConnectedAccount';
import { isConnectedAccountEligibleForProviderReconnect } from '@/settings/accounts/utils/isConnectedAccountEligibleForProviderReconnect';
@@ -52,6 +52,7 @@ export const SettingsAppPreferencesRowDropdownMenu = ({
DISCONNECT_CONNECTED_ACCOUNT,
);
const { triggerProviderReconnect } = useTriggerProviderReconnect();
+ const { pathname, hash } = useLocation();
const hasPendingConfiguration =
account.messageChannels.some(
@@ -125,6 +126,7 @@ export const SettingsAppPreferencesRowDropdownMenu = ({
onClick={() => {
triggerProviderReconnect(account.provider, account.id, {
loginHint: account.handle,
+ redirectLocation: `${pathname}${hash}`,
});
}}
>{t`Reconnect`}</Dropdown.ActionItem>
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesSections.tsx b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesSections.tsx
deleted file mode 100644
index 19d88373ae3..00000000000
--- a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesSections.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-import { SettingsAccountsBlocklistSection } from '@/settings/accounts/components/SettingsAccountsBlocklistSection';
-import { SettingsAccountGroupsSection } from '@/settings/app-preferences/components/SettingsAccountGroupsSection';
-import { SettingsAppPreferencesAppsSection } from '@/settings/app-preferences/components/SettingsAppPreferencesAppsSection';
-import { useApplicationsWithPreferences } from '@/settings/app-preferences/hooks/useApplicationsWithPreferences';
-import { useEnabledBuiltInAccountApps } from '@/settings/app-preferences/hooks/useEnabledBuiltInAccountApps';
-import { isNonEmptyArray } from 'twenty-shared/utils';
-
-export const SettingsAppPreferencesSections = () => {
- const { enabledBuiltInAccountApps } = useEnabledBuiltInAccountApps();
- const { applicationsWithPreferences, hasApplicationsLoadError } =
- useApplicationsWithPreferences();
-
- const hasBuiltInAccountApps = isNonEmptyArray(enabledBuiltInAccountApps);
-
- return (
- <>
- <SettingsAccountGroupsSection />
- {(hasBuiltInAccountApps ||
- isNonEmptyArray(applicationsWithPreferences) ||
- hasApplicationsLoadError) && <SettingsAppPreferencesAppsSection />}
- {!hasBuiltInAccountApps && <SettingsAccountsBlocklistSection />}
- </>
- );
-};
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/constants/SettingsAppPreferencesTabIds.ts b/packages/twenty-front/src/modules/settings/app-preferences/constants/SettingsAppPreferencesTabIds.ts
new file mode 100644
index 00000000000..d0523a48c70
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/app-preferences/constants/SettingsAppPreferencesTabIds.ts
@@ -0,0 +1,4 @@
+export const SETTINGS_APP_PREFERENCES_TAB_IDS = {
+ APPS: 'apps',
+ ACCOUNTS: 'accounts',
+} as const;
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/constants/SettingsAppPreferencesTabListComponentId.ts b/packages/twenty-front/src/modules/settings/app-preferences/constants/SettingsAppPreferencesTabListComponentId.ts
new file mode 100644
index 00000000000..85b4a25f4d4
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/app-preferences/constants/SettingsAppPreferencesTabListComponentId.ts
@@ -0,0 +1,2 @@
+export const SETTINGS_APP_PREFERENCES_TAB_LIST_COMPONENT_ID =
+ 'settings-app-preferences-tab-list';
diff --git a/packages/twenty-front/src/modules/settings/hooks/__tests__/useSettingsNavigationItems.test.tsx b/packages/twenty-front/src/modules/settings/hooks/__tests__/useSettingsNavigationItems.test.tsx
index e6583d749bb..0957d3415d3 100644
--- a/packages/twenty-front/src/modules/settings/hooks/__tests__/useSettingsNavigationItems.test.tsx
+++ b/packages/twenty-front/src/modules/settings/hooks/__tests__/useSettingsNavigationItems.test.tsx
@@ -219,7 +219,7 @@ describe('useSettingsNavigationItems', () => {
]);
});
- it('should show App preferences without sub-items when app preferences are on', () => {
+ it('should show Apps preferences without sub-items when app preferences are on', () => {
setPermissionFlags([PermissionFlagType.CONNECTED_ACCOUNTS]);
jotaiStore.set(currentWorkspaceState.atom, {
...mockCurrentWorkspace,
@@ -230,7 +230,7 @@ describe('useSettingsNavigationItems', () => {
const accountsItem = getAccountsItem();
- expect(accountsItem?.label).toBe('App preferences');
+ expect(accountsItem?.label).toBe('Apps preferences');
expect(accountsItem?.Icon).toBe(IconApps);
expect(accountsItem?.isHidden).toBe(false);
expect(accountsItem?.subItems).toBeUndefined();
diff --git a/packages/twenty-front/src/modules/settings/hooks/useSettingsNavigationItems.tsx b/packages/twenty-front/src/modules/settings/hooks/useSettingsNavigationItems.tsx
index 51282fd8779..f66aba19544 100644
--- a/packages/twenty-front/src/modules/settings/hooks/useSettingsNavigationItems.tsx
+++ b/packages/twenty-front/src/modules/settings/hooks/useSettingsNavigationItems.tsx
@@ -92,7 +92,7 @@ const useSettingsNavigationItems = (): SettingsNavigationSection[] => {
Icon: IconColorSwatch,
},
{
- label: isAppPreferencesEnabled ? t`App preferences` : t`Accounts`,
+ label: isAppPreferencesEnabled ? t`Apps preferences` : t`Accounts`,
path: SettingsPath.Accounts,
Icon: isAppPreferencesEnabled ? IconApps : IconAt,
isHidden: !permissionFlagMap[PermissionFlagType.CONNECTED_ACCOUNTS],
diff --git a/packages/twenty-front/src/pages/settings/accounts/SettingsAccountDetail.tsx b/packages/twenty-front/src/pages/settings/accounts/SettingsAccountDetail.tsx
index 8d3e2c56a27..0de5f2f63c2 100644
--- a/packages/twenty-front/src/pages/settings/accounts/SettingsAccountDetail.tsx
+++ b/packages/twenty-front/src/pages/settings/accounts/SettingsAccountDetail.tsx
@@ -1,4 +1,5 @@
import { SettingsAccountsCalendarChannelDetails } from '@/settings/accounts/components/SettingsAccountsCalendarChannelDetails';
+import { SETTINGS_APP_PREFERENCES_TAB_IDS } from '@/settings/app-preferences/constants/SettingsAppPreferencesTabIds';
import { SettingsConnectedAccountIcon } from '@/settings/accounts/components/SettingsConnectedAccountIcon';
import { SETTINGS_ACCOUNT_GROUP_TAB_LIST_COMPONENT_ID } from '@/settings/app-preferences/constants/SettingsAccountGroupTabListComponentId';
import { useMyAccountGroups } from '@/settings/app-preferences/hooks/useMyAccountGroups';
@@ -91,8 +92,13 @@ export const SettingsAccountDetail = () => {
href: getSettingsPath(SettingsPath.ProfilePage),
},
{
- children: t`App preferences`,
- href: getSettingsPath(SettingsPath.Accounts),
+ children: t`Apps preferences`,
+ href: getSettingsPath(
+ SettingsPath.Accounts,
+ undefined,
+ undefined,
+ SETTINGS_APP_PREFERENCES_TAB_IDS.ACCOUNTS,
+ ),
},
{ children: builtInAccount.handle },
]}
diff --git a/packages/twenty-front/src/pages/settings/accounts/SettingsAccounts.tsx b/packages/twenty-front/src/pages/settings/accounts/SettingsAccounts.tsx
index 2d5d492a822..e1d0f2af31b 100644
--- a/packages/twenty-front/src/pages/settings/accounts/SettingsAccounts.tsx
+++ b/packages/twenty-front/src/pages/settings/accounts/SettingsAccounts.tsx
@@ -1,12 +1,18 @@
import { SettingsAccountsLegacySections } from '@/settings/accounts/components/SettingsAccountsLegacySections';
import { SettingsAccountsMessageChannelsSSEEffect } from '@/settings/accounts/components/SettingsAccountsMessageChannelsSSEEffect';
-import { SettingsAppPreferencesSections } from '@/settings/app-preferences/components/SettingsAppPreferencesSections';
+import { SettingsAppPreferencesAccountsTab } from '@/settings/app-preferences/components/SettingsAppPreferencesAccountsTab';
+import { SettingsAppPreferencesAppsSection } from '@/settings/app-preferences/components/SettingsAppPreferencesAppsSection';
+import { SETTINGS_APP_PREFERENCES_TAB_IDS } from '@/settings/app-preferences/constants/SettingsAppPreferencesTabIds';
+import { SETTINGS_APP_PREFERENCES_TAB_LIST_COMPONENT_ID } from '@/settings/app-preferences/constants/SettingsAppPreferencesTabListComponentId';
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import { SettingsPageLayout } from '@/settings/components/layout/SettingsPageLayout';
+import { SettingsTabBar } from '@/settings/components/layout/SettingsTabBar';
+import { useSettingsActiveTabId } from '@/settings/components/layout/useSettingsActiveTabId';
import { useLingui } from '@lingui/react/macro';
import { SettingsPath } from 'twenty-shared/types';
import { getSettingsPath } from 'twenty-shared/utils';
+import { IconApps, IconAt } from 'twenty-ui/icon';
import { FeatureFlagKey } from '~/generated-metadata/graphql';
export const SettingsAccounts = () => {
@@ -15,7 +21,25 @@ export const SettingsAccounts = () => {
const isAppPreferencesEnabled = useIsFeatureEnabled(
FeatureFlagKey.IS_APP_PREFERENCES_ENABLED,
);
- const pageTitle = isAppPreferencesEnabled ? t`App preferences` : t`Account`;
+ const pageTitle = isAppPreferencesEnabled ? t`Apps preferences` : t`Account`;
+
+ const tabs = [
+ {
+ id: SETTINGS_APP_PREFERENCES_TAB_IDS.APPS,
+ title: t`Apps`,
+ Icon: IconApps,
+ },
+ {
+ id: SETTINGS_APP_PREFERENCES_TAB_IDS.ACCOUNTS,
+ title: t`Accounts`,
+ Icon: IconAt,
+ },
+ ];
+
+ const activeTabId = useSettingsActiveTabId(
+ SETTINGS_APP_PREFERENCES_TAB_LIST_COMPONENT_ID,
+ tabs.map((tab) => tab.id),
+ );
return (
<SettingsPageLayout
@@ -27,11 +51,27 @@ export const SettingsAccounts = () => {
},
{ children: pageTitle },
]}
+ secondaryBar={
+ isAppPreferencesEnabled ? (
+ <SettingsTabBar
+ aria-label={pageTitle}
+ tabs={tabs}
+ componentInstanceId={SETTINGS_APP_PREFERENCES_TAB_LIST_COMPONENT_ID}
+ />
+ ) : undefined
+ }
>
<SettingsAccountsMessageChannelsSSEEffect />
<SettingsPageContainer>
{isAppPreferencesEnabled ? (
- <SettingsAppPreferencesSections />
+ <>
+ {activeTabId === SETTINGS_APP_PREFERENCES_TAB_IDS.APPS && (
+ <SettingsAppPreferencesAppsSection />
+ )}
+ {activeTabId === SETTINGS_APP_PREFERENCES_TAB_IDS.ACCOUNTS && (
+ <SettingsAppPreferencesAccountsTab />
+ )}
+ </>
) : (
<SettingsAccountsLegacySections />
)}
diff --git a/packages/twenty-front/src/pages/settings/accounts/SettingsAccountsConfiguration.tsx b/packages/twenty-front/src/pages/settings/accounts/SettingsAccountsConfiguration.tsx
index 1448bc69ba6..4a67763c75c 100644
--- a/packages/twenty-front/src/pages/settings/accounts/SettingsAccountsConfiguration.tsx
+++ b/packages/twenty-front/src/pages/settings/accounts/SettingsAccountsConfiguration.tsx
@@ -7,9 +7,9 @@ import { type MessageChannel } from '@/accounts/types/MessageChannel';
import { getToastOptionsFromError } from '@/error-handler/utils/getToastOptionsFromError';
import { GET_MY_CALENDAR_CHANNELS } from '@/settings/accounts/graphql/queries/getMyCalendarChannels';
import { GET_MY_MESSAGE_CHANNELS } from '@/settings/accounts/graphql/queries/getMyMessageChannels';
+import { useAccountsConfigurationCompletionPath } from '@/settings/accounts/hooks/useAccountsConfigurationCompletionPath';
import { useMutation, useQuery } from '@apollo/client/react';
-import { SettingsPath } from 'twenty-shared/types';
-import { getSettingsPath, isDefined } from 'twenty-shared/utils';
+import { isDefined } from 'twenty-shared/utils';
import { useToast } from 'twenty-ui/components/feedback';
import { StartChannelSyncDocument } from '~/generated-metadata/graphql';
import { SettingsAccountsConfigurationSelectedMessageChannelEffect } from '~/pages/settings/accounts/SettingsAccountsConfigurationSelectedMessageChannelEffect';
@@ -59,6 +59,9 @@ export const SettingsAccountsConfiguration = () => {
const messageChannel = messageChannels[0];
const calendarChannel = calendarChannels[0];
+ const completionPath =
+ useAccountsConfigurationCompletionPath(connectedAccountId);
+
const handleNext = () => {
setCurrentStep(SettingsAccountsConfigurationStep.Calendar);
};
@@ -75,7 +78,7 @@ export const SettingsAccountsConfiguration = () => {
status: 'success',
children: t`Account added successfully. Sync started.`,
});
- navigate(getSettingsPath(SettingsPath.Accounts));
+ navigate(completionPath);
},
onError: (error) => {
enqueueToast(getToastOptionsFromError({ error }));
diff --git a/packages/twenty-front/src/pages/settings/accounts/SettingsApplicationPreferences.tsx b/packages/twenty-front/src/pages/settings/accounts/SettingsApplicationPreferences.tsx
index 79f5b42e305..9297f864544 100644
--- a/packages/twenty-front/src/pages/settings/accounts/SettingsApplicationPreferences.tsx
+++ b/packages/twenty-front/src/pages/settings/accounts/SettingsApplicationPreferences.tsx
@@ -40,14 +40,14 @@ export const SettingsApplicationPreferences = () => {
if (isAppPreferencesEnabled && isDefined(error)) {
return (
<SettingsPageLayout
- title={t`App preferences`}
+ title={t`Apps preferences`}
links={[
{
children: t`User`,
href: getSettingsPath(SettingsPath.ProfilePage),
},
{
- children: t`App preferences`,
+ children: t`Apps preferences`,
href: getSettingsPath(SettingsPath.Accounts),
},
]}
diff --git a/packages/twenty-front/src/pages/settings/accounts/SettingsApplicationPreferencesDetail.tsx b/packages/twenty-front/src/pages/settings/accounts/SettingsApplicationPreferencesDetail.tsx
index 66c1556ebff..553bbe3d5dd 100644
--- a/packages/twenty-front/src/pages/settings/accounts/SettingsApplicationPreferencesDetail.tsx
+++ b/packages/twenty-front/src/pages/settings/accounts/SettingsApplicationPreferencesDetail.tsx
@@ -149,7 +149,7 @@ export const SettingsApplicationPreferencesDetail = ({
href: getSettingsPath(SettingsPath.ProfilePage),
},
{
- children: t`App preferences`,
+ children: t`Apps preferences`,
href: getSettingsPath(SettingsPath.Accounts),
},
{ children: appName },
diff --git a/packages/twenty-front/src/pages/settings/accounts/SettingsBuiltInAccountApp.tsx b/packages/twenty-front/src/pages/settings/accounts/SettingsBuiltInAccountApp.tsx
index 94fae30368d..a144b2fa839 100644
--- a/packages/twenty-front/src/pages/settings/accounts/SettingsBuiltInAccountApp.tsx
+++ b/packages/twenty-front/src/pages/settings/accounts/SettingsBuiltInAccountApp.tsx
@@ -182,7 +182,7 @@ export const SettingsBuiltInAccountApp = () => {
href: getSettingsPath(SettingsPath.ProfilePage),
},
{
- children: t`App preferences`,
+ children: t`Apps preferences`,
href: getSettingsPath(SettingsPath.Accounts),
},
{ children: appName },
diff --git a/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsAccountDetail.stories.tsx b/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsAccountDetail.stories.tsx
index 899ea0c07b7..b1c243591ea 100644
--- a/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsAccountDetail.stories.tsx
+++ b/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsAccountDetail.stories.tsx
@@ -43,7 +43,7 @@ export const EmailsAndCalendarTabs: Story = {
await canvas.findByTestId('tab-emails', undefined, { timeout: 3000 }),
);
- expect(canvas.getByText('App preferences')).toBeVisible();
+ expect(canvas.getByText('Apps preferences')).toBeVisible();
expect(await canvas.findByText('Visibility')).toBeVisible();
await userEvent.click(canvas.getByTestId('tab-calendar'));
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.tsx
index c4671582d57..5421ae858b9 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
@@ -62,6 +62,14 @@ const getTableRow = (canvasElement: HTMLElement, text: string) => {
return within(row);
};
+const getTab = ({
+ canvasElement,
+ tabId,
+}: {
+ canvasElement: HTMLElement;
+ tabId: string;
+}) => within(canvasElement).getByTestId(`tab-${tabId}`);
+
const accountGroupsStory: Story = {
args: {
additionalRoutes: ['/settings/accounts/detail/:connectedAccountId'],
@@ -72,6 +80,11 @@ const accountGroupsStory: Story = {
},
};
+const accountsTabStory: Story = {
+ ...accountGroupsStory,
+ args: { ...accountGroupsStory.args, routeHash: '#accounts' },
+};
+
export const Default: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
@@ -80,18 +93,44 @@ export const Default: Story = {
timeout: 3000,
});
- expect(canvas.queryByText('App preferences')).not.toBeInTheDocument();
+ expect(canvas.queryByText('Apps preferences')).not.toBeInTheDocument();
},
};
-export const AccountsGroupedByEmail: Story = {
+export const AppsTabOpensByDefault: Story = {
...accountGroupsStory,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
+ expect(
+ await canvas.findByText(
+ 'Choose your preferences for the apps installed on your workspace by the admin',
+ undefined,
+ { timeout: 3000 },
+ ),
+ ).toBeVisible();
+ expect(canvas.getByRole('heading', { name: 'Apps' })).toBeVisible();
+ expect(
+ canvas.queryByText('Shared accounts between apps'),
+ ).not.toBeInTheDocument();
+
+ await userEvent.click(getTab({ canvasElement, tabId: 'accounts' }));
+
+ expect(await canvas.findByText('[email protected]')).toBeVisible();
+ expect(
+ canvas.queryByRole('button', { name: 'Add account' }),
+ ).not.toBeInTheDocument();
+ },
+};
+
+export const AccountsGroupedByEmail: Story = {
+ ...accountsTabStory,
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
await canvas.findByText('[email protected]', undefined, { timeout: 3000 });
- expect(canvas.getAllByText('App preferences').length).toBeGreaterThan(0);
+ expect(canvas.getAllByText('Apps preferences').length).toBeGreaterThan(0);
expect(canvas.queryByText('Connected accounts')).not.toBeInTheDocument();
const timRow = getTableRow(canvasElement, '[email protected]');
@@ -131,7 +170,7 @@ export const AccountsGroupedByEmail: Story = {
};
export const WorkspaceSharedAppConnectionsStayOff: Story = {
- ...accountGroupsStory,
+ ...accountsTabStory,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
@@ -147,7 +186,7 @@ export const WorkspaceSharedAppConnectionsStayOff: Story = {
};
export const AccountsHeaderStaysWhileLoading: Story = {
- ...accountGroupsStory,
+ ...accountsTabStory,
parameters: {
msw: {
handlers: [
@@ -166,39 +205,53 @@ export const AccountsHeaderStaysWhileLoading: Story = {
timeout: 3000,
}),
).toBeVisible();
- expect(canvas.getByText('Accounts')).toBeVisible();
- expect(
- canvas.getByText(
- 'Choose your preferences for the apps installed on your workspace by the admin',
- ),
- ).toBeVisible();
+ expect(canvas.getByRole('heading', { name: 'Accounts' })).toBeVisible();
expect(canvas.getByText('Used by')).toBeVisible();
expect(canvasElement.querySelector('[aria-busy="true"]')).not.toBeNull();
expect(canvas.queryByText('[email protected]')).not.toBeInTheDocument();
},
};
+export const AccountsTabWithoutAccountsSaysNoAccountsYet: Story = {
+ ...accountsTabStory,
+ parameters: {
+ msw: {
+ handlers: [
+ graphql.query('MyConnectedAccounts', () =>
+ HttpResponse.json({ data: { myConnectedAccounts: [] } }),
+ ),
+ ...ACCOUNT_GROUPS_GRAPHQL_HANDLERS,
+ ],
+ },
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ expect(
+ await canvas.findByText('No accounts yet', undefined, { timeout: 3000 }),
+ ).toBeVisible();
+ expect(canvas.queryByText('Connect with Google')).not.toBeInTheDocument();
+ },
+};
+
export const AppPreferencesListEnabledApps: Story = {
- ...accountGroupsStory,
+ ...accountsTabStory,
args: {
+ ...accountsTabStory.args,
additionalRoutes: ['/settings/accounts/apps/outlook'],
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- await canvas.findByText(
- 'Choose your preferences for the apps installed on your workspace by the admin',
- undefined,
- { timeout: 3000 },
- );
- await canvas.findByText('[email protected]');
+ await canvas.findByText('[email protected]', undefined, { timeout: 3000 });
+ expect(canvas.queryByText('Blocklist')).not.toBeInTheDocument();
+ await userEvent.click(getTab({ canvasElement, tabId: 'apps' }));
expect(
- canvas.getByRole('link', { name: 'Gmail and Calendar' }),
+ await canvas.findByRole('link', { name: 'Gmail and Calendar' }),
).toBeVisible();
expect(canvas.queryByText('IMAP')).not.toBeInTheDocument();
expect(canvas.queryByText('Missing account')).not.toBeInTheDocument();
- expect(canvas.queryByText('Blocklist')).not.toBeInTheDocument();
await userEvent.click(canvas.getByRole('link', { name: 'Outlook' }));
@@ -209,7 +262,7 @@ export const AppPreferencesListEnabledApps: Story = {
};
export const RowOpensAccountPage: Story = {
- ...accountGroupsStory,
+ ...accountsTabStory,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
@@ -229,7 +282,7 @@ export const RowOpensAccountPage: Story = {
};
export const DeleteKeepsAppConnections: Story = {
- ...accountGroupsStory,
+ ...accountsTabStory,
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const body = within(canvasElement.ownerDocument.body);
@@ -312,29 +365,6 @@ export const AppsWithoutAccountShowMissingAccount: Story = {
},
};
-export const BlocklistStaysWhenNoAppIsEnabled: Story = {
- ...accountGroupsStory,
- beforeEach: async () => {
- await seedAccountGroupsStory();
- jotaiStore.set(isGoogleMessagingEnabledState.atom, false);
- jotaiStore.set(isGoogleCalendarEnabledState.atom, false);
- jotaiStore.set(isMicrosoftMessagingEnabledState.atom, false);
- jotaiStore.set(isMicrosoftCalendarEnabledState.atom, false);
- },
- play: async ({ canvasElement }) => {
- const canvas = within(canvasElement);
-
- expect(
- await canvas.findByText('Blocklist', undefined, { timeout: 3000 }),
- ).toBeVisible();
- expect(
- canvas.queryByText(
- 'Choose your preferences for the apps installed on your workspace by the admin',
- ),
- ).not.toBeInTheDocument();
- },
-};
-
export const AppPreferencesListInstalledApps: Story = {
...accountGroupsStory,
args: {
@@ -426,7 +456,7 @@ export const AppPreferencesListFlagsMissingConfiguration: Story = {
};
export const AppsWhoseProviderIsNotSetUpShowNoMissingAccount: Story = {
- ...accountGroupsStory,
+ ...accountsTabStory,
beforeEach: async () => {
await seedApplicationPreferencesStory();
unconfigureLinearClientCredentials();
@@ -437,8 +467,9 @@ export const AppsWhoseProviderIsNotSetUpShowNoMissingAccount: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
+ await canvas.findByText('[email protected]', undefined, { timeout: 3000 });
+ await userEvent.click(getTab({ canvasElement, tabId: 'apps' }));
await canvas.findByText('Linear', undefined, { timeout: 3000 });
- await canvas.findByText('[email protected]');
expect(
getTableRow(canvasElement, 'Linear').queryByText('Missing account'),
@@ -483,47 +514,45 @@ export const AppPreferencesListLoadErrorOffersRetry: Story = {
},
};
-export const InstalledAppsKeepBlocklistWhenNoBuiltInAccountAppIsEnabled: Story =
- {
- ...accountGroupsStory,
- beforeEach: async () => {
- await seedApplicationPreferencesStory();
- jotaiStore.set(isGoogleMessagingEnabledState.atom, false);
- jotaiStore.set(isGoogleCalendarEnabledState.atom, false);
- jotaiStore.set(isMicrosoftMessagingEnabledState.atom, false);
- jotaiStore.set(isMicrosoftCalendarEnabledState.atom, false);
- },
- parameters: {
- msw: {
- handlers: [
- // The client config can load after beforeEach and would re-enable them
- http.get(`${REACT_APP_SERVER_BASE_URL}/client-config`, () =>
- HttpResponse.json({
- ...mockedClientConfig,
- isGoogleMessagingEnabled: false,
- isGoogleCalendarEnabled: false,
- isMicrosoftMessagingEnabled: false,
- isMicrosoftCalendarEnabled: false,
- }),
- ),
- ...APPLICATION_PREFERENCES_GRAPHQL_HANDLERS,
- ],
- },
- },
- play: async ({ canvasElement }) => {
- const canvas = within(canvasElement);
-
- expect(
- await canvas.findByText('Fathom', undefined, { timeout: 3000 }),
- ).toBeVisible();
- expect(
- canvas.getByText(
- 'Choose your preferences for the apps installed on your workspace by the admin',
+export const BlocklistFallsBackToAccountsTabWithoutBuiltInAccountApp: Story = {
+ ...accountsTabStory,
+ beforeEach: async () => {
+ await seedApplicationPreferencesStory();
+ jotaiStore.set(isGoogleMessagingEnabledState.atom, false);
+ jotaiStore.set(isGoogleCalendarEnabledState.atom, false);
+ jotaiStore.set(isMicrosoftMessagingEnabledState.atom, false);
+ jotaiStore.set(isMicrosoftCalendarEnabledState.atom, false);
+ },
+ parameters: {
+ msw: {
+ handlers: [
+ // The client config can load after beforeEach and would re-enable them
+ http.get(`${REACT_APP_SERVER_BASE_URL}/client-config`, () =>
+ HttpResponse.json({
+ ...mockedClientConfig,
+ isGoogleMessagingEnabled: false,
+ isGoogleCalendarEnabled: false,
+ isMicrosoftMessagingEnabled: false,
+ isMicrosoftCalendarEnabled: false,
+ }),
),
- ).toBeVisible();
- expect(await canvas.findByText('Blocklist')).toBeVisible();
- expect(
- canvas.queryByRole('link', { name: 'Gmail and Calendar' }),
- ).not.toBeInTheDocument();
+ ...APPLICATION_PREFERENCES_GRAPHQL_HANDLERS,
+ ],
},
- };
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ expect(
+ await canvas.findByText('Blocklist', undefined, { timeout: 3000 }),
+ ).toBeVisible();
+
+ await userEvent.click(getTab({ canvasElement, tabId: 'apps' }));
+
+ expect(await canvas.findByText('Fathom')).toBeVisible();
+ expect(
+ canvas.queryByRole('link', { name: 'Gmail and Calendar' }),
+ ).not.toBeInTheDocument();
+ expect(canvas.queryByText('Blocklist')).not.toBeInTheDocument();
+ },
+};
diff --git a/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsAccountsConfiguration.stories.tsx b/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsAccountsConfiguration.stories.tsx
new file mode 100644
index 00000000000..356f7cbb1b6
--- /dev/null
+++ b/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsAccountsConfiguration.stories.tsx
@@ -0,0 +1,66 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { HttpResponse, graphql } from 'msw';
+import { expect, userEvent, within } from 'storybook/test';
+
+import {
+ PageDecorator,
+ type PageDecoratorArgs,
+} from '~/testing/decorators/PageDecorator';
+
+import { SettingsAccountsConfiguration } from '~/pages/settings/accounts/SettingsAccountsConfiguration';
+import {
+ ACCOUNT_GROUPS_GRAPHQL_HANDLERS,
+ GOOGLE_ACCOUNT_ID,
+ seedAccountGroupsStory,
+} from '~/pages/settings/accounts/__stories__/mockedAccountGroups';
+
+const meta: Meta<PageDecoratorArgs> = {
+ title: 'Pages/Settings/Accounts/SettingsAccountsConfiguration',
+ component: SettingsAccountsConfiguration,
+ decorators: [PageDecorator],
+ args: {
+ routePath: '/settings/accounts/configuration/:connectedAccountId',
+ routeParams: { ':connectedAccountId': GOOGLE_ACCOUNT_ID },
+ additionalRoutes: ['/settings/accounts/apps/google'],
+ },
+ beforeEach: seedAccountGroupsStory,
+ parameters: {
+ layout: 'fullscreen',
+ msw: {
+ handlers: [
+ graphql.mutation('StartChannelSync', () =>
+ HttpResponse.json({
+ data: {
+ startChannelSync: {
+ __typename: 'ChannelSyncSuccess',
+ success: true,
+ },
+ },
+ }),
+ ),
+ ...ACCOUNT_GROUPS_GRAPHQL_HANDLERS,
+ ],
+ },
+ },
+};
+
+export default meta;
+
+export type Story = StoryObj<typeof SettingsAccountsConfiguration>;
+
+export const FinishedSetupOpensTheAppPage: Story = {
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await userEvent.click(
+ await canvas.findByRole('button', { name: 'Next' }, { timeout: 3000 }),
+ );
+ await userEvent.click(
+ await canvas.findByRole('button', { name: 'Finish Setup' }),
+ );
+
+ expect(
+ await canvas.findByText('Navigated to /settings/accounts/apps/google'),
+ ).toBeVisible();
+ },
+};
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.tsx
index 58c70a439ed..ec04ab47ea4 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
@@ -57,7 +57,7 @@ export const VariablesTabSavesOnlyEditedValues: Story = {
await canvas.findByRole('link', { name: 'Variables' }, { timeout: 3000 }),
).toBeVisible();
expect(canvas.getAllByText('Fathom').length).toBeGreaterThan(0);
- expect(canvas.getByText('App preferences')).toBeVisible();
+ expect(canvas.getByText('Apps preferences')).toBeVisible();
expect(canvas.getByText('Record my meetings')).toBeVisible();
expect(canvas.getByDisplayValue('always')).toBeVisible();
expect(canvas.getByPlaceholderText('sk-1********')).toHaveValue('');
diff --git a/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsBuiltInAccountApp.stories.tsx b/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsBuiltInAccountApp.stories.tsx
index 40407a604e9..0faac44424b 100644
--- a/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsBuiltInAccountApp.stories.tsx
+++ b/packages/twenty-front/src/pages/settings/accounts/__stories__/SettingsBuiltInAccountApp.stories.tsx
@@ -10,13 +10,18 @@ import {
import { isMicrosoftCalendarEnabledState } from '@/client-config/states/isMicrosoftCalendarEnabledState';
import { jotaiStore } from '@/ui/utilities/state/jotai/jotaiStore';
import { SettingsBuiltInAccountApp } from '~/pages/settings/accounts/SettingsBuiltInAccountApp';
+import { REACT_APP_SERVER_BASE_URL } from '~/config';
+import { clickAndCaptureOAuthRedirect } from '~/pages/settings/accounts/__stories__/clickAndCaptureOAuthRedirect';
import {
ACCOUNT_GROUPS_GRAPHQL_HANDLERS,
CALENDAR_CHANNELS,
CONNECTED_ACCOUNTS,
+ GOOGLE_ACCOUNT_ID,
MICROSOFT_ACCOUNT_ID,
seedAccountGroupsStory,
} from '~/pages/settings/accounts/__stories__/mockedAccountGroups';
+import { GENERATE_TRANSIENT_TOKEN_GRAPHQL_HANDLER } from '~/pages/settings/accounts/__stories__/mockedLinearApplicationPreferences';
+import { withinTableRowOrThrow } from '~/testing/utils/withinTableRowOrThrow';
const meta: Meta<PageDecoratorArgs> = {
title: 'Pages/Settings/Accounts/SettingsBuiltInAccountApp',
@@ -56,6 +61,7 @@ export const GoogleGeneralShowsAccountsAndBlocklist: Story = {
canvas.getByText('Read emails, Send emails, Manage events'),
).toBeVisible();
expect(canvas.getByText('Read emails')).toBeVisible();
+ expect(canvas.getByRole('button', { name: 'Add account' })).toBeVisible();
expect(canvas.getByTestId('tab-emails')).toBeVisible();
expect(canvas.getByTestId('tab-calendar')).toBeVisible();
},
@@ -251,3 +257,75 @@ export const OutlookWithoutAccountOffersMicrosoftOnly: Story = {
expect(canvas.getByText('Blocklist')).toBeVisible();
},
};
+
+export const AddAccountStartsTheProviderSignIn: Story = {
+ parameters: {
+ msw: {
+ handlers: [
+ GENERATE_TRANSIENT_TOKEN_GRAPHQL_HANDLER,
+ ...ACCOUNT_GROUPS_GRAPHQL_HANDLERS,
+ ],
+ },
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await userEvent.click(
+ await canvas.findByTestId('tab-general', undefined, { timeout: 3000 }),
+ );
+
+ const redirectUrl = await clickAndCaptureOAuthRedirect(
+ await canvas.findByRole('button', { name: 'Add account' }),
+ );
+
+ expect(`${redirectUrl.origin}${redirectUrl.pathname}`).toBe(
+ `${REACT_APP_SERVER_BASE_URL}/auth/google-apis`,
+ );
+ expect(redirectUrl.searchParams.has('redirectLocation')).toBe(false);
+ },
+};
+
+export const ReconnectReturnsToTheAppPage: Story = {
+ parameters: {
+ msw: {
+ handlers: [
+ GENERATE_TRANSIENT_TOKEN_GRAPHQL_HANDLER,
+ graphql.query('MyConnectedAccounts', () =>
+ HttpResponse.json({
+ data: {
+ myConnectedAccounts: CONNECTED_ACCOUNTS.map((account) =>
+ account.id === GOOGLE_ACCOUNT_ID
+ ? { ...account, authFailedAt: '2026-10-01T00:00:00.000Z' }
+ : account,
+ ),
+ },
+ }),
+ ),
+ ...ACCOUNT_GROUPS_GRAPHQL_HANDLERS,
+ ],
+ },
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const body = within(canvasElement.ownerDocument.body);
+
+ await userEvent.click(
+ await canvas.findByTestId('tab-general', undefined, { timeout: 3000 }),
+ );
+ await canvas.findByText('[email protected]');
+ await userEvent.click(
+ withinTableRowOrThrow({ canvasElement, text: '[email protected]' }).getByRole(
+ 'button',
+ { name: 'More options' },
+ ),
+ );
+
+ const redirectUrl = await clickAndCaptureOAuthRedirect(
+ await body.findByRole('menuitem', { name: 'Reconnect' }),
+ );
+
+ expect(redirectUrl.searchParams.get('redirectLocation')).toBe(
+ '/settings/accounts/apps/google#general',
+ );
+ },
+};