Skip to content

The open alternative to Salesforce, designed for AI.

Show connected apps' settings as tabs on the account page (#29468)

nitinfc21e893f0be
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAccountGroupTableRow.tsx b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAccountGroupTableRow.tsx
index 59a1965e673..bafa282f75b 100644
--- a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAccountGroupTableRow.tsx
+++ b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAccountGroupTableRow.tsx
@@ -22,11 +22,13 @@ const DISPLAYED_SYNC_STATUSES: ReadonlySet<SyncStatus> = new Set([
type SettingsAccountGroupTableRowProps = {
group: ConnectedAccountGroup;
+ hasApplicationSettings: boolean;
builtInAccountApp?: BuiltInAccountApp;
};
export const SettingsAccountGroupTableRow = ({
group,
+ hasApplicationSettings,
builtInAccountApp,
}: SettingsAccountGroupTableRowProps) => {
const theme = useTheme();
@@ -37,7 +39,10 @@ export const SettingsAccountGroupTableRow = ({
});
const { messageChannel, calendarChannel } =
getConnectedAccountSettingsChannels(builtInAccount);
- const hasSettings = isDefined(messageChannel) || isDefined(calendarChannel);
+ const hasSettings =
+ isDefined(messageChannel) ||
+ isDefined(calendarChannel) ||
+ hasApplicationSettings;
const shouldShowSyncStatus =
isDefined(builtInAccount) &&
(isDefined(builtInAccount.archivedAt) ||
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 28243a87c3e..e0fabee20e7 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,15 +1,17 @@
import { SettingsAccountGroupTableRow } from '@/settings/app-preferences/components/SettingsAccountGroupTableRow';
import { SettingsAccountGroupsEmptyState } from '@/settings/app-preferences/components/SettingsAccountGroupsEmptyState';
import { useAddBuiltInAccount } from '@/settings/app-preferences/hooks/useAddBuiltInAccount';
+import { useApplicationsWithPreferences } from '@/settings/app-preferences/hooks/useApplicationsWithPreferences';
import { useMyAccountGroups } from '@/settings/app-preferences/hooks/useMyAccountGroups';
import { type BuiltInAccountApp } from '@/settings/app-preferences/types/BuiltInAccountApp';
+import { getAccountGroupApplicationsWithSettings } from '@/settings/app-preferences/utils/getAccountGroupApplicationsWithSettings';
import { getBuiltInAccountAppsUsingAccount } from '@/settings/app-preferences/utils/getBuiltInAccountAppsUsingAccount';
import { SettingsApplicationTableHeaderRow } from '@/settings/applications/components/SettingsApplicationTableHeaderRow';
import { SettingsSectionSkeletonLoader } from '@/settings/components/SettingsSectionSkeletonLoader';
import { Table } from '@/ui/layout/table/components/Table';
import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
-import { isDefined } from 'twenty-shared/utils';
+import { isDefined, isNonEmptyArray } from 'twenty-shared/utils';
import { Section } from 'twenty-ui/components/layout';
import { IconPlus } from 'twenty-ui/icon';
import { Button } from 'twenty-ui/primitives/input';
@@ -37,6 +39,7 @@ export const SettingsAccountGroupsSection = ({
const { t } = useLingui();
const { addBuiltInAccount } = useAddBuiltInAccount();
const { groups: allGroups, loading } = useMyAccountGroups();
+ const { applicationsWithPreferences } = useApplicationsWithPreferences();
const groups = isDefined(builtInAccountApp)
? allGroups.filter((group) =>
@@ -75,6 +78,12 @@ export const SettingsAccountGroupsSection = ({
<SettingsAccountGroupTableRow
key={group.id}
group={group}
+ hasApplicationSettings={isNonEmptyArray(
+ getAccountGroupApplicationsWithSettings({
+ group,
+ applicationsWithPreferences,
+ }),
+ )}
builtInAccountApp={builtInAccountApp}
/>
))}
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/hooks/useAccountGroupApplicationSettingsTabs.ts b/packages/twenty-front/src/modules/settings/app-preferences/hooks/useAccountGroupApplicationSettingsTabs.ts
new file mode 100644
index 00000000000..0cd0e9639d8
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/app-preferences/hooks/useAccountGroupApplicationSettingsTabs.ts
@@ -0,0 +1,53 @@
+import { getApplicationDisplayName } from '@/applications/utils/getApplicationDisplayName';
+import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
+import { useApplicationsWithPreferences } from '@/settings/app-preferences/hooks/useApplicationsWithPreferences';
+import { type ConnectedAccountGroup } from '@/settings/app-preferences/types/ConnectedAccountGroup';
+import { getAccountGroupApplicationsWithSettings } from '@/settings/app-preferences/utils/getAccountGroupApplicationsWithSettings';
+import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
+import { useLingui } from '@lingui/react/macro';
+import { isDefined } from 'twenty-shared/utils';
+import { useIcons } from 'twenty-ui/icon/provider';
+
+export const useAccountGroupApplicationSettingsTabs = (
+ group: ConnectedAccountGroup | undefined,
+) => {
+ const { t } = useLingui();
+ const { getIcon } = useIcons();
+ const currentWorkspace = useAtomStateValue(currentWorkspaceState);
+ const { applicationsWithPreferences, loading } =
+ useApplicationsWithPreferences();
+
+ const applicationsWithSettings = isDefined(group)
+ ? getAccountGroupApplicationsWithSettings({
+ group,
+ applicationsWithPreferences,
+ })
+ : [];
+
+ const applicationSettingsTabs = applicationsWithSettings.flatMap(
+ ({ application, settingsMenuItems }) => {
+ const applicationName = getApplicationDisplayName({
+ application,
+ currentWorkspace,
+ });
+
+ return settingsMenuItems.map((settingsMenuItem) => {
+ const settingsMenuItemTitle = settingsMenuItem.title;
+
+ return {
+ frontComponentId: settingsMenuItem.frontComponentId,
+ tab: {
+ id: settingsMenuItem.universalIdentifier,
+ title:
+ settingsMenuItems.length > 1
+ ? t`${applicationName}: ${settingsMenuItemTitle}`
+ : applicationName,
+ Icon: getIcon(settingsMenuItem.icon, 'IconAdjustments'),
+ },
+ };
+ });
+ },
+ );
+
+ return { applicationSettingsTabs, loading };
+};
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/utils/__tests__/getAccountGroupApplicationsWithSettings.test.ts b/packages/twenty-front/src/modules/settings/app-preferences/utils/__tests__/getAccountGroupApplicationsWithSettings.test.ts
new file mode 100644
index 00000000000..5647893067a
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/app-preferences/utils/__tests__/getAccountGroupApplicationsWithSettings.test.ts
@@ -0,0 +1,88 @@
+import { type ApplicationWithPreferences } from '@/settings/app-preferences/types/ApplicationWithPreferences';
+import { getAccountGroupApplicationsWithSettings } from '@/settings/app-preferences/utils/getAccountGroupApplicationsWithSettings';
+import { SettingsMenuItemScope } from '~/generated-metadata/graphql';
+
+const buildApplicationWithPreferences = ({
+ applicationId,
+ hasSettingsMenuItem,
+}: {
+ applicationId: string;
+ hasSettingsMenuItem: boolean;
+}): ApplicationWithPreferences => ({
+ application: {
+ id: applicationId,
+ name: applicationId,
+ universalIdentifier: `${applicationId}-universal-identifier`,
+ logoUrl: null,
+ createdAt: '2024-01-01T00:00:00.000Z',
+ },
+ settingsMenuItems: hasSettingsMenuItem
+ ? [
+ {
+ __typename: 'SettingsMenuItem',
+ id: `${applicationId}-settings-menu-item-id`,
+ universalIdentifier: `${applicationId}-settings-menu-item`,
+ applicationId,
+ frontComponentId: `${applicationId}-front-component-id`,
+ title: 'My settings',
+ icon: null,
+ position: 0,
+ scope: SettingsMenuItemScope.USER,
+ slug: null,
+ },
+ ]
+ : [],
+ variables: [],
+ missingRequiredVariables: [],
+ connectionProviders: [],
+});
+
+const applicationsWithPreferences = [
+ buildApplicationWithPreferences({
+ applicationId: 'recorder',
+ hasSettingsMenuItem: true,
+ }),
+ buildApplicationWithPreferences({
+ applicationId: 'notetaker',
+ hasSettingsMenuItem: true,
+ }),
+ buildApplicationWithPreferences({
+ applicationId: 'archived-notetaker',
+ hasSettingsMenuItem: true,
+ }),
+ buildApplicationWithPreferences({
+ applicationId: 'variables-only',
+ hasSettingsMenuItem: false,
+ }),
+];
+
+describe('getAccountGroupApplicationsWithSettings', () => {
+ it('keeps applications connected with the account that have settings', () => {
+ const applicationsWithSettings = getAccountGroupApplicationsWithSettings({
+ group: {
+ appAccounts: [
+ { applicationId: 'recorder', archivedAt: null },
+ {
+ applicationId: 'archived-notetaker',
+ archivedAt: '2026-09-02T00:00:00.000Z',
+ },
+ { applicationId: 'variables-only', archivedAt: null },
+ ],
+ },
+ applicationsWithPreferences,
+ });
+
+ expect(
+ applicationsWithSettings.map(({ application }) => application.id),
+ ).toEqual(['recorder']);
+ });
+
+ it('returns nothing for an account without app connections', () => {
+ expect(
+ getAccountGroupApplicationsWithSettings({
+ group: { appAccounts: [] },
+ applicationsWithPreferences,
+ }),
+ ).toEqual([]);
+ });
+});
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/utils/getAccountGroupApplicationsWithSettings.ts b/packages/twenty-front/src/modules/settings/app-preferences/utils/getAccountGroupApplicationsWithSettings.ts
new file mode 100644
index 00000000000..db48c0724e7
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/app-preferences/utils/getAccountGroupApplicationsWithSettings.ts
@@ -0,0 +1,30 @@
+import { type ConnectedAccount } from '@/accounts/types/ConnectedAccount';
+import { type ApplicationWithPreferences } from '@/settings/app-preferences/types/ApplicationWithPreferences';
+import { type ConnectedAccountGroup } from '@/settings/app-preferences/types/ConnectedAccountGroup';
+import { isDefined, isNonEmptyArray } from 'twenty-shared/utils';
+
+export const getAccountGroupApplicationsWithSettings = ({
+ group,
+ applicationsWithPreferences,
+}: {
+ group: Pick<
+ ConnectedAccountGroup<
+ Pick<ConnectedAccount, 'applicationId' | 'archivedAt'>
+ >,
+ 'appAccounts'
+ >;
+ applicationsWithPreferences: ApplicationWithPreferences[];
+}): ApplicationWithPreferences[] => {
+ const connectedApplicationIds = new Set(
+ group.appAccounts
+ .filter((appAccount) => !isDefined(appAccount.archivedAt))
+ .map((appAccount) => appAccount.applicationId)
+ .filter(isDefined),
+ );
+
+ return applicationsWithPreferences.filter(
+ ({ application, settingsMenuItems }) =>
+ connectedApplicationIds.has(application.id) &&
+ isNonEmptyArray(settingsMenuItems),
+ );
+};
diff --git a/packages/twenty-front/src/pages/settings/accounts/SettingsAccountDetail.tsx b/packages/twenty-front/src/pages/settings/accounts/SettingsAccountDetail.tsx
index e88b363d077..140571999d6 100644
--- a/packages/twenty-front/src/pages/settings/accounts/SettingsAccountDetail.tsx
+++ b/packages/twenty-front/src/pages/settings/accounts/SettingsAccountDetail.tsx
@@ -2,8 +2,10 @@ import { SettingsAccountsCalendarChannelDetails } from '@/settings/accounts/comp
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 { useAccountGroupApplicationSettingsTabs } from '@/settings/app-preferences/hooks/useAccountGroupApplicationSettingsTabs';
import { useMyAccountGroups } from '@/settings/app-preferences/hooks/useMyAccountGroups';
import { getConnectedAccountSettingsChannels } from '@/settings/app-preferences/utils/getConnectedAccountSettingsChannels';
+import { SettingsApplicationCustomSettingsSection } from '@/settings/applications/components/SettingsApplicationCustomSettingsSection';
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
import { SettingsSectionSkeletonLoader } from '@/settings/components/SettingsSectionSkeletonLoader';
import { SettingsSkeletonLoader } from '@/settings/components/SettingsSkeletonLoader';
@@ -25,11 +27,11 @@ export const SettingsAccountDetail = () => {
const { groups, loading } = useMyAccountGroups();
const tabListComponentInstanceId = `${SETTINGS_ACCOUNT_GROUP_TAB_LIST_COMPONENT_ID}-${connectedAccountId}`;
- const builtInAccount = groups.find(
- (group) => group.builtInAccount?.id === connectedAccountId,
- )?.builtInAccount;
+ const group = groups.find((candidate) => candidate.id === connectedAccountId);
const { messageChannel, calendarChannel } =
- getConnectedAccountSettingsChannels(builtInAccount);
+ getConnectedAccountSettingsChannels(group?.builtInAccount);
+ const { applicationSettingsTabs, loading: applicationSettingsTabsLoading } =
+ useAccountGroupApplicationSettingsTabs(group);
const tabs = [
isDefined(messageChannel)
@@ -38,6 +40,7 @@ export const SettingsAccountDetail = () => {
isDefined(calendarChannel)
? { id: 'calendar', title: t`Calendar`, Icon: IconCalendarEvent }
: undefined,
+ ...applicationSettingsTabs.map(({ tab }) => tab),
].filter(isDefined);
const activeTabId = useSettingsActiveTabId(
@@ -45,18 +48,22 @@ export const SettingsAccountDetail = () => {
tabs.map((tab) => tab.id),
);
- if (!loading && tabs.length === 0) {
+ const activeApplicationSettingsTab = applicationSettingsTabs.find(
+ ({ tab }) => tab.id === activeTabId,
+ );
+
+ if (!loading && !applicationSettingsTabsLoading && tabs.length === 0) {
return (
<Navigate to={getSettingsPath(SettingsPath.AppPreferences)} replace />
);
}
- if (!isDefined(builtInAccount)) {
+ if (!isDefined(group)) {
return <SettingsSkeletonLoader />;
}
const ProviderIcon = SettingsConnectedAccountIcon({
- account: builtInAccount,
+ account: group.builtInAccount ?? group.appAccounts[0],
});
const renderContent = () => {
@@ -76,12 +83,20 @@ export const SettingsAccountDetail = () => {
);
}
+ if (isDefined(activeApplicationSettingsTab)) {
+ return (
+ <SettingsApplicationCustomSettingsSection
+ frontComponentId={activeApplicationSettingsTab.frontComponentId}
+ />
+ );
+ }
+
return <SettingsSectionSkeletonLoader />;
};
return (
<SettingsPageLayout
- title={builtInAccount.handle}
+ title={group.handle}
icon={<ProviderIcon size={theme.icon.size.md} />}
links={[
{
@@ -97,7 +112,7 @@ export const SettingsAccountDetail = () => {
SETTINGS_APP_PREFERENCES_TAB_IDS.ACCOUNTS,
),
},
- { children: builtInAccount.handle },
+ { children: group.handle },
]}
secondaryBar={
tabs.length > 0 ? (
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 8217f6bb8b9..6888b6b2fef 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
@@ -1,6 +1,6 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
-import { delay, graphql } from 'msw';
-import { expect, userEvent, waitFor, within } from 'storybook/test';
+import { HttpResponse, delay, graphql } from 'msw';
+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
import {
PageDecorator,
@@ -10,10 +10,60 @@ import {
import { SettingsAccountDetail } from '~/pages/settings/accounts/SettingsAccountDetail';
import {
ACCOUNT_GROUPS_GRAPHQL_HANDLERS,
+ CONNECTED_ACCOUNTS,
FATHOM_ONLY_ACCOUNT_ID,
+ FATHOM_USER_SETTINGS_FRONT_COMPONENT_ID,
+ FATHOM_USER_SETTINGS_MENU_ITEM_ID,
GOOGLE_ACCOUNT_ID,
+ GRANOLA_APPLICATION_ID,
+ GRANOLA_USER_SETTINGS_MENU_ITEM_ID,
+ MY_USER_WORKSPACE_ID,
+ USER_SETTINGS_APPLICATION_PREFERENCES_GRAPHQL_HANDLER,
+ buildConnectedAccount,
seedAccountGroupsStory,
} from '~/pages/settings/accounts/__stories__/mockedAccountGroups';
+import { GENERATE_TRANSIENT_TOKEN_GRAPHQL_HANDLER } from '~/pages/settings/accounts/__stories__/mockedLinearApplicationPreferences';
+
+const findOneFrontComponent = fn();
+
+const USER_SETTINGS_GRAPHQL_HANDLERS = [
+ USER_SETTINGS_APPLICATION_PREFERENCES_GRAPHQL_HANDLER,
+ graphql.query('FindOneFrontComponent', ({ variables }) => {
+ findOneFrontComponent(variables.id);
+
+ return HttpResponse.json({ data: { frontComponent: null } });
+ }),
+ GENERATE_TRANSIENT_TOKEN_GRAPHQL_HANDLER,
+];
+
+const ARCHIVED_GRANOLA_CONNECTION_GRAPHQL_HANDLER = graphql.query(
+ 'MyConnectedAccounts',
+ () =>
+ HttpResponse.json({
+ data: {
+ myConnectedAccounts: [
+ ...CONNECTED_ACCOUNTS,
+ buildConnectedAccount({
+ id: '20202020-1a2b-4c3d-8e4f-000000000019',
+ handle: '[email protected]',
+ provider: 'app',
+ userWorkspaceId: MY_USER_WORKSPACE_ID,
+ applicationId: GRANOLA_APPLICATION_ID,
+ archivedAt: '2026-09-02T00:00:00.000Z',
+ }),
+ ],
+ },
+ }),
+);
+
+const WITHOUT_CHANNELS_GRAPHQL_HANDLERS = [
+ graphql.query('MyMessageChannels', () =>
+ HttpResponse.json({ data: { myMessageChannels: [] } }),
+ ),
+ graphql.query('MyCalendarChannels', () =>
+ HttpResponse.json({ data: { myCalendarChannels: [] } }),
+ ),
+];
const meta: Meta<PageDecoratorArgs> = {
title: 'Pages/Settings/Accounts/SettingsAccountDetail',
@@ -52,6 +102,102 @@ export const EmailsAndCalendarTabs: Story = {
},
};
+export const ConnectedAppSettingsOpenFromTheirTab: Story = {
+ beforeEach: () => {
+ findOneFrontComponent.mockClear();
+ },
+ parameters: {
+ msw: {
+ handlers: [
+ ARCHIVED_GRANOLA_CONNECTION_GRAPHQL_HANDLER,
+ ...USER_SETTINGS_GRAPHQL_HANDLERS,
+ ...ACCOUNT_GROUPS_GRAPHQL_HANDLERS,
+ ],
+ },
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ const fathomTab = await canvas.findByTestId(
+ `tab-${FATHOM_USER_SETTINGS_MENU_ITEM_ID}`,
+ undefined,
+ { timeout: 3000 },
+ );
+
+ expect(fathomTab).toHaveTextContent('Fathom');
+ expect(
+ canvas.queryByTestId(`tab-${GRANOLA_USER_SETTINGS_MENU_ITEM_ID}`),
+ ).not.toBeInTheDocument();
+
+ await userEvent.click(fathomTab);
+
+ await waitFor(
+ () =>
+ expect(findOneFrontComponent).toHaveBeenCalledWith(
+ FATHOM_USER_SETTINGS_FRONT_COMPONENT_ID,
+ ),
+ { timeout: 3000 },
+ );
+ expect(findOneFrontComponent).toHaveBeenCalledTimes(1);
+
+ await userEvent.click(canvas.getByTestId('tab-emails'));
+
+ expect(await canvas.findByText('Visibility')).toBeVisible();
+ },
+};
+
+export const AccountWithoutChannelsShowsItsAppSettings: Story = {
+ parameters: {
+ msw: {
+ handlers: [
+ ...WITHOUT_CHANNELS_GRAPHQL_HANDLERS,
+ ...USER_SETTINGS_GRAPHQL_HANDLERS,
+ ...ACCOUNT_GROUPS_GRAPHQL_HANDLERS,
+ ],
+ },
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ expect(
+ await canvas.findByTestId(
+ `tab-${FATHOM_USER_SETTINGS_MENU_ITEM_ID}`,
+ undefined,
+ { timeout: 3000 },
+ ),
+ ).toHaveTextContent('Fathom');
+ expect(canvas.queryByTestId('tab-emails')).not.toBeInTheDocument();
+ expect(canvas.queryByTestId('tab-calendar')).not.toBeInTheDocument();
+ },
+};
+
+export const AppOnlyAccountShowsItsAppSettings: Story = {
+ args: {
+ routeParams: { ':connectedAccountId': FATHOM_ONLY_ACCOUNT_ID },
+ },
+ parameters: {
+ msw: {
+ handlers: [
+ ...USER_SETTINGS_GRAPHQL_HANDLERS,
+ ...ACCOUNT_GROUPS_GRAPHQL_HANDLERS,
+ ],
+ },
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ expect(
+ await canvas.findByTestId(
+ `tab-${FATHOM_USER_SETTINGS_MENU_ITEM_ID}`,
+ undefined,
+ { timeout: 3000 },
+ ),
+ ).toHaveTextContent('Fathom');
+ expect(canvas.getAllByText('[email protected]').length).toBeGreaterThan(0);
+ expect(canvas.queryByTestId('tab-emails')).not.toBeInTheDocument();
+ },
+};
+
export const TitleStaysWhileLoading: Story = {
parameters: {
msw: {
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 3581542d6da..febf0d2df51 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
@@ -22,10 +22,12 @@ import {
CONNECTED_ACCOUNTS,
FATHOM_ACCOUNT_ID,
FATHOM_APPLICATION_ID,
+ FATHOM_ONLY_ACCOUNT_ID,
GOOGLE_ACCOUNT_ID,
GOOGLE_MESSAGE_CHANNEL_ID,
MESSAGE_CHANNELS,
MICROSOFT_ACCOUNT_ID,
+ USER_SETTINGS_APPLICATION_PREFERENCES_GRAPHQL_HANDLER,
deleteConnectedAccount,
disconnectConnectedAccount,
seedAccountGroupsStory,
@@ -391,6 +393,32 @@ export const RowOpensAccountPage: Story = {
},
};
+export const AppOnlyAccountWithAppSettingsOpensAccountPage: Story = {
+ ...accountsTabStory,
+ parameters: {
+ msw: {
+ handlers: [
+ USER_SETTINGS_APPLICATION_PREFERENCES_GRAPHQL_HANDLER,
+ ...ACCOUNT_GROUPS_GRAPHQL_HANDLERS,
+ ],
+ },
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ expect(
+ await canvas.findByRole(
+ 'link',
+ { name: '[email protected]' },
+ { timeout: 3000 },
+ ),
+ ).toHaveAttribute(
+ 'href',
+ `/settings/app-preferences/accounts/${FATHOM_ONLY_ACCOUNT_ID}`,
+ );
+ },
+};
+
export const DisconnectCoversEveryActiveConnection: Story = {
...accountsTabStory,
play: async ({ canvasElement }) => {
diff --git a/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedAccountGroups.ts b/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedAccountGroups.ts
index 71d02cbf537..db5b30ee291 100644
--- a/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedAccountGroups.ts
+++ b/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedAccountGroups.ts
@@ -217,6 +217,68 @@ export const CALENDAR_CHANNELS = [
),
];
+export const FATHOM_USER_SETTINGS_MENU_ITEM_ID =
+ '20202020-1a2b-4c3d-8e4f-000000000051';
+export const FATHOM_USER_SETTINGS_FRONT_COMPONENT_ID =
+ '20202020-1a2b-4c3d-8e4f-000000000052';
+export const GRANOLA_USER_SETTINGS_MENU_ITEM_ID =
+ '20202020-1a2b-4c3d-8e4f-000000000053';
+const GRANOLA_USER_SETTINGS_FRONT_COMPONENT_ID =
+ '20202020-1a2b-4c3d-8e4f-000000000054';
+
+const buildUserSettingsApplicationPreferences = ({
+ applicationId,
+ settingsMenuItemId,
+ frontComponentId,
+ slug,
+}: {
+ applicationId: string;
+ settingsMenuItemId: string;
+ frontComponentId: string;
+ slug: string;
+}) => ({
+ __typename: 'ApplicationPreferences',
+ applicationId,
+ connectionProviders: [],
+ variables: [],
+ settingsMenuItems: [
+ {
+ __typename: 'SettingsMenuItem',
+ id: settingsMenuItemId,
+ universalIdentifier: settingsMenuItemId,
+ applicationId,
+ frontComponentId,
+ title: 'My settings',
+ icon: 'IconUser',
+ position: 1,
+ scope: 'USER',
+ slug,
+ },
+ ],
+});
+
+export const USER_SETTINGS_APPLICATION_PREFERENCES_GRAPHQL_HANDLER =
+ graphql.query('MyApplicationPreferences', () =>
+ HttpResponse.json({
+ data: {
+ myApplicationPreferences: [
+ buildUserSettingsApplicationPreferences({
+ applicationId: FATHOM_APPLICATION_ID,
+ settingsMenuItemId: FATHOM_USER_SETTINGS_MENU_ITEM_ID,
+ frontComponentId: FATHOM_USER_SETTINGS_FRONT_COMPONENT_ID,
+ slug: 'emails',
+ }),
+ buildUserSettingsApplicationPreferences({
+ applicationId: GRANOLA_APPLICATION_ID,
+ settingsMenuItemId: GRANOLA_USER_SETTINGS_MENU_ITEM_ID,
+ frontComponentId: GRANOLA_USER_SETTINGS_FRONT_COMPONENT_ID,
+ slug: 'my-settings',
+ }),
+ ],
+ },
+ }),
+ );
+
const deletedAccountIds = new Set<string>();
export const withoutDeletedAccounts = <TAccount extends { id: string }>(