Skip to content

The open alternative to Salesforce, designed for AI.

Show only workspace-shared connections in app settings (#28556)

nitin51ec0ac16c1d
diff --git a/packages/twenty-docs/developers/extend/apps/logic/connections.mdx b/packages/twenty-docs/developers/extend/apps/logic/connections.mdx
index d95971844b5..ad798a4997a 100644
--- a/packages/twenty-docs/developers/extend/apps/logic/connections.mdx
+++ b/packages/twenty-docs/developers/extend/apps/logic/connections.mdx
@@ -367,9 +367,9 @@ From there use `getConnection(connectedAccountId)` to read the fresh access toke
</Accordion>
-<Accordion title="Run a logic function on disconnect" description="Clean up when a connection is removed">
+<Accordion title="Run a logic function on disconnect" description="Clean up when a connection is disconnected or removed">
-Anything an app claims at connect time has to be released when the connection goes away. A Slack integration that claims a `team_id` on connect, for instance, has to release that claim so another workspace can connect the same Slack team. Set `onDisconnectLogicFunction` to reference a logic function in the same app, and it runs right before the `ConnectedAccount` and its token are deleted, so the handler can still call the provider with `getConnection` to release anything the on-connect hook set up remotely.
+Anything an app claims at connect time has to be released when the connection goes away. A Slack integration that claims a `team_id` on connect, for instance, has to release that claim so another workspace can connect the same Slack team. Set `onDisconnectLogicFunction` to reference a logic function in the same app, and it runs when the connection is disconnected and again when it is deleted.
```ts src/connection-providers/slack-connection.ts
export default defineConnectionProvider({
@@ -387,7 +387,7 @@ export default defineConnectionProvider({
});
```
-Unlike the on-connect hook it runs **inline in the disconnecting workspace**, once, without retries: a failure is captured and the disconnect still completes. The handler receives the same payload shape:
+Unlike the on-connect hook it runs **inline in the disconnecting workspace**, without retries: a failure is captured and the disconnect or delete still completes. The handler receives the same payload shape:
```ts
type OnDisconnectPayload = {
@@ -397,9 +397,9 @@ type OnDisconnectPayload = {
};
```
-The `ConnectedAccount` and its token are still present when the hook runs, so `getConnection(connectedAccountId)` resolves with a fresh access token and the handler can delete whatever it registered remotely. State the provider cannot give back (a `team_id`, an external subscription id) still belongs in the [key-value store](/developers/extend/apps/logic/key-value-store), written at connect time and keyed by `connectedAccountId`. Keep the handler short: it runs inside the disconnect request, so its `timeoutSeconds` is the upper bound on how long that request can take.
+On a disconnect the `ConnectedAccount` and its token are still present, so `getConnection(connectedAccountId)` resolves and the handler can release whatever it registered remotely. On a delete the credentials may already be gone (a member can delete a connection they disconnected earlier), so make the handler idempotent and keep the state it needs (a `team_id`, an external subscription id) in the [key-value store](/developers/extend/apps/logic/key-value-store), written at connect time and keyed by `connectedAccountId`. Keep it short: it runs inside the request, so its `timeoutSeconds` is the upper bound on how long that request can take.
-The hook fires when a connection is removed on its own. Uninstalling the app drops its connections through a database cascade instead, so the hook does not run there. Declare an `uninstallLogicFunction` on `defineApplication` for that path: it runs before the app's metadata is deleted, so it can still call `listConnections` and clean up whatever is left.
+The hook fires when a connection is disconnected or removed on its own. Uninstalling the app drops its connections through a database cascade instead, so the hook does not run there. Declare an `uninstallLogicFunction` on `defineApplication` for that path: it runs before the app's metadata is deleted, so it can still call `listConnections` and clean up whatever is left.
</Accordion>
diff --git a/packages/twenty-front/src/pages/settings/applications/SettingsApplicationConnectionDetail.tsx b/packages/twenty-front/src/pages/settings/applications/SettingsApplicationConnectionDetail.tsx
index 587b1085741..75f22107498 100644
--- a/packages/twenty-front/src/pages/settings/applications/SettingsApplicationConnectionDetail.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/SettingsApplicationConnectionDetail.tsx
@@ -113,7 +113,9 @@ export const SettingsApplicationConnectionDetail = () => {
const application = data?.findOneApplication;
const providerIds = new Set(
- connectionProviders.map((provider) => provider.id),
+ connectionProviders
+ .filter((provider) => provider.scope === 'WORKSPACE')
+ .map((provider) => provider.id),
);
const connection = connectedAccounts.find(
(account) =>
@@ -134,7 +136,7 @@ export const SettingsApplicationConnectionDetail = () => {
connection.name.trim() !== ''
? connection.name
: (connection?.handle ?? t`Connection`);
- const deleteModalId = `delete-application-connection-modal-${connectedAccountId}`;
+ const removeDialogId = `remove-application-connection-modal-${connectedAccountId}`;
const applicationSettingsPath = getSettingsPath(
SettingsPath.ApplicationDetail,
{ applicationId },
@@ -159,7 +161,7 @@ export const SettingsApplicationConnectionDetail = () => {
});
};
- const handleDelete = async () => {
+ const handleRemove = async () => {
if (connection === undefined) {
return;
}
@@ -197,17 +199,6 @@ export const SettingsApplicationConnectionDetail = () => {
label: t`Handle`,
value: <StyledMonoText>{connection.handle}</StyledMonoText>,
},
- {
- key: 'scope',
- label: t`Visibility`,
- value: (
- <Status color={connection.scope === 'WORKSPACE' ? 'blue' : 'gray'}>
- {connection.scope === 'WORKSPACE'
- ? t`Workspace shared`
- : t`Just for me`}
- </Status>
- ),
- },
{
key: 'status',
label: t`Status`,
@@ -320,10 +311,10 @@ export const SettingsApplicationConnectionDetail = () => {
)}
<Button
startIcon={<IconTrash />}
- onClick={() => openDialog(deleteModalId)}
+ onClick={() => openDialog(removeDialogId)}
variant="outline"
color="danger"
- >{t`Disconnect`}</Button>
+ >{t`Remove`}</Button>
</StyledActions>
</Section.Root>
<Section.Root>
@@ -354,15 +345,16 @@ export const SettingsApplicationConnectionDetail = () => {
</Table>
</Section.Root>
<ConfirmationDialog
- dialogId={deleteModalId}
- title={t`Disconnect connection?`}
+ dialogId={removeDialogId}
+ title={t`Remove connection?`}
subtitle={
<Trans>
- This will disconnect {connectionLabel} from this application.
+ This permanently removes {connectionLabel}. The app loses
+ access to it.
</Trans>
}
- onConfirmClick={handleDelete}
- confirmButtonText={t`Disconnect`}
+ onConfirmClick={handleRemove}
+ confirmButtonText={t`Remove`}
loading={isDeleting}
/>
</>
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.tsx
index d313b0ec2b9..190457afb75 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
@@ -143,7 +143,7 @@ describe('SettingsApplicationConnectionDetail', () => {
__typename: 'ApplicationConnectedAccountDTO',
id: 'account-1',
handle: '[email protected]',
- authFailedAt: null,
+ authFailedAt: '2026-05-01T00:00:00.000Z',
scopes: ['calendar.readonly'],
lastSignedInAt: null,
connectionProviderId: 'provider-1',
@@ -159,7 +159,7 @@ describe('SettingsApplicationConnectionDetail', () => {
});
});
- it('offers reconnect and disconnect on a failed workspace shared connection', () => {
+ it('offers reconnect and remove on a failed workspace shared connection', () => {
mockedUseApplicationConnectedAccounts.mockReturnValue({
accounts: [
{
@@ -183,7 +183,6 @@ describe('SettingsApplicationConnectionDetail', () => {
renderDetailPage();
- expect(screen.getByText('Workspace shared')).toBeVisible();
expect(screen.getByText('Reconnect needed')).toBeVisible();
fireEvent.click(screen.getByText('Reconnect'));
@@ -196,13 +195,13 @@ describe('SettingsApplicationConnectionDetail', () => {
redirectLocation: '/settings/applications/app-1/connections/account-1',
});
- const [disconnectButton] = screen.getAllByText('Disconnect');
+ const [removeButton] = screen.getAllByRole('button', { name: 'Remove' });
- fireEvent.click(disconnectButton);
+ fireEvent.click(removeButton);
expect(mockOpenModal).toHaveBeenCalledTimes(1);
expect(mockOpenModal).toHaveBeenCalledWith(
- 'delete-application-connection-modal-account-1',
+ 'remove-application-connection-modal-account-1',
);
});
});
diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationConnectionsSection.tsx b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationConnectionsSection.tsx
index 50efff9516a..60e8221487f 100644
--- a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationConnectionsSection.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationConnectionsSection.tsx
@@ -13,13 +13,11 @@ 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 { 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';
-const CONNECTION_TABLE_ROW_GRID_TEMPLATE_COLUMNS =
- 'minmax(0, 1fr) 160px 180px 36px';
+const CONNECTION_TABLE_ROW_GRID_TEMPLATE_COLUMNS = 'minmax(0, 1fr) 160px 36px';
export const SettingsApplicationConnectionsSection = ({
applicationId,
@@ -40,27 +38,23 @@ export const SettingsApplicationConnectionsSection = ({
return (
<>
{connectionProviders.map((provider) => {
+ if (provider.scope !== 'WORKSPACE') {
+ return null;
+ }
+
const canStartAuthorization =
canStartConnectionProviderAuthorization(provider);
- const canAddConnection = provider.scope === 'WORKSPACE';
-
const providerConnections = connectedAccounts.filter(
(account) => account.connectionProviderId === provider.id,
);
- if (!canAddConnection && providerConnections.length === 0) {
- return null;
- }
-
return (
<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
- }
+ shouldShowMissingCredentialsBanner={!canStartAuthorization}
>
{providerConnections.length > 0 && (
<Table>
@@ -71,7 +65,6 @@ export const SettingsApplicationConnectionsSection = ({
>
<TableHeader>{t`Connection`}</TableHeader>
<TableHeader>{t`Status`}</TableHeader>
- <TableHeader>{t`Visibility`}</TableHeader>
<TableHeader />
</TableRow>
<SettingsApplicationConnectionTableRows>
@@ -106,17 +99,6 @@ export const SettingsApplicationConnectionsSection = ({
connection={connection}
/>
</TableCell>
- <TableCell clickable>
- <Status
- color={
- connection.scope === 'WORKSPACE' ? 'blue' : 'gray'
- }
- >
- {connection.scope === 'WORKSPACE'
- ? t`Workspace shared`
- : t`Just for me`}
- </Status>
- </TableCell>
<TableCell
align="right"
color={themeCssVariables.font.color.tertiary}
@@ -133,7 +115,7 @@ export const SettingsApplicationConnectionsSection = ({
</SettingsApplicationConnectionTableRows>
</Table>
)}
- {canAddConnection && canStartAuthorization && (
+ {canStartAuthorization && (
<SettingsApplicationAddConnectionButton
applicationId={applicationId}
providerName={provider.name}
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.tsx
index 0b5098afd27..afe614cd90a 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
@@ -103,7 +103,6 @@ describe('SettingsApplicationConnectionsSection', () => {
'/settings/applications/app-1/connections/account-1',
);
expect(screen.getByText('Reconnect needed')).toBeVisible();
- expect(screen.getByText('Workspace shared')).toBeVisible();
expect(
screen.queryByRole('button', { name: 'Reconnect' }),
).not.toBeInTheDocument();
@@ -200,85 +199,79 @@ describe('SettingsApplicationConnectionsSection', () => {
});
});
- it('hides a provider scoped to each member when the caller sees none of its connections', () => {
- mockedUseFindApplicationConnectionProviders.mockReturnValue({
- connectionProviders: [
- {
- id: 'provider-1',
- applicationId: 'app-1',
- type: 'oauth',
- name: 'google-calendar',
- displayName: 'Google Calendar',
- scope: 'USER',
- logoUrl: null,
- oauth: {
- scopes: ['calendar.readonly'],
- isClientCredentialsConfigured: false,
- },
- },
- ],
- loading: false,
- refetch: jest.fn(),
- });
+ const buildProvider = ({
+ scope,
+ isClientCredentialsConfigured = true,
+ }: {
+ scope: 'USER' | 'WORKSPACE';
+ isClientCredentialsConfigured?: boolean;
+ }) => ({
+ id: 'provider-1',
+ applicationId: 'app-1',
+ type: 'oauth' as const,
+ name: 'google-calendar',
+ displayName: 'Google Calendar',
+ scope,
+ logoUrl: null,
+ oauth: {
+ scopes: ['calendar.readonly'],
+ isClientCredentialsConfigured,
+ },
+ });
- mockedUseApplicationConnectedAccounts.mockReturnValue({
- accounts: [],
- loading: false,
- refetch: jest.fn(),
- });
+ const buildAccount = ({
+ id,
+ name,
+ scope,
+ }: {
+ id: string;
+ name: string;
+ scope: ConnectedAccountScope;
+ }) => ({
+ __typename: 'ApplicationConnectedAccountDTO' as const,
+ id,
+ handle: `${id}@example.com`,
+ authFailedAt: null,
+ scopes: ['calendar.readonly'],
+ lastSignedInAt: null,
+ connectionProviderId: 'provider-1',
+ name,
+ scope,
+ lastCredentialsRefreshedAt: null,
+ createdAt: '2026-05-01T00:00:00.000Z',
+ updatedAt: '2026-05-01T00:00:00.000Z',
+ });
- render(
- <I18nProvider i18n={i18n}>
- <MemoryRouter>
- <SettingsApplicationConnectionsSection applicationId="app-1" />
- </MemoryRouter>
- </I18nProvider>,
- );
+ const SHARED_ACCOUNT = buildAccount({
+ id: 'shared-account',
+ name: 'Team calendar',
+ scope: ConnectedAccountScope.WORKSPACE,
+ });
- expect(screen.queryByText('Google Calendar')).not.toBeInTheDocument();
- expect(
- screen.queryByRole('button', { name: /Add connection/i }),
- ).not.toBeInTheDocument();
+ const PERSONAL_ACCOUNT = buildAccount({
+ id: 'personal-account',
+ name: 'My calendar',
+ scope: ConnectedAccountScope.USER,
});
- it('lists the connections of a provider scoped to each member without offering to add one', () => {
+ const renderSection = ({
+ providerScope,
+ accounts,
+ isClientCredentialsConfigured = true,
+ }: {
+ providerScope: 'USER' | 'WORKSPACE';
+ accounts: ReturnType<typeof buildAccount>[];
+ isClientCredentialsConfigured?: boolean;
+ }) => {
mockedUseFindApplicationConnectionProviders.mockReturnValue({
connectionProviders: [
- {
- id: 'provider-1',
- applicationId: 'app-1',
- type: 'oauth',
- name: 'google-calendar',
- displayName: 'Google Calendar',
- scope: 'USER',
- logoUrl: null,
- oauth: {
- scopes: ['calendar.readonly'],
- isClientCredentialsConfigured: false,
- },
- },
+ buildProvider({ scope: providerScope, isClientCredentialsConfigured }),
],
loading: false,
refetch: jest.fn(),
});
-
mockedUseApplicationConnectedAccounts.mockReturnValue({
- accounts: [
- {
- __typename: 'ApplicationConnectedAccountDTO',
- id: 'account-1',
- handle: '[email protected]',
- authFailedAt: null,
- scopes: ['calendar.readonly'],
- lastSignedInAt: null,
- connectionProviderId: 'provider-1',
- name: 'My calendar',
- scope: ConnectedAccountScope.USER,
- lastCredentialsRefreshedAt: null,
- createdAt: '2026-05-01T00:00:00.000Z',
- updatedAt: '2026-05-01T00:00:00.000Z',
- },
- ],
+ accounts,
loading: false,
refetch: jest.fn(),
});
@@ -290,9 +283,29 @@ describe('SettingsApplicationConnectionsSection', () => {
</MemoryRouter>
</I18nProvider>,
);
+ };
- expect(screen.getByRole('link', { name: /My calendar/i })).toBeVisible();
- expect(screen.getByText('Just for me')).toBeVisible();
+ it('lists the rows of a workspace provider', () => {
+ renderSection({
+ providerScope: 'WORKSPACE',
+ accounts: [SHARED_ACCOUNT],
+ });
+
+ expect(screen.getByRole('link', { name: /Team calendar/i })).toBeVisible();
+ expect(
+ screen.getByRole('button', { name: /Add connection/i }),
+ ).toBeVisible();
+ });
+
+ it('does not list a member-scoped provider', () => {
+ renderSection({
+ providerScope: 'USER',
+ accounts: [PERSONAL_ACCOUNT],
+ isClientCredentialsConfigured: false,
+ });
+
+ expect(screen.queryByText('Google Calendar')).not.toBeInTheDocument();
+ expect(screen.queryByText('My calendar')).not.toBeInTheDocument();
expect(
screen.queryByRole('button', { name: /Add connection/i }),
).not.toBeInTheDocument();