Skip to content

The open alternative to Salesforce, designed for AI.

Render the member Apps tab with the shared installed applications table (#29112)

nitinf15df0fc7a52
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAppNameCell.tsx b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAppNameCell.tsx
deleted file mode 100644
index 8676008d092..00000000000
--- a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAppNameCell.tsx
+++ /dev/null
@@ -1,65 +0,0 @@
-import { AppChip } from '@/applications/components/AppChip';
-import { getApplicationDisplayName } from '@/applications/utils/getApplicationDisplayName';
-import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
-import { type AppPreferencesRow } from '@/settings/app-preferences/types/AppPreferencesRow';
-import { UndecoratedLink } from '@/ui/navigation/link/components/UndecoratedLink/UndecoratedLink';
-import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
-import { styled } from '@linaria/react';
-import { useLingui } from '@lingui/react/macro';
-import { SettingsPath } from 'twenty-shared/types';
-import { getSettingsPath } from 'twenty-shared/utils';
-import { themeCssVariables, useTheme } from 'twenty-ui/theme';
-
-const StyledNameCell = styled.div`
- align-items: center;
- color: ${themeCssVariables.font.color.primary};
- display: flex;
- gap: ${themeCssVariables.spacing[2]};
-`;
-
-type SettingsAppPreferencesAppNameCellProps = {
- item: AppPreferencesRow;
-};
-
-export const SettingsAppPreferencesAppNameCell = ({
- item,
-}: SettingsAppPreferencesAppNameCellProps) => {
- const { t } = useLingui();
- const theme = useTheme();
- const currentWorkspace = useAtomStateValue(currentWorkspaceState);
-
- const { to, icon, name } =
- item.type === 'builtIn'
- ? {
- to: getSettingsPath(SettingsPath.BuiltInAccountApp, {
- builtInAccountAppId: item.builtInAccountApp.id,
- }),
- icon: <item.builtInAccountApp.Icon size={theme.icon.size.md} />,
- name: t(item.builtInAccountApp.name),
- }
- : {
- to: getSettingsPath(SettingsPath.ApplicationPreferences, {
- applicationId: item.applicationWithPreferences.application.id,
- }),
- icon: (
- <AppChip
- applicationId={item.applicationWithPreferences.application.id}
- size="md"
- chipOnly
- />
- ),
- name: getApplicationDisplayName({
- application: item.applicationWithPreferences.application,
- currentWorkspace,
- }),
- };
-
- return (
- <UndecoratedLink to={to} onClick={(event) => event.stopPropagation()}>
- <StyledNameCell>
- {icon}
- {name}
- </StyledNameCell>
- </UndecoratedLink>
- );
-};
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAppStatusCell.tsx b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAppStatusCell.tsx
index d61d2bbdff8..447619d7004 100644
--- a/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAppStatusCell.tsx
+++ b/packages/twenty-front/src/modules/settings/app-preferences/components/SettingsAppPreferencesAppStatusCell.tsx
@@ -1,78 +1,31 @@
import { SettingsConnectedAccountSyncStatus } from '@/settings/app-preferences/components/SettingsConnectedAccountSyncStatus';
-import { useMyAccountGroups } from '@/settings/app-preferences/hooks/useMyAccountGroups';
-import { type AppPreferencesRow } from '@/settings/app-preferences/types/AppPreferencesRow';
-import { getBuiltInAccountAppsUsingAccount } from '@/settings/app-preferences/utils/getBuiltInAccountAppsUsingAccount';
-import { SyncStatus } from '@/settings/accounts/constants/SyncStatus';
-import { computeSyncStatus } from '@/settings/accounts/utils/computeSyncStatus';
-import { isApplicationConnectionReconnectNeeded } from '@/settings/applications/utils/isApplicationConnectionReconnectNeeded';
+import { type AppPreferencesAppStatus } from '@/settings/app-preferences/types/AppPreferencesAppStatus';
import { useLingui } from '@lingui/react/macro';
-import { isDefined, isNonEmptyArray } from 'twenty-shared/utils';
-import { Status } from 'twenty-ui/primitives/data-display';
+import { Status, Tag } from 'twenty-ui/primitives/data-display';
type SettingsAppPreferencesAppStatusCellProps = {
- item: AppPreferencesRow;
+ status?: AppPreferencesAppStatus;
};
export const SettingsAppPreferencesAppStatusCell = ({
- item,
+ status,
}: SettingsAppPreferencesAppStatusCellProps) => {
const { t } = useLingui();
- const { groups, loading } = useMyAccountGroups();
- if (loading) {
- return null;
- }
-
- if (item.type === 'builtIn') {
- const activeAccounts = groups
- .map((group) => group.builtInAccount)
- .filter(isDefined)
- .filter(
- (account) =>
- !isDefined(account.archivedAt) &&
- getBuiltInAccountAppsUsingAccount(account).some(
- (app) => app.id === item.builtInAccountApp.id,
- ),
- );
- const findAccountWithStatus = (status: SyncStatus) =>
- activeAccounts.find(
- (account) =>
- computeSyncStatus(
- account.messageChannels[0],
- account.calendarChannels[0],
- ) === status,
+ switch (status?.type) {
+ case 'accountSyncIssue':
+ return <SettingsConnectedAccountSyncStatus account={status.account} />;
+ case 'reconnectNeeded':
+ return <Status color="red">{t`Reconnect needed`}</Status>;
+ case 'missingConfiguration':
+ return <Status color="red">{t`Missing configuration`}</Status>;
+ case 'notConnected':
+ return (
+ <Tag color="gray" weight="regular" truncate={false}>
+ {t`Not connected`}
+ </Tag>
);
- const brokenAccount =
- findAccountWithStatus(SyncStatus.FAILED) ??
- findAccountWithStatus(SyncStatus.PENDING_CONFIGURATION);
-
- if (!isDefined(brokenAccount)) {
+ default:
return null;
- }
-
- return <SettingsConnectedAccountSyncStatus account={brokenAccount} />;
- }
-
- const { application, connectionProviders, missingRequiredVariables } =
- item.applicationWithPreferences;
- const activeConnections = groups.flatMap((group) =>
- group.appAccounts.filter(
- (account) =>
- account.applicationId === application.id &&
- !isDefined(account.archivedAt),
- ),
- );
-
- if (activeConnections.some(isApplicationConnectionReconnectNeeded)) {
- return <Status color="red">{t`Reconnect needed`}</Status>;
- }
-
- const isAppInUse =
- !isNonEmptyArray(connectionProviders) || isNonEmptyArray(activeConnections);
-
- if (!isAppInUse || !isNonEmptyArray(missingRequiredVariables)) {
- return null;
}
-
- return <Status color="red">{t`Missing configuration`}</Status>;
};
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 e492bfaee10..2e0c67ad5a4 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
@@ -1,15 +1,13 @@
-import { SettingsAppPreferencesAppNameCell } from '@/settings/app-preferences/components/SettingsAppPreferencesAppNameCell';
-import { SettingsAppPreferencesAppStatusCell } from '@/settings/app-preferences/components/SettingsAppPreferencesAppStatusCell';
import { useApplicationsWithPreferences } from '@/settings/app-preferences/hooks/useApplicationsWithPreferences';
import { useEnabledBuiltInAccountApps } from '@/settings/app-preferences/hooks/useEnabledBuiltInAccountApps';
-import { type AppPreferencesRow } from '@/settings/app-preferences/types/AppPreferencesRow';
+import { useMyAccountGroups } from '@/settings/app-preferences/hooks/useMyAccountGroups';
+import { getAppPreferencesAppStatusById } from '@/settings/app-preferences/utils/getAppPreferencesAppStatusById';
import { SettingsApplicationLoadErrorBanner } from '@/settings/applications/components/SettingsApplicationLoadErrorBanner';
-import { SettingsTableListSection } from '@/settings/components/SettingsTableListSection';
+import { SettingsApplicationsTable } from '@/settings/applications/components/SettingsApplicationsTable';
import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
-import { SettingsPath } from 'twenty-shared/types';
+import { isDefined } from 'twenty-shared/utils';
import { themeCssVariables } from 'twenty-ui/theme';
-import { useNavigateSettings } from '~/hooks/useNavigateSettings';
const StyledToolbar = styled.div`
padding-bottom: ${themeCssVariables.spacing[2]};
@@ -17,7 +15,6 @@ const StyledToolbar = styled.div`
export const SettingsAppPreferencesAppsSection = () => {
const { t } = useLingui();
- const navigateSettings = useNavigateSettings();
const { enabledBuiltInAccountApps } = useEnabledBuiltInAccountApps();
const {
applicationsWithPreferences,
@@ -26,61 +23,53 @@ export const SettingsAppPreferencesAppsSection = () => {
hasApplicationsLoadError,
refetch,
} = useApplicationsWithPreferences();
+ const {
+ groups,
+ loading: accountGroupsLoading,
+ error: accountGroupsError,
+ refetch: refetchAccountGroups,
+ } = useMyAccountGroups();
const isLoadingApplications =
loading && !hasLoadedApplicationsWithPreferences;
-
- const rows: AppPreferencesRow[] = [
- ...enabledBuiltInAccountApps.map(
- (builtInAccountApp): AppPreferencesRow => ({
- type: 'builtIn',
- id: builtInAccountApp.id,
- builtInAccountApp,
- }),
- ),
- ...applicationsWithPreferences.map(
- (applicationWithPreferences): AppPreferencesRow => ({
- type: 'installed',
- id: applicationWithPreferences.application.id,
- applicationWithPreferences,
- }),
- ),
- ];
+ const hasAccountGroupsLoadError = isDefined(accountGroupsError);
+ const statusById =
+ accountGroupsLoading || hasAccountGroupsLoadError
+ ? {}
+ : getAppPreferencesAppStatusById({
+ groups,
+ builtInAccountApps: enabledBuiltInAccountApps,
+ applicationsWithPreferences,
+ });
return (
- <SettingsTableListSection<AppPreferencesRow>
+ <SettingsApplicationsTable
title={t`Apps`}
description={t`Choose your preferences for the apps installed on your workspace by the admin`}
toolbar={
- hasApplicationsLoadError ? (
+ hasApplicationsLoadError || hasAccountGroupsLoadError ? (
<StyledToolbar>
- <SettingsApplicationLoadErrorBanner
- message={t`Your installed apps could not be loaded. Check your connection and try again.`}
- onRetry={() => refetch().catch(() => undefined)}
- />
+ {hasApplicationsLoadError && (
+ <SettingsApplicationLoadErrorBanner
+ message={t`Your installed apps could not be loaded. Check your connection and try again.`}
+ onRetry={() => refetch().catch(() => undefined)}
+ />
+ )}
+ {hasAccountGroupsLoadError && (
+ <SettingsApplicationLoadErrorBanner
+ message={t`Your connections could not be loaded. Check your connection and try again.`}
+ onRetry={() => refetchAccountGroups().catch(() => undefined)}
+ />
+ )}
</StyledToolbar>
) : undefined
}
- items={rows}
+ applications={applicationsWithPreferences.map(
+ ({ application }) => application,
+ )}
+ builtInAccountApps={enabledBuiltInAccountApps}
+ variant="member"
+ statusById={statusById}
isLoading={isLoadingApplications}
- columns={[
- { label: t`App`, Cell: SettingsAppPreferencesAppNameCell },
- {
- label: t`Status`,
- align: 'right',
- Cell: SettingsAppPreferencesAppStatusCell,
- },
- ]}
- gridAutoColumns="1fr 1fr"
- showRowChevron
- onRowClick={(row) =>
- row.type === 'builtIn'
- ? navigateSettings(SettingsPath.BuiltInAccountApp, {
- builtInAccountAppId: row.builtInAccountApp.id,
- })
- : navigateSettings(SettingsPath.ApplicationPreferences, {
- applicationId: row.applicationWithPreferences.application.id,
- })
- }
/>
);
};
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/hooks/useMyAccountGroups.ts b/packages/twenty-front/src/modules/settings/app-preferences/hooks/useMyAccountGroups.ts
index b23802c2459..9d601f9dcb8 100644
--- a/packages/twenty-front/src/modules/settings/app-preferences/hooks/useMyAccountGroups.ts
+++ b/packages/twenty-front/src/modules/settings/app-preferences/hooks/useMyAccountGroups.ts
@@ -10,12 +10,14 @@ const ACCOUNT_GROUP_PROVIDERS: ReadonlySet<ConnectedAccountProvider> = new Set([
]);
export const useMyAccountGroups = () => {
- const { accounts, loading } = useMyPersonalConnectedAccounts({
+ const { accounts, loading, error, refetch } = useMyPersonalConnectedAccounts({
providers: ACCOUNT_GROUP_PROVIDERS,
});
return {
groups: groupConnectedAccountsByBuiltInAccount(accounts),
loading,
+ error,
+ refetch,
};
};
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/types/AppPreferencesAppStatus.ts b/packages/twenty-front/src/modules/settings/app-preferences/types/AppPreferencesAppStatus.ts
new file mode 100644
index 00000000000..943f9b719fc
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/app-preferences/types/AppPreferencesAppStatus.ts
@@ -0,0 +1,7 @@
+import { type ConnectedAccount } from '@/accounts/types/ConnectedAccount';
+
+export type AppPreferencesAppStatus<TConnectedAccount = ConnectedAccount> =
+ | { type: 'accountSyncIssue'; account: TConnectedAccount }
+ | { type: 'reconnectNeeded' }
+ | { type: 'missingConfiguration' }
+ | { type: 'notConnected' };
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/types/AppPreferencesAppStatusAccount.ts b/packages/twenty-front/src/modules/settings/app-preferences/types/AppPreferencesAppStatusAccount.ts
new file mode 100644
index 00000000000..c5df7a49b68
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/app-preferences/types/AppPreferencesAppStatusAccount.ts
@@ -0,0 +1,11 @@
+import { type CalendarChannel } from '@/accounts/types/CalendarChannel';
+import { type ConnectedAccount } from '@/accounts/types/ConnectedAccount';
+import { type MessageChannel } from '@/accounts/types/MessageChannel';
+
+export type AppPreferencesAppStatusAccount = Pick<
+ ConnectedAccount,
+ 'provider' | 'archivedAt' | 'authFailedAt' | 'applicationId'
+> & {
+ messageChannels: Pick<MessageChannel, 'type' | 'syncStatus' | 'syncStage'>[];
+ calendarChannels: Pick<CalendarChannel, 'syncStatus' | 'syncStage'>[];
+};
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/types/AppPreferencesAppStatusApplication.ts b/packages/twenty-front/src/modules/settings/app-preferences/types/AppPreferencesAppStatusApplication.ts
new file mode 100644
index 00000000000..63210c2be40
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/app-preferences/types/AppPreferencesAppStatusApplication.ts
@@ -0,0 +1,13 @@
+import { type ApplicationWithPreferences } from '@/settings/app-preferences/types/ApplicationWithPreferences';
+import { type canStartConnectionProviderAuthorization } from '@/settings/applications/utils/canStartConnectionProviderAuthorization';
+
+export type AppPreferencesAppStatusApplication = {
+ application: Pick<ApplicationWithPreferences['application'], 'id'>;
+ connectionProviders: Parameters<
+ typeof canStartConnectionProviderAuthorization
+ >[0][];
+ missingRequiredVariables: Pick<
+ ApplicationWithPreferences['missingRequiredVariables'][number],
+ 'key'
+ >[];
+};
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/types/AppPreferencesRow.ts b/packages/twenty-front/src/modules/settings/app-preferences/types/AppPreferencesRow.ts
deleted file mode 100644
index b4fbac3d922..00000000000
--- a/packages/twenty-front/src/modules/settings/app-preferences/types/AppPreferencesRow.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { type ApplicationWithPreferences } from '@/settings/app-preferences/types/ApplicationWithPreferences';
-import { type BuiltInAccountApp } from '@/settings/app-preferences/types/BuiltInAccountApp';
-
-export type AppPreferencesRow =
- | { type: 'builtIn'; id: string; builtInAccountApp: BuiltInAccountApp }
- | {
- type: 'installed';
- id: string;
- applicationWithPreferences: ApplicationWithPreferences;
- };
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/utils/__tests__/getAppPreferencesAppStatusById.test.ts b/packages/twenty-front/src/modules/settings/app-preferences/utils/__tests__/getAppPreferencesAppStatusById.test.ts
new file mode 100644
index 00000000000..9c945f7c17f
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/app-preferences/utils/__tests__/getAppPreferencesAppStatusById.test.ts
@@ -0,0 +1,152 @@
+import { getAppPreferencesAppStatusById } from '@/settings/app-preferences/utils/getAppPreferencesAppStatusById';
+import {
+ ConnectedAccountProvider,
+ MessageChannelSyncStage,
+ MessageChannelSyncStatus,
+ MessageChannelType,
+} from 'twenty-shared/types';
+
+const APPLICATION_ID = 'linear-application-id';
+
+const buildAccount = ({
+ provider = ConnectedAccountProvider.APP,
+ applicationId = APPLICATION_ID,
+ archivedAt = null,
+ authFailedAt = null,
+ messageChannelSyncStatus = MessageChannelSyncStatus.ACTIVE,
+}: {
+ provider?: ConnectedAccountProvider;
+ applicationId?: string | null;
+ archivedAt?: string | null;
+ authFailedAt?: string | null;
+ messageChannelSyncStatus?: MessageChannelSyncStatus;
+} = {}) => ({
+ provider,
+ applicationId,
+ archivedAt,
+ authFailedAt,
+ messageChannels:
+ provider === ConnectedAccountProvider.APP
+ ? []
+ : [
+ {
+ type: MessageChannelType.EMAIL,
+ syncStatus: messageChannelSyncStatus,
+ syncStage: MessageChannelSyncStage.MESSAGE_LIST_FETCH_PENDING,
+ },
+ ],
+ calendarChannels: [],
+});
+
+const buildApplication = ({
+ isClientCredentialsConfigured = true,
+ hasConnectionProvider = true,
+ hasMissingRequiredVariable = false,
+}: {
+ isClientCredentialsConfigured?: boolean;
+ hasConnectionProvider?: boolean;
+ hasMissingRequiredVariable?: boolean;
+} = {}) => ({
+ application: { id: APPLICATION_ID },
+ connectionProviders: hasConnectionProvider
+ ? [{ type: 'oauth', oauth: { isClientCredentialsConfigured } }]
+ : [],
+ missingRequiredVariables: hasMissingRequiredVariable
+ ? [{ key: 'API_KEY' }]
+ : [],
+});
+
+const getStatusOfInstalledApplication = ({
+ application = buildApplication(),
+ appAccounts = [],
+}: {
+ application?: ReturnType<typeof buildApplication>;
+ appAccounts?: ReturnType<typeof buildAccount>[];
+}) =>
+ getAppPreferencesAppStatusById({
+ groups: [{ id: 'group', handle: '[email protected]', appAccounts }],
+ builtInAccountApps: [],
+ applicationsWithPreferences: [application],
+ })[APPLICATION_ID];
+
+describe('getAppPreferencesAppStatusById', () => {
+ it('flags a built-in app whose active account failed to sync', () => {
+ const failedAccount = buildAccount({
+ provider: ConnectedAccountProvider.GOOGLE,
+ applicationId: null,
+ messageChannelSyncStatus: MessageChannelSyncStatus.FAILED_UNKNOWN,
+ });
+
+ expect(
+ getAppPreferencesAppStatusById({
+ groups: [
+ {
+ id: 'group',
+ handle: '[email protected]',
+ builtInAccount: failedAccount,
+ appAccounts: [],
+ },
+ ],
+ builtInAccountApps: [{ id: 'google' }, { id: 'outlook' }],
+ applicationsWithPreferences: [],
+ }),
+ ).toEqual({
+ google: { type: 'accountSyncIssue', account: failedAccount },
+ });
+ });
+
+ it('asks to reconnect when an active connection failed to authenticate', () => {
+ expect(
+ getStatusOfInstalledApplication({
+ appAccounts: [buildAccount({ authFailedAt: '2026-09-01' })],
+ }),
+ ).toEqual({ type: 'reconnectNeeded' });
+ });
+
+ it('flags missing configuration when the app is in use', () => {
+ expect(
+ getStatusOfInstalledApplication({
+ application: buildApplication({ hasMissingRequiredVariable: true }),
+ appAccounts: [buildAccount()],
+ }),
+ ).toEqual({ type: 'missingConfiguration' });
+ expect(
+ getStatusOfInstalledApplication({
+ application: buildApplication({
+ hasConnectionProvider: false,
+ hasMissingRequiredVariable: true,
+ }),
+ }),
+ ).toEqual({ type: 'missingConfiguration' });
+ });
+
+ it('hints at connecting when a provider can authorize and nothing is connected', () => {
+ expect(getStatusOfInstalledApplication({})).toEqual({
+ type: 'notConnected',
+ });
+ expect(
+ getStatusOfInstalledApplication({
+ application: buildApplication({ hasMissingRequiredVariable: true }),
+ appAccounts: [buildAccount({ archivedAt: '2026-09-01' })],
+ }),
+ ).toEqual({ type: 'notConnected' });
+ });
+
+ it('shows nothing for a connected app, an app without providers or an unconfigured provider', () => {
+ expect(
+ getStatusOfInstalledApplication({ appAccounts: [buildAccount()] }),
+ ).toBeUndefined();
+ expect(
+ getStatusOfInstalledApplication({
+ application: buildApplication({ hasConnectionProvider: false }),
+ }),
+ ).toBeUndefined();
+ expect(
+ getStatusOfInstalledApplication({
+ application: buildApplication({
+ isClientCredentialsConfigured: false,
+ }),
+ }),
+ ).toBeUndefined();
+ });
+});
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/utils/getAppPreferencesAppStatusById.ts b/packages/twenty-front/src/modules/settings/app-preferences/utils/getAppPreferencesAppStatusById.ts
new file mode 100644
index 00000000000..039682a6234
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/app-preferences/utils/getAppPreferencesAppStatusById.ts
@@ -0,0 +1,57 @@
+import { type AppPreferencesAppStatus } from '@/settings/app-preferences/types/AppPreferencesAppStatus';
+import { type AppPreferencesAppStatusAccount } from '@/settings/app-preferences/types/AppPreferencesAppStatusAccount';
+import { type AppPreferencesAppStatusApplication } from '@/settings/app-preferences/types/AppPreferencesAppStatusApplication';
+import { type BuiltInAccountApp } from '@/settings/app-preferences/types/BuiltInAccountApp';
+import { type ConnectedAccountGroup } from '@/settings/app-preferences/types/ConnectedAccountGroup';
+import { getBuiltInAccountAppStatus } from '@/settings/app-preferences/utils/getBuiltInAccountAppStatus';
+import { getInstalledApplicationStatus } from '@/settings/app-preferences/utils/getInstalledApplicationStatus';
+import { isDefined } from 'twenty-shared/utils';
+
+export const getAppPreferencesAppStatusById = <
+ TConnectedAccount extends AppPreferencesAppStatusAccount,
+>({
+ groups,
+ builtInAccountApps,
+ applicationsWithPreferences,
+}: {
+ groups: ConnectedAccountGroup<TConnectedAccount>[];
+ builtInAccountApps: Pick<BuiltInAccountApp, 'id'>[];
+ applicationsWithPreferences: AppPreferencesAppStatusApplication[];
+}): Record<string, AppPreferencesAppStatus<TConnectedAccount>> => {
+ const activeBuiltInAccounts = groups
+ .map((group) => group.builtInAccount)
+ .filter(isDefined)
+ .filter((account) => !isDefined(account.archivedAt));
+ const activeAppAccounts = groups
+ .flatMap((group) => group.appAccounts)
+ .filter((account) => !isDefined(account.archivedAt));
+
+ const statusById: Record<
+ string,
+ AppPreferencesAppStatus<TConnectedAccount>
+ > = {};
+
+ for (const { id } of builtInAccountApps) {
+ const status = getBuiltInAccountAppStatus({
+ builtInAccountAppId: id,
+ activeBuiltInAccounts,
+ });
+
+ if (isDefined(status)) {
+ statusById[id] = status;
+ }
+ }
+
+ for (const applicationWithPreferences of applicationsWithPreferences) {
+ const status = getInstalledApplicationStatus({
+ applicationWithPreferences,
+ activeAppAccounts,
+ });
+
+ if (isDefined(status)) {
+ statusById[applicationWithPreferences.application.id] = status;
+ }
+ }
+
+ return statusById;
+};
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/utils/getBuiltInAccountAppStatus.ts b/packages/twenty-front/src/modules/settings/app-preferences/utils/getBuiltInAccountAppStatus.ts
new file mode 100644
index 00000000000..ac215aa04ad
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/app-preferences/utils/getBuiltInAccountAppStatus.ts
@@ -0,0 +1,38 @@
+import { SyncStatus } from '@/settings/accounts/constants/SyncStatus';
+import { computeSyncStatus } from '@/settings/accounts/utils/computeSyncStatus';
+import { type AppPreferencesAppStatus } from '@/settings/app-preferences/types/AppPreferencesAppStatus';
+import { type AppPreferencesAppStatusAccount } from '@/settings/app-preferences/types/AppPreferencesAppStatusAccount';
+import { type BuiltInAccountApp } from '@/settings/app-preferences/types/BuiltInAccountApp';
+import { getBuiltInAccountAppsUsingAccount } from '@/settings/app-preferences/utils/getBuiltInAccountAppsUsingAccount';
+import { isDefined } from 'twenty-shared/utils';
+
+export const getBuiltInAccountAppStatus = <
+ TConnectedAccount extends AppPreferencesAppStatusAccount,
+>({
+ builtInAccountAppId,
+ activeBuiltInAccounts,
+}: {
+ builtInAccountAppId: BuiltInAccountApp['id'];
+ activeBuiltInAccounts: TConnectedAccount[];
+}): AppPreferencesAppStatus<TConnectedAccount> | undefined => {
+ const accountsUsingApp = activeBuiltInAccounts.filter((account) =>
+ getBuiltInAccountAppsUsingAccount(account).some(
+ (app) => app.id === builtInAccountAppId,
+ ),
+ );
+ const findAccountWithStatus = (status: SyncStatus) =>
+ accountsUsingApp.find(
+ (account) =>
+ computeSyncStatus(
+ account.messageChannels[0],
+ account.calendarChannels[0],
+ ) === status,
+ );
+ const brokenAccount =
+ findAccountWithStatus(SyncStatus.FAILED) ??
+ findAccountWithStatus(SyncStatus.PENDING_CONFIGURATION);
+
+ return isDefined(brokenAccount)
+ ? { type: 'accountSyncIssue', account: brokenAccount }
+ : undefined;
+};
diff --git a/packages/twenty-front/src/modules/settings/app-preferences/utils/getInstalledApplicationStatus.ts b/packages/twenty-front/src/modules/settings/app-preferences/utils/getInstalledApplicationStatus.ts
new file mode 100644
index 00000000000..cda89f449e6
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/app-preferences/utils/getInstalledApplicationStatus.ts
@@ -0,0 +1,44 @@
+import { type AppPreferencesAppStatus } from '@/settings/app-preferences/types/AppPreferencesAppStatus';
+import { type AppPreferencesAppStatusAccount } from '@/settings/app-preferences/types/AppPreferencesAppStatusAccount';
+import { type AppPreferencesAppStatusApplication } from '@/settings/app-preferences/types/AppPreferencesAppStatusApplication';
+import { canStartConnectionProviderAuthorization } from '@/settings/applications/utils/canStartConnectionProviderAuthorization';
+import { isApplicationConnectionReconnectNeeded } from '@/settings/applications/utils/isApplicationConnectionReconnectNeeded';
+import { isNonEmptyArray } from 'twenty-shared/utils';
+
+export const getInstalledApplicationStatus = ({
+ applicationWithPreferences: {
+ application,
+ connectionProviders,
+ missingRequiredVariables,
+ },
+ activeAppAccounts,
+}: {
+ applicationWithPreferences: AppPreferencesAppStatusApplication;
+ activeAppAccounts: AppPreferencesAppStatusAccount[];
+}):
+ | Exclude<AppPreferencesAppStatus, { type: 'accountSyncIssue' }>
+ | undefined => {
+ const activeConnections = activeAppAccounts.filter(
+ (account) => account.applicationId === application.id,
+ );
+
+ if (activeConnections.some(isApplicationConnectionReconnectNeeded)) {
+ return { type: 'reconnectNeeded' };
+ }
+
+ const isAppInUse =
+ !isNonEmptyArray(connectionProviders) || isNonEmptyArray(activeConnections);
+
+ if (isAppInUse && isNonEmptyArray(missingRequiredVariables)) {
+ return { type: 'missingConfiguration' };
+ }
+
+ if (
+ isNonEmptyArray(activeConnections) ||
+ !connectionProviders.some(canStartConnectionProviderAuthorization)
+ ) {
+ return undefined;
+ }
+
+ return { type: 'notConnected' };
+};
diff --git a/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationTableHeaderRow.tsx b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationTableHeaderRow.tsx
new file mode 100644
index 00000000000..2df62886ca0
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationTableHeaderRow.tsx
@@ -0,0 +1,33 @@
+import { type SettingsApplicationTableRowMiddleColumn } from '@/settings/applications/types/SettingsApplicationTableRowMiddleColumn';
+import { getApplicationTableRowGridTemplateColumns } from '@/settings/applications/utils/getApplicationTableRowGridTemplateColumns';
+import { TableHeader } from '@/ui/layout/table/components/TableHeader';
+import { TableRow } from '@/ui/layout/table/components/TableRow';
+import { useLingui } from '@lingui/react/macro';
+import { useIsMobile } from 'twenty-ui/utilities';
+
+type SettingsApplicationTableHeaderRowProps = {
+ middleColumn: SettingsApplicationTableRowMiddleColumn;
+};
+
+export const SettingsApplicationTableHeaderRow = ({
+ middleColumn,
+}: SettingsApplicationTableHeaderRowProps) => {
+ const { t } = useLingui();
+ const isMobile = useIsMobile();
+
+ return (
+ <TableRow
+ gridTemplateColumns={getApplicationTableRowGridTemplateColumns({
+ middleColumn,
+ isMobile,
+ })}
+ >
+ <TableHeader>{t`Name`}</TableHeader>
+ <TableHeader>
+ {middleColumn === 'status' ? t`Status` : t`Type`}
+ </TableHeader>
+ {!isMobile && <TableHeader>{t`Description`}</TableHeader>}
+ <TableHeader />
+ </TableRow>
+ );
+};
diff --git a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationTableRow.tsx b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationTableRow.tsx
similarity index 62%
rename from packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationTableRow.tsx
rename to packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationTableRow.tsx
index c6d2196cfc9..8817685abca 100644
--- a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationTableRow.tsx
+++ b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationTableRow.tsx
@@ -3,6 +3,8 @@ import { type ReactNode } from 'react';
import { ApplicationDisplay } from '@/applications/components/ApplicationDisplay';
import { useResolvedApplicationDescription } from '@/applications/hooks/useResolvedApplicationDescription';
import { type ApplicationDisplayData } from '@/applications/types/ApplicationDisplayData';
+import { SettingsAppPreferencesAppStatusCell } from '@/settings/app-preferences/components/SettingsAppPreferencesAppStatusCell';
+import { type AppPreferencesAppStatus } from '@/settings/app-preferences/types/AppPreferencesAppStatus';
import { StyledNameTableCell } from '@/settings/data-model/object-details/components/SettingsObjectItemTableRowStyledComponents';
import { TableCell } from '@/ui/layout/table/components/TableCell';
import { TableRow } from '@/ui/layout/table/components/TableRow';
@@ -10,9 +12,13 @@ import { msg, t } from '@lingui/core/macro';
import { type MessageDescriptor } from '@lingui/core';
import { OverflowingTextWithTooltip } from 'twenty-ui/primitives/typography';
import { Tag } from 'twenty-ui/primitives/data-display';
+import { isDefined } from 'twenty-shared/utils';
import { themeCssVariables } from 'twenty-ui/theme';
import { ApplicationRegistrationSourceType } from '~/generated-metadata/graphql';
import { getApplicationDescriptionSummary } from '@/settings/applications/utils/getApplicationDescriptionSummary';
+import { getApplicationTableRowGridTemplateColumns } from '@/settings/applications/utils/getApplicationTableRowGridTemplateColumns';
+import { useIsMobile } from 'twenty-ui/utilities';
+import { type SettingsApplicationTableRowMiddleColumn } from '@/settings/applications/types/SettingsApplicationTableRowMiddleColumn';
export type SettingsApplicationTableRowProps = {
action: ReactNode;
@@ -21,12 +27,11 @@ export type SettingsApplicationTableRowProps = {
};
hasUpdate?: boolean;
link?: string;
+ middleColumn?: SettingsApplicationTableRowMiddleColumn;
sourceType?: ApplicationRegistrationSourceType;
+ status?: AppPreferencesAppStatus;
};
-export const APPLICATION_TABLE_ROW_GRID_TEMPLATE_COLUMNS =
- '164px 80px minmax(0, 1fr) 36px';
-
const SOURCE_TYPE_LABELS: Record<
ApplicationRegistrationSourceType,
MessageDescriptor
@@ -37,20 +42,29 @@ const SOURCE_TYPE_LABELS: Record<
[ApplicationRegistrationSourceType.TARBALL]: msg`Tarball`,
};
+const getSourceTypeLabel = (sourceType?: ApplicationRegistrationSourceType) =>
+ isDefined(sourceType) ? t(SOURCE_TYPE_LABELS[sourceType]) : t`Built-in`;
+
export const SettingsApplicationTableRow = ({
action,
application,
hasUpdate,
link,
+ middleColumn = 'type',
sourceType,
+ status,
}: SettingsApplicationTableRowProps) => {
+ const isMobile = useIsMobile();
const resolvedDescription = useResolvedApplicationDescription(application);
const descriptionSummary =
getApplicationDescriptionSummary(resolvedDescription);
return (
<TableRow
- gridTemplateColumns={APPLICATION_TABLE_ROW_GRID_TEMPLATE_COLUMNS}
+ gridTemplateColumns={getApplicationTableRowGridTemplateColumns({
+ middleColumn,
+ isMobile,
+ })}
key={application.id}
to={link}
>
@@ -58,16 +72,22 @@ export const SettingsApplicationTableRow = ({
<ApplicationDisplay application={application} />
</StyledNameTableCell>
<TableCell color={themeCssVariables.font.color.tertiary}>
- {sourceType ? t(SOURCE_TYPE_LABELS[sourceType]) : t`Built-in`}
- </TableCell>
- <TableCell gap={themeCssVariables.spacing[2]} minWidth="0">
- <OverflowingTextWithTooltip text={descriptionSummary} />
- {hasUpdate === true && (
- <Tag color="blue" weight="medium" truncate={false}>
- {t`Update`}
- </Tag>
+ {middleColumn === 'status' ? (
+ <SettingsAppPreferencesAppStatusCell status={status} />
+ ) : (
+ getSourceTypeLabel(sourceType)
)}
</TableCell>
+ {!isMobile && (
+ <TableCell gap={themeCssVariables.spacing[2]} minWidth="0">
+ <OverflowingTextWithTooltip text={descriptionSummary} />
+ {hasUpdate && (
+ <Tag color="blue" weight="medium" truncate={false}>
+ {t`Update`}
+ </Tag>
+ )}
+ </TableCell>
+ )}
<TableCell
align="right"
padding={`0 ${themeCssVariables.spacing[2]} 0 0`}
diff --git a/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationsTable.tsx b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationsTable.tsx
new file mode 100644
index 00000000000..30dafef6345
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationsTable.tsx
@@ -0,0 +1,208 @@
+import { type AppPreferencesAppStatus } from '@/settings/app-preferences/types/AppPreferencesAppStatus';
+import { type BuiltInAccountApp } from '@/settings/app-preferences/types/BuiltInAccountApp';
+import { getBuiltInAccountAppLogoUrl } from '@/settings/app-preferences/utils/getBuiltInAccountAppLogoUrl';
+import { splitApplicationsAroundBuiltInAccountApps } from '@/settings/applications/utils/splitApplicationsAroundBuiltInAccountApps';
+import { SettingsEmptyPlaceholder } from '@/settings/components/SettingsEmptyPlaceholder';
+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 { type ReactNode, useState } from 'react';
+import { SettingsPath } from 'twenty-shared/types';
+import { getSettingsPath, isNonEmptyArray } from 'twenty-shared/utils';
+import { SearchInput } from 'twenty-ui/components/input';
+import { Section } from 'twenty-ui/components/layout';
+import { IconChevronRight } from 'twenty-ui/icon';
+import { useTheme, themeCssVariables } from 'twenty-ui/theme';
+import { ApplicationRegistrationSourceType } from '~/generated-metadata/graphql';
+import { SettingsApplicationTableHeaderRow } from '@/settings/applications/components/SettingsApplicationTableHeaderRow';
+import { SettingsApplicationTableRow } from '@/settings/applications/components/SettingsApplicationTableRow';
+import { type SettingsApplicationTableRowMiddleColumn } from '@/settings/applications/types/SettingsApplicationTableRowMiddleColumn';
+import { type ApplicationWithoutRelation } from '@/applications/types/ApplicationWithoutRelation';
+import { hasApplicationUpdate } from '@/settings/applications/utils/hasApplicationUpdate';
+import { filterBySearchQuery } from '~/utils/filterBySearchQuery';
+
+const StyledTableRowsContainer = styled.div`
+ border-bottom: 1px solid ${themeCssVariables.border.color.light};
+ padding: ${themeCssVariables.spacing[2]} 0;
+`;
+
+const StyledSearchInputContainer = styled.div`
+ padding-bottom: ${themeCssVariables.spacing[2]};
+ width: 100%;
+`;
+
+type SettingsApplicationsTableApplication = Pick<
+ ApplicationWithoutRelation,
+ | 'id'
+ | 'name'
+ | 'description'
+ | 'logoUrl'
+ | 'universalIdentifier'
+ | 'version'
+ | 'applicationRegistration'
+>;
+
+type SettingsApplicationsTableProps = {
+ title: string;
+ description: string;
+ applications: SettingsApplicationsTableApplication[];
+ builtInAccountApps: BuiltInAccountApp[];
+ variant: 'workspace' | 'member';
+ statusById?: Record<string, AppPreferencesAppStatus>;
+ isLoading?: boolean;
+ toolbar?: ReactNode;
+};
+
+export const SettingsApplicationsTable = ({
+ title,
+ description,
+ applications,
+ builtInAccountApps,
+ variant,
+ statusById,
+ isLoading = false,
+ toolbar,
+}: SettingsApplicationsTableProps) => {
+ const theme = useTheme();
+ const { t } = useLingui();
+
+ const [searchTerm, setSearchTerm] = useState('');
+
+ const filteredApplications = filterBySearchQuery({
+ items: applications,
+ searchQuery: searchTerm.trim(),
+ getSearchableValues: (application) => [
+ application.name,
+ application.description ?? '',
+ ],
+ }).sort((firstApplication, secondApplication) => {
+ const isFirstApplicationOAuthOnly =
+ firstApplication.applicationRegistration?.sourceType ===
+ ApplicationRegistrationSourceType.OAUTH_ONLY;
+ const isSecondApplicationOAuthOnly =
+ secondApplication.applicationRegistration?.sourceType ===
+ ApplicationRegistrationSourceType.OAUTH_ONLY;
+
+ if (isFirstApplicationOAuthOnly === isSecondApplicationOAuthOnly) {
+ return 0;
+ }
+
+ return isFirstApplicationOAuthOnly ? 1 : -1;
+ });
+
+ const filteredBuiltInAccountApps = filterBySearchQuery({
+ items: builtInAccountApps,
+ searchQuery: searchTerm.trim(),
+ getSearchableValues: (builtInAccountApp) => [
+ t(builtInAccountApp.name),
+ t(builtInAccountApp.description),
+ ],
+ });
+
+ const {
+ applicationsBeforeBuiltInAccountApps,
+ applicationsAfterBuiltInAccountApps,
+ } = splitApplicationsAroundBuiltInAccountApps({
+ applications: filteredApplications,
+ hasBuiltInAccountApps: isNonEmptyArray(builtInAccountApps),
+ });
+
+ const chevronIcon = (
+ <IconChevronRight
+ size={theme.icon.size.md}
+ stroke={theme.icon.stroke.sm}
+ color={theme.font.color.light}
+ />
+ );
+
+ const hasApplications =
+ isNonEmptyArray(applications) || isNonEmptyArray(builtInAccountApps);
+
+ const middleColumn: SettingsApplicationTableRowMiddleColumn =
+ variant === 'member' ? 'status' : 'type';
+
+ const getApplicationLink = (applicationId: string) =>
+ variant === 'member'
+ ? getSettingsPath(SettingsPath.ApplicationPreferences, { applicationId })
+ : getSettingsPath(SettingsPath.ApplicationDetail, { applicationId });
+
+ const getBuiltInAccountAppLink = (
+ builtInAccountAppId: BuiltInAccountApp['id'],
+ ) =>
+ variant === 'member'
+ ? getSettingsPath(SettingsPath.BuiltInAccountApp, { builtInAccountAppId })
+ : getSettingsPath(SettingsPath.ApplicationDetail, {
+ applicationId: builtInAccountAppId,
+ });
+
+ const renderApplicationRow = (
+ application: SettingsApplicationsTableApplication,
+ ) => {
+ const hasUpdate = hasApplicationUpdate({
+ sourceType: application.applicationRegistration?.sourceType,
+ currentVersion: application.version,
+ latestAvailableVersion:
+ application.applicationRegistration?.latestAvailableVersion,
+ });
+
+ return (
+ <SettingsApplicationTableRow
+ key={application.id}
+ application={application}
+ hasUpdate={hasUpdate}
+ sourceType={application.applicationRegistration?.sourceType}
+ middleColumn={middleColumn}
+ status={statusById?.[application.id]}
+ action={chevronIcon}
+ link={getApplicationLink(application.id)}
+ />
+ );
+ };
+
+ return (
+ <Section.Root>
+ <Section.Header title={title} description={description} />
+ {toolbar}
+ {isLoading && <SettingsSectionSkeletonLoader />}
+ {!isLoading && hasApplications && (
+ <>
+ <StyledSearchInputContainer>
+ <SearchInput
+ placeholder={t`Search an application`}
+ value={searchTerm}
+ onValueChange={setSearchTerm}
+ />
+ </StyledSearchInputContainer>
+ <Table>
+ <SettingsApplicationTableHeaderRow middleColumn={middleColumn} />
+ <StyledTableRowsContainer>
+ {filteredApplications.length === 0 &&
+ filteredBuiltInAccountApps.length === 0 && (
+ <SettingsEmptyPlaceholder padding="4">
+ <span role="status">{t`No application matches your search`}</span>
+ </SettingsEmptyPlaceholder>
+ )}
+ {applicationsBeforeBuiltInAccountApps.map(renderApplicationRow)}
+ {filteredBuiltInAccountApps.map((builtInAccountApp) => (
+ <SettingsApplicationTableRow
+ key={builtInAccountApp.id}
+ application={{
+ name: t(builtInAccountApp.name),
+ description: t(builtInAccountApp.description),
+ logoUrl: getBuiltInAccountAppLogoUrl(builtInAccountApp),
+ }}
+ middleColumn={middleColumn}
+ status={statusById?.[builtInAccountApp.id]}
+ action={chevronIcon}
+ link={getBuiltInAccountAppLink(builtInAccountApp.id)}
+ />
+ ))}
+ {applicationsAfterBuiltInAccountApps.map(renderApplicationRow)}
+ </StyledTableRowsContainer>
+ </Table>
+ </>
+ )}
+ </Section.Root>
+ );
+};
diff --git a/packages/twenty-front/src/pages/settings/applications/components/__stories__/SettingsApplicationsTable.stories.tsx b/packages/twenty-front/src/modules/settings/applications/components/__stories__/SettingsApplicationsTable.stories.tsx
similarity index 79%
rename from packages/twenty-front/src/pages/settings/applications/components/__stories__/SettingsApplicationsTable.stories.tsx
rename to packages/twenty-front/src/modules/settings/applications/components/__stories__/SettingsApplicationsTable.stories.tsx
index 354f57b746b..799a39961ea 100644
--- a/packages/twenty-front/src/pages/settings/applications/components/__stories__/SettingsApplicationsTable.stories.tsx
+++ b/packages/twenty-front/src/modules/settings/applications/components/__stories__/SettingsApplicationsTable.stories.tsx
@@ -5,7 +5,7 @@ import { TWENTY_STANDARD_APPLICATION_UNIVERSAL_IDENTIFIER } from 'twenty-shared/
import { type ApplicationWithoutRelation } from '@/applications/types/ApplicationWithoutRelation';
import { BUILT_IN_ACCOUNT_APPS } from '@/settings/app-preferences/constants/BuiltInAccountApps';
import { ApplicationRegistrationSourceType } from '~/generated-metadata/graphql';
-import { SettingsApplicationsTable } from '~/pages/settings/applications/components/SettingsApplicationsTable';
+import { SettingsApplicationsTable } from '@/settings/applications/components/SettingsApplicationsTable';
import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator';
const STANDARD_APPLICATION: ApplicationWithoutRelation = {
@@ -41,12 +41,15 @@ const getRowLinks = (canvasElement: HTMLElement) =>
.map((link) => link.getAttribute('href'));
const meta: Meta<typeof SettingsApplicationsTable> = {
- title: 'Pages/Settings/Applications/SettingsApplicationsTable',
+ title: 'Modules/Settings/Applications/SettingsApplicationsTable',
component: SettingsApplicationsTable,
decorators: [ComponentWithRouterDecorator],
args: {
+ title: 'Installed apps',
+ description: 'All the applications currently installed on this workspace',
applications: [OAUTH_APPLICATION, NPM_APPLICATION, STANDARD_APPLICATION],
builtInAccountApps: BUILT_IN_ACCOUNT_APPS,
+ variant: 'workspace',
},
};
@@ -114,3 +117,22 @@ export const KeepsExistingOrderWithoutBuiltInAccountApps: Story = {
]);
},
};
+
+export const HidesTheDescriptionOnMobile: Story = {
+ parameters: {
+ viewport: { defaultViewport: 'mobile1' },
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ expect(await canvas.findByText('Acme Sync')).toBeVisible();
+ expect(canvas.getByText('Name')).toBeVisible();
+ expect(canvas.queryByText('Description')).not.toBeInTheDocument();
+
+ const acmeRow = canvas.getByRole('link', { name: /Acme Sync/ });
+
+ expect(acmeRow).toHaveTextContent('NPM');
+ expect(acmeRow).not.toHaveTextContent('Keeps Acme in sync');
+ expect(acmeRow.scrollWidth).toBeLessThanOrEqual(acmeRow.clientWidth);
+ },
+};
diff --git a/packages/twenty-front/src/modules/settings/applications/constants/ApplicationTableRowGridTemplateColumnsByMiddleColumn.ts b/packages/twenty-front/src/modules/settings/applications/constants/ApplicationTableRowGridTemplateColumnsByMiddleColumn.ts
new file mode 100644
index 00000000000..789379e063b
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/applications/constants/ApplicationTableRowGridTemplateColumnsByMiddleColumn.ts
@@ -0,0 +1,9 @@
+import { type SettingsApplicationTableRowMiddleColumn } from '@/settings/applications/types/SettingsApplicationTableRowMiddleColumn';
+
+export const APPLICATION_TABLE_ROW_GRID_TEMPLATE_COLUMNS_BY_MIDDLE_COLUMN: Record<
+ SettingsApplicationTableRowMiddleColumn,
+ string
+> = {
+ type: '200px 80px minmax(0, 1fr) 36px',
+ status: '200px 180px minmax(0, 1fr) 36px',
+};
diff --git a/packages/twenty-front/src/modules/settings/applications/constants/ApplicationTableRowMobileGridTemplateColumns.ts b/packages/twenty-front/src/modules/settings/applications/constants/ApplicationTableRowMobileGridTemplateColumns.ts
new file mode 100644
index 00000000000..6fd5a4ec7a3
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/applications/constants/ApplicationTableRowMobileGridTemplateColumns.ts
@@ -0,0 +1,2 @@
+export const APPLICATION_TABLE_ROW_MOBILE_GRID_TEMPLATE_COLUMNS =
+ 'minmax(0, 1fr) auto 36px';
diff --git a/packages/twenty-front/src/modules/settings/applications/types/SettingsApplicationTableRowMiddleColumn.ts b/packages/twenty-front/src/modules/settings/applications/types/SettingsApplicationTableRowMiddleColumn.ts
new file mode 100644
index 00000000000..9750c8835d9
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/applications/types/SettingsApplicationTableRowMiddleColumn.ts
@@ -0,0 +1 @@
+export type SettingsApplicationTableRowMiddleColumn = 'type' | 'status';
diff --git a/packages/twenty-front/src/pages/settings/applications/utils/__tests__/hasApplicationUpdate.test.ts b/packages/twenty-front/src/modules/settings/applications/utils/__tests__/hasApplicationUpdate.test.ts
similarity index 94%
rename from packages/twenty-front/src/pages/settings/applications/utils/__tests__/hasApplicationUpdate.test.ts
rename to packages/twenty-front/src/modules/settings/applications/utils/__tests__/hasApplicationUpdate.test.ts
index f0a1cca9c68..4b5d9d18996 100644
--- a/packages/twenty-front/src/pages/settings/applications/utils/__tests__/hasApplicationUpdate.test.ts
+++ b/packages/twenty-front/src/modules/settings/applications/utils/__tests__/hasApplicationUpdate.test.ts
@@ -1,5 +1,5 @@
import { ApplicationRegistrationSourceType } from '~/generated-metadata/graphql';
-import { hasApplicationUpdate } from '~/pages/settings/applications/utils/hasApplicationUpdate';
+import { hasApplicationUpdate } from '@/settings/applications/utils/hasApplicationUpdate';
describe('hasApplicationUpdate', () => {
it.each([
diff --git a/packages/twenty-front/src/pages/settings/applications/utils/__tests__/isNewerSemver.test.ts b/packages/twenty-front/src/modules/settings/applications/utils/__tests__/isNewerSemver.test.ts
similarity index 96%
rename from packages/twenty-front/src/pages/settings/applications/utils/__tests__/isNewerSemver.test.ts
rename to packages/twenty-front/src/modules/settings/applications/utils/__tests__/isNewerSemver.test.ts
index a40016d171d..a98ee8d068a 100644
--- a/packages/twenty-front/src/pages/settings/applications/utils/__tests__/isNewerSemver.test.ts
+++ b/packages/twenty-front/src/modules/settings/applications/utils/__tests__/isNewerSemver.test.ts
@@ -1,4 +1,4 @@
-import { isNewerSemver } from '~/pages/settings/applications/utils/isNewerSemver';
+import { isNewerSemver } from '@/settings/applications/utils/isNewerSemver';
const isNumberedBetaNewer = () =>
isNewerSemver('1.0.0-beta.11', '1.0.0-beta.2');
diff --git a/packages/twenty-front/src/modules/settings/applications/utils/getApplicationTableRowGridTemplateColumns.ts b/packages/twenty-front/src/modules/settings/applications/utils/getApplicationTableRowGridTemplateColumns.ts
new file mode 100644
index 00000000000..87946cef1bb
--- /dev/null
+++ b/packages/twenty-front/src/modules/settings/applications/utils/getApplicationTableRowGridTemplateColumns.ts
@@ -0,0 +1,16 @@
+import { APPLICATION_TABLE_ROW_GRID_TEMPLATE_COLUMNS_BY_MIDDLE_COLUMN } from '@/settings/applications/constants/ApplicationTableRowGridTemplateColumnsByMiddleColumn';
+import { APPLICATION_TABLE_ROW_MOBILE_GRID_TEMPLATE_COLUMNS } from '@/settings/applications/constants/ApplicationTableRowMobileGridTemplateColumns';
+import { type SettingsApplicationTableRowMiddleColumn } from '@/settings/applications/types/SettingsApplicationTableRowMiddleColumn';
+
+export const getApplicationTableRowGridTemplateColumns = ({
+ middleColumn,
+ isMobile,
+}: {
+ middleColumn: SettingsApplicationTableRowMiddleColumn;
+ isMobile: boolean;
+}) =>
+ isMobile
+ ? APPLICATION_TABLE_ROW_MOBILE_GRID_TEMPLATE_COLUMNS
+ : APPLICATION_TABLE_ROW_GRID_TEMPLATE_COLUMNS_BY_MIDDLE_COLUMN[
+ middleColumn
+ ];
diff --git a/packages/twenty-front/src/pages/settings/applications/utils/hasApplicationUpdate.ts b/packages/twenty-front/src/modules/settings/applications/utils/hasApplicationUpdate.ts
similarity index 74%
rename from packages/twenty-front/src/pages/settings/applications/utils/hasApplicationUpdate.ts
rename to packages/twenty-front/src/modules/settings/applications/utils/hasApplicationUpdate.ts
index 0cade6b1181..f48ed812f27 100644
--- a/packages/twenty-front/src/pages/settings/applications/utils/hasApplicationUpdate.ts
+++ b/packages/twenty-front/src/modules/settings/applications/utils/hasApplicationUpdate.ts
@@ -1,7 +1,7 @@
import { isDefined } from 'twenty-shared/utils';
import { type ApplicationRegistrationSourceType } from '~/generated-metadata/graphql';
-import { isNewerSemver } from '~/pages/settings/applications/utils/isNewerSemver';
-import { isUpgradableApplicationSourceType } from '~/pages/settings/applications/utils/isUpgradableApplicationSourceType';
+import { isNewerSemver } from '@/settings/applications/utils/isNewerSemver';
+import { isUpgradableApplicationSourceType } from '@/settings/applications/utils/isUpgradableApplicationSourceType';
export const hasApplicationUpdate = ({
sourceType,
diff --git a/packages/twenty-front/src/pages/settings/applications/utils/isNewerSemver.ts b/packages/twenty-front/src/modules/settings/applications/utils/isNewerSemver.ts
similarity index 100%
rename from packages/twenty-front/src/pages/settings/applications/utils/isNewerSemver.ts
rename to packages/twenty-front/src/modules/settings/applications/utils/isNewerSemver.ts
diff --git a/packages/twenty-front/src/pages/settings/applications/utils/isUpgradableApplicationSourceType.ts b/packages/twenty-front/src/modules/settings/applications/utils/isUpgradableApplicationSourceType.ts
similarity index 100%
rename from packages/twenty-front/src/pages/settings/applications/utils/isUpgradableApplicationSourceType.ts
rename to packages/twenty-front/src/modules/settings/applications/utils/isUpgradableApplicationSourceType.ts
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 4af0f402f58..4a451435d8b 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
@@ -34,7 +34,10 @@ import {
import {
APPLICATION_PREFERENCES_DETAIL_GRAPHQL_HANDLERS,
APPLICATION_PREFERENCES_GRAPHQL_HANDLERS,
+ CONNECTED_GRANOLA_GRAPHQL_HANDLERS,
failNextApplicationPreferencesRequest,
+ failNextConnectedAccountsRequest,
+ findApplicationsGatedQuery,
seedApplicationPreferencesStory,
} from '~/pages/settings/accounts/__stories__/mockedApplicationPreferences';
import {
@@ -334,11 +337,11 @@ export const AppPreferencesListEnabledApps: Story = {
await userEvent.click(getTab({ canvasElement, tabId: 'apps' }));
expect(
- await canvas.findByRole('link', { name: 'Gmail and Calendar' }),
+ await canvas.findByRole('link', { name: /Gmail and Calendar/ }),
).toBeVisible();
expect(canvas.queryByText('IMAP')).not.toBeInTheDocument();
- await userEvent.click(canvas.getByRole('link', { name: 'Outlook' }));
+ await userEvent.click(canvas.getByRole('link', { name: /Outlook/ }));
expect(
await canvas.findByText('Navigated to /settings/accounts/apps/outlook'),
@@ -586,7 +589,7 @@ export const AppsFlagOnlyBrokenAccounts: Story = {
getStatusCell({ canvasElement, text: 'Outlook' }),
).toBeEmptyDOMElement();
expect(
- getStatusCell({ canvasElement, text: 'Linear' }),
+ getStatusCell({ canvasElement, text: 'Granola' }),
).toBeEmptyDOMElement();
},
};
@@ -613,6 +616,9 @@ export const AppPreferencesListInstalledApps: Story = {
);
expect(canvas.getByText('Granola')).toBeVisible();
expect(canvas.getByText('Linear')).toBeVisible();
+ expect(
+ canvas.getByText('Records, transcribes and summarizes your meetings.'),
+ ).toBeVisible();
expect(canvas.queryByText('Blocklist')).not.toBeInTheDocument();
const outlookRow = canvas
@@ -646,6 +652,7 @@ export const AppPreferencesListInstalledApps: Story = {
'Navigated to /settings/accounts/applications/:applicationId',
),
).toBeVisible();
+ expect(findApplicationsGatedQuery).not.toHaveBeenCalled();
},
};
@@ -674,6 +681,31 @@ export const InstalledAppsFlagReconnectAndMissingConfiguration: Story = {
},
};
+export const InstalledAppWithoutMyConnectionShowsNotConnectedHint: Story = {
+ ...accountGroupsStory,
+ beforeEach: seedApplicationPreferencesStory,
+ parameters: {
+ msw: { handlers: CONNECTED_GRANOLA_GRAPHQL_HANDLERS },
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await canvas.findByText('Linear', undefined, { timeout: 3000 });
+
+ expect(
+ await getTableRow(canvasElement, 'Linear').findByText('Not connected'),
+ ).toBeVisible();
+
+ const fathomRow = getTableRow(canvasElement, 'Fathom');
+
+ expect(fathomRow.getByText('Missing configuration')).toBeVisible();
+ expect(fathomRow.queryByText('Not connected')).not.toBeInTheDocument();
+ expect(
+ getStatusCell({ canvasElement, text: 'Granola' }),
+ ).toBeEmptyDOMElement();
+ },
+};
+
export const AppPreferencesListLoadErrorOffersRetry: Story = {
...accountGroupsStory,
beforeEach: async () => {
@@ -694,7 +726,7 @@ export const AppPreferencesListLoadErrorOffersRetry: Story = {
),
).toBeVisible();
expect(
- canvas.getByRole('link', { name: 'Gmail and Calendar' }),
+ canvas.getByRole('link', { name: /Gmail and Calendar/ }),
).toBeVisible();
expect(canvas.queryByText('Fathom')).not.toBeInTheDocument();
@@ -711,6 +743,46 @@ export const AppPreferencesListLoadErrorOffersRetry: Story = {
},
};
+export const ConnectionsLoadErrorHidesStatusesUntilRetry: Story = {
+ ...accountGroupsStory,
+ beforeEach: async () => {
+ await seedApplicationPreferencesStory();
+ failNextConnectedAccountsRequest();
+ },
+ parameters: {
+ msw: { handlers: CONNECTED_GRANOLA_GRAPHQL_HANDLERS },
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ expect(
+ await canvas.findByText(
+ 'Your connections could not be loaded. Check your connection and try again.',
+ undefined,
+ { timeout: 3000 },
+ ),
+ ).toBeVisible();
+ expect(canvas.getByText('Linear')).toBeVisible();
+ expect(canvas.queryByText('Not connected')).not.toBeInTheDocument();
+ expect(canvas.queryByText('Missing configuration')).not.toBeInTheDocument();
+
+ await userEvent.click(canvas.getByRole('button', { name: 'Retry' }));
+
+ expect(
+ await getTableRow(canvasElement, 'Linear').findByText(
+ 'Not connected',
+ undefined,
+ { timeout: 3000 },
+ ),
+ ).toBeVisible();
+ expect(
+ canvas.queryByText(
+ 'Your connections could not be loaded. Check your connection and try again.',
+ ),
+ ).not.toBeInTheDocument();
+ },
+};
+
export const BlocklistFallsBackToAccountsTabWithoutBuiltInAccountApp: Story = {
...accountsTabStory,
beforeEach: async () => {
@@ -748,7 +820,7 @@ export const BlocklistFallsBackToAccountsTabWithoutBuiltInAccountApp: Story = {
expect(await canvas.findByText('Fathom')).toBeVisible();
expect(
- canvas.queryByRole('link', { name: 'Gmail and Calendar' }),
+ 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__/mockedAccountGroups.ts b/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedAccountGroups.ts
index 8de6b169a86..71d02cbf537 100644
--- a/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedAccountGroups.ts
+++ b/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedAccountGroups.ts
@@ -328,6 +328,7 @@ export const seedAccountGroupsStory = async () => {
id: GRANOLA_APPLICATION_ID,
universalIdentifier: GRANOLA_APPLICATION_ID,
name: 'Granola',
+ description: 'Takes notes during your calls.',
logoUrl: null,
createdAt: '2024-01-01T00:00:00.000Z',
},
diff --git a/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedApplicationPreferences.ts b/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedApplicationPreferences.ts
index 4c23b0af402..f3c21b0c65c 100644
--- a/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedApplicationPreferences.ts
+++ b/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedApplicationPreferences.ts
@@ -8,8 +8,11 @@ import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
import { jotaiStore } from '@/ui/utilities/state/jotai/jotaiStore';
import {
ACCOUNT_GROUPS_GRAPHQL_HANDLERS,
+ CONNECTED_ACCOUNTS,
FATHOM_APPLICATION_ID,
GRANOLA_APPLICATION_ID,
+ MY_USER_WORKSPACE_ID,
+ buildConnectedAccount,
myApplicationPreferencesRequested,
seedAccountGroupsStory,
} from '~/pages/settings/accounts/__stories__/mockedAccountGroups';
@@ -98,6 +101,23 @@ const FATHOM_CONNECTION_PROVIDER = {
},
};
+const GRANOLA_CONNECTION_PROVIDER = {
+ ...FATHOM_CONNECTION_PROVIDER,
+ id: '20202020-1a2b-4c3d-8e4f-000000000073',
+ applicationId: GRANOLA_APPLICATION_ID,
+ name: 'granola',
+ displayName: 'Granola',
+};
+
+const GRANOLA_PERSONAL_ACCOUNT = buildConnectedAccount({
+ id: '20202020-1a2b-4c3d-8e4f-000000000019',
+ handle: '[email protected]',
+ provider: 'app',
+ userWorkspaceId: MY_USER_WORKSPACE_ID,
+ applicationId: GRANOLA_APPLICATION_ID,
+ connectionProviderId: GRANOLA_CONNECTION_PROVIDER.id,
+});
+
const SAVED_PERSONAL_API_KEY = 'sk-1abcdefghijklmnopqrstuvwxyz0123456789';
// Same masking as the server's SecretEncryptionService.maskDecryptedValue.
@@ -280,6 +300,41 @@ export const APPLICATION_PREFERENCES_GRAPHQL_HANDLERS = [
...ACCOUNT_GROUPS_GRAPHQL_HANDLERS,
];
+const withGranolaConnectionProvider = (
+ applicationPreferences: ReturnType<
+ typeof buildApplicationPreferences
+ >[number],
+) => {
+ if (applicationPreferences.applicationId !== GRANOLA_APPLICATION_ID) {
+ return applicationPreferences;
+ }
+
+ return {
+ ...applicationPreferences,
+ connectionProviders: [GRANOLA_CONNECTION_PROVIDER],
+ };
+};
+
+export const CONNECTED_GRANOLA_GRAPHQL_HANDLERS = [
+ graphql.query('MyApplicationPreferences', () =>
+ HttpResponse.json({
+ data: {
+ myApplicationPreferences: buildApplicationPreferences().map(
+ withGranolaConnectionProvider,
+ ),
+ },
+ }),
+ ),
+ graphql.query('MyConnectedAccounts', () =>
+ HttpResponse.json({
+ data: {
+ myConnectedAccounts: [...CONNECTED_ACCOUNTS, GRANOLA_PERSONAL_ACCOUNT],
+ },
+ }),
+ ),
+ ...APPLICATION_PREFERENCES_GRAPHQL_HANDLERS,
+];
+
export const APPLICATION_PREFERENCES_DETAIL_GRAPHQL_HANDLERS = [
LINEAR_CONNECTED_ACCOUNTS_GRAPHQL_HANDLER,
...APPLICATION_PREFERENCES_GRAPHQL_HANDLERS,
diff --git a/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedLinearApplicationPreferences.ts b/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedLinearApplicationPreferences.ts
index e5b20d7142b..2f5de8d0536 100644
--- a/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedLinearApplicationPreferences.ts
+++ b/packages/twenty-front/src/pages/settings/accounts/__stories__/mockedLinearApplicationPreferences.ts
@@ -28,6 +28,7 @@ export const LINEAR_INSTALLED_APPLICATION = {
id: LINEAR_APPLICATION_ID,
universalIdentifier: LINEAR_APPLICATION_ID,
name: 'Linear',
+ description: 'Syncs issues and projects with your workspace.',
logoUrl: null,
createdAt: '2024-01-01T00:00:00.000Z',
};
diff --git a/packages/twenty-front/src/pages/settings/applications/SettingsApplicationDetails.tsx b/packages/twenty-front/src/pages/settings/applications/SettingsApplicationDetails.tsx
index f90cd133230..0a36c81067b 100644
--- a/packages/twenty-front/src/pages/settings/applications/SettingsApplicationDetails.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/SettingsApplicationDetails.tsx
@@ -65,7 +65,7 @@ import { SettingsApplicationDetailVariablesTab } from '@/settings/applications/c
import { getApplicationDescriptionSummary } from '@/settings/applications/utils/getApplicationDescriptionSummary';
import { getApplicationHealthBanner } from '~/pages/settings/applications/utils/getApplicationHealthBanner';
import { getApplicationLookupStatus } from '~/pages/settings/applications/utils/getApplicationLookupStatus';
-import { hasApplicationUpdate } from '~/pages/settings/applications/utils/hasApplicationUpdate';
+import { hasApplicationUpdate } from '@/settings/applications/utils/hasApplicationUpdate';
import { isUuidFormat } from '~/pages/settings/applications/utils/isUuidFormat';
import { getMissingRequiredApplicationVariables } from '@/settings/applications/utils/getMissingRequiredApplicationVariables';
import { getSettingsMenuItemDisplayTitle } from '~/pages/settings/applications/utils/getSettingsMenuItemDisplayTitle';
diff --git a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationsTable.tsx b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationsTable.tsx
deleted file mode 100644
index 5e779eb75e3..00000000000
--- a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationsTable.tsx
+++ /dev/null
@@ -1,169 +0,0 @@
-import { type BuiltInAccountApp } from '@/settings/app-preferences/types/BuiltInAccountApp';
-import { getBuiltInAccountAppLogoUrl } from '@/settings/app-preferences/utils/getBuiltInAccountAppLogoUrl';
-import { splitApplicationsAroundBuiltInAccountApps } from '@/settings/applications/utils/splitApplicationsAroundBuiltInAccountApps';
-import { SettingsEmptyPlaceholder } from '@/settings/components/SettingsEmptyPlaceholder';
-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 { useState } from 'react';
-import { SettingsPath } from 'twenty-shared/types';
-import { getSettingsPath, isNonEmptyArray } from 'twenty-shared/utils';
-import { SearchInput } from 'twenty-ui/components/input';
-import { Section } from 'twenty-ui/components/layout';
-import { IconChevronRight } from 'twenty-ui/icon';
-import { useTheme, themeCssVariables } from 'twenty-ui/theme';
-import { ApplicationRegistrationSourceType } from '~/generated-metadata/graphql';
-import {
- APPLICATION_TABLE_ROW_GRID_TEMPLATE_COLUMNS,
- SettingsApplicationTableRow,
-} from '~/pages/settings/applications/components/SettingsApplicationTableRow';
-import { type ApplicationWithoutRelation } from '@/applications/types/ApplicationWithoutRelation';
-import { hasApplicationUpdate } from '~/pages/settings/applications/utils/hasApplicationUpdate';
-import { filterBySearchQuery } from '~/utils/filterBySearchQuery';
-
-const StyledTableRowsContainer = styled.div`
- border-bottom: 1px solid ${themeCssVariables.border.color.light};
- padding: ${themeCssVariables.spacing[2]} 0;
-`;
-
-const StyledSearchInputContainer = styled.div`
- padding-bottom: ${themeCssVariables.spacing[2]};
- width: 100%;
-`;
-
-type SettingsApplicationsTableProps = {
- applications: ApplicationWithoutRelation[];
- builtInAccountApps: BuiltInAccountApp[];
-};
-
-export const SettingsApplicationsTable = ({
- applications,
- builtInAccountApps,
-}: SettingsApplicationsTableProps) => {
- const theme = useTheme();
- const { t } = useLingui();
-
- const [searchTerm, setSearchTerm] = useState('');
-
- const normalizedSearchTerm = searchTerm.trim().toLowerCase();
-
- const filteredApplications = applications
- .filter(
- (application) =>
- application.name.toLowerCase().includes(normalizedSearchTerm) ||
- (application.description ?? '')
- .toLowerCase()
- .includes(normalizedSearchTerm),
- )
- .sort((a, b) => {
- const aIsOAuth =
- a.applicationRegistration?.sourceType ===
- ApplicationRegistrationSourceType.OAUTH_ONLY;
- const bIsOAuth =
- b.applicationRegistration?.sourceType ===
- ApplicationRegistrationSourceType.OAUTH_ONLY;
-
- if (aIsOAuth === bIsOAuth) return 0;
-
- return aIsOAuth ? 1 : -1;
- });
-
- const filteredBuiltInAccountApps = filterBySearchQuery({
- items: builtInAccountApps,
- searchQuery: searchTerm.trim(),
- getSearchableValues: (builtInAccountApp) => [
- t(builtInAccountApp.name),
- t(builtInAccountApp.description),
- ],
- });
-
- const {
- applicationsBeforeBuiltInAccountApps,
- applicationsAfterBuiltInAccountApps,
- } = splitApplicationsAroundBuiltInAccountApps({
- applications: filteredApplications,
- hasBuiltInAccountApps: isNonEmptyArray(builtInAccountApps),
- });
-
- const chevronIcon = (
- <IconChevronRight
- size={theme.icon.size.md}
- stroke={theme.icon.stroke.sm}
- color={theme.font.color.light}
- />
- );
-
- const renderApplicationRow = (application: ApplicationWithoutRelation) => {
- const hasUpdate = hasApplicationUpdate({
- sourceType: application.applicationRegistration?.sourceType,
- currentVersion: application.version,
- latestAvailableVersion:
- application.applicationRegistration?.latestAvailableVersion,
- });
-
- return (
- <SettingsApplicationTableRow
- key={application.id}
- application={application}
- hasUpdate={hasUpdate}
- sourceType={application.applicationRegistration?.sourceType}
- action={chevronIcon}
- link={getSettingsPath(SettingsPath.ApplicationDetail, {
- applicationId: application.id,
- })}
- />
- );
- };
-
- return (
- <Section.Root>
- <Section.Header
- title={t`Installed apps`}
- description={t`All the applications currently installed on this workspace`}
- />
- <StyledSearchInputContainer>
- <SearchInput
- placeholder={t`Search an application`}
- value={searchTerm}
- onValueChange={setSearchTerm}
- />
- </StyledSearchInputContainer>
- <Table>
- <TableRow
- gridTemplateColumns={APPLICATION_TABLE_ROW_GRID_TEMPLATE_COLUMNS}
- >
- <TableHeader>{t`Name`}</TableHeader>
- <TableHeader>{t`Type`}</TableHeader>
- <TableHeader>{t`Description`}</TableHeader>
- <TableHeader />
- </TableRow>
- <StyledTableRowsContainer>
- {filteredApplications.length === 0 &&
- filteredBuiltInAccountApps.length === 0 && (
- <SettingsEmptyPlaceholder padding="4">
- <span role="status">{t`No application matches your search`}</span>
- </SettingsEmptyPlaceholder>
- )}
- {applicationsBeforeBuiltInAccountApps.map(renderApplicationRow)}
- {filteredBuiltInAccountApps.map((builtInAccountApp) => (
- <SettingsApplicationTableRow
- key={builtInAccountApp.id}
- application={{
- name: t(builtInAccountApp.name),
- description: t(builtInAccountApp.description),
- logoUrl: getBuiltInAccountAppLogoUrl(builtInAccountApp),
- }}
- action={chevronIcon}
- link={getSettingsPath(SettingsPath.ApplicationDetail, {
- applicationId: builtInAccountApp.id,
- })}
- />
- ))}
- {applicationsAfterBuiltInAccountApps.map(renderApplicationRow)}
- </StyledTableRowsContainer>
- </Table>
- </Section.Root>
- );
-};
diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationDetailGeneralTab.tsx b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationDetailGeneralTab.tsx
index c22c0c95783..ebaf28ffd0b 100644
--- a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationDetailGeneralTab.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationDetailGeneralTab.tsx
@@ -18,7 +18,7 @@ import { SettingsApplicationAutoUpdateSection } from '~/pages/settings/applicati
import { SettingsApplicationConnectionsSection } from '~/pages/settings/applications/tabs/SettingsApplicationConnectionsSection';
import { SettingsApplicationFunctionDomainSection } from '~/pages/settings/applications/tabs/SettingsApplicationFunctionDomainSection';
import { applicationHasHttpTriggeredFunctions } from '~/pages/settings/applications/utils/applicationHasHttpTriggeredFunctions';
-import { isUpgradableApplicationSourceType } from '~/pages/settings/applications/utils/isUpgradableApplicationSourceType';
+import { isUpgradableApplicationSourceType } from '@/settings/applications/utils/isUpgradableApplicationSourceType';
type SettingsApplicationDetailGeneralTabProps = {
application: Pick<
diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsInstalledTab.tsx b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsInstalledTab.tsx
index 4823656866a..e9ae86b1189 100644
--- a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsInstalledTab.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsInstalledTab.tsx
@@ -1,8 +1,10 @@
import { useInstalledApplications } from '@/applications/hooks/useInstalledApplications';
import { useInstalledBuiltInAccountApps } from '@/settings/applications/hooks/useInstalledBuiltInAccountApps';
-import { SettingsApplicationsTable } from '~/pages/settings/applications/components/SettingsApplicationsTable';
+import { SettingsApplicationsTable } from '@/settings/applications/components/SettingsApplicationsTable';
+import { useLingui } from '@lingui/react/macro';
export const SettingsApplicationsInstalledTab = () => {
+ const { t } = useLingui();
const installedApplications = useInstalledApplications();
const installedBuiltInAccountApps = useInstalledBuiltInAccountApps();
@@ -12,8 +14,11 @@ export const SettingsApplicationsInstalledTab = () => {
return (
<SettingsApplicationsTable
+ title={t`Installed apps`}
+ description={t`All the applications currently installed on this workspace`}
applications={installedApplications}
builtInAccountApps={installedBuiltInAccountApps}
+ variant="workspace"
/>
);
};
diff --git a/packages/twenty-front/src/pages/settings/developers/tabs/SettingsDevelopersAppsTab.tsx b/packages/twenty-front/src/pages/settings/developers/tabs/SettingsDevelopersAppsTab.tsx
index ae805f1a4bb..3d69bb3a748 100644
--- a/packages/twenty-front/src/pages/settings/developers/tabs/SettingsDevelopersAppsTab.tsx
+++ b/packages/twenty-front/src/pages/settings/developers/tabs/SettingsDevelopersAppsTab.tsx
@@ -5,8 +5,6 @@ import { TWENTY_CLI_LOGIN_COMMAND } from '@/settings/developers/constants/Twenty
import { useHasPermissionFlag } from '@/settings/roles/hooks/useHasPermissionFlag';
import { getDocumentationUrl } from '@/support/utils/getDocumentationUrl';
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 { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { useQuery } from '@apollo/client/react';
import { styled } from '@linaria/react';
@@ -26,10 +24,8 @@ import {
PermissionFlagType,
} from '~/generated-metadata/graphql';
import { useCopyToClipboard } from '~/hooks/useCopyToClipboard';
-import {
- APPLICATION_TABLE_ROW_GRID_TEMPLATE_COLUMNS,
- SettingsApplicationTableRow,
-} from '~/pages/settings/applications/components/SettingsApplicationTableRow';
+import { SettingsApplicationTableHeaderRow } from '@/settings/applications/components/SettingsApplicationTableHeaderRow';
+import { SettingsApplicationTableRow } from '@/settings/applications/components/SettingsApplicationTableRow';
import { SettingsClaimApplicationSection } from '~/pages/settings/applications/components/SettingsClaimApplicationSection';
import { openUrlInNewTab } from '~/utils/openUrlInNewTab';
@@ -132,14 +128,7 @@ export const SettingsDevelopersAppsTab = () => {
/>
</StyledSearchInputContainer>
<Table>
- <TableRow
- gridTemplateColumns={APPLICATION_TABLE_ROW_GRID_TEMPLATE_COLUMNS}
- >
- <TableHeader>{t`Name`}</TableHeader>
- <TableHeader>{t`Type`}</TableHeader>
- <TableHeader>{''}</TableHeader>
- <TableHeader />
- </TableRow>
+ <SettingsApplicationTableHeaderRow middleColumn="type" />
<StyledTableRowsContainer>
{registrations.map((registration) => {
return (