Skip to content

The open alternative to Salesforce, designed for AI.

Search the apps table by the name and description each row shows (#29277)

nitin62c1dd0bf01c
diff --git a/packages/twenty-front/src/modules/applications/hooks/useResolvedApplicationDescription.ts b/packages/twenty-front/src/modules/applications/hooks/useResolvedApplicationDescription.ts
index c7e8e70ef00..35870d349c4 100644
--- a/packages/twenty-front/src/modules/applications/hooks/useResolvedApplicationDescription.ts
+++ b/packages/twenty-front/src/modules/applications/hooks/useResolvedApplicationDescription.ts
@@ -1,9 +1,6 @@
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
-import { isTwentyStandardApplication } from '@/applications/utils/isTwentyStandardApplication';
-import { isWorkspaceCustomApplication } from '@/applications/utils/isWorkspaceCustomApplication';
-import { getCustomApplicationDescription } from '@/applications/utils/getCustomApplicationDescription';
-import { getStandardApplicationDescription } from '@/applications/utils/getStandardApplicationDescription';
+import { getResolvedApplicationDescription } from '@/applications/utils/getResolvedApplicationDescription';
type ApplicationLike = {
id?: string | null;
@@ -16,13 +13,5 @@ export const useResolvedApplicationDescription = (
): string => {
const currentWorkspace = useAtomStateValue(currentWorkspaceState);
- if (isTwentyStandardApplication(application)) {
- return getStandardApplicationDescription();
- }
-
- if (isWorkspaceCustomApplication(application, currentWorkspace)) {
- return getCustomApplicationDescription();
- }
-
- return application?.description ?? '';
+ return getResolvedApplicationDescription({ application, currentWorkspace });
};
diff --git a/packages/twenty-front/src/modules/applications/utils/getResolvedApplicationDescription.ts b/packages/twenty-front/src/modules/applications/utils/getResolvedApplicationDescription.ts
new file mode 100644
index 00000000000..d4c8e49d11b
--- /dev/null
+++ b/packages/twenty-front/src/modules/applications/utils/getResolvedApplicationDescription.ts
@@ -0,0 +1,32 @@
+import { getCustomApplicationDescription } from '@/applications/utils/getCustomApplicationDescription';
+import { getStandardApplicationDescription } from '@/applications/utils/getStandardApplicationDescription';
+import { isTwentyStandardApplication } from '@/applications/utils/isTwentyStandardApplication';
+import { isWorkspaceCustomApplication } from '@/applications/utils/isWorkspaceCustomApplication';
+
+type ApplicationLike = {
+ id?: string | null;
+ universalIdentifier?: string | null;
+ description?: string | null;
+};
+
+type WorkspaceLike = {
+ workspaceCustomApplication?: { id?: string | null } | null;
+};
+
+export const getResolvedApplicationDescription = ({
+ application,
+ currentWorkspace,
+}: {
+ application: ApplicationLike | null | undefined;
+ currentWorkspace: WorkspaceLike | null | undefined;
+}): string => {
+ if (isTwentyStandardApplication(application)) {
+ return getStandardApplicationDescription();
+ }
+
+ if (isWorkspaceCustomApplication(application, currentWorkspace)) {
+ return getCustomApplicationDescription();
+ }
+
+ return application?.description ?? '';
+};
diff --git a/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationsTable.tsx b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationsTable.tsx
index c12f6077730..c2d9f6de70c 100644
--- a/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationsTable.tsx
+++ b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationsTable.tsx
@@ -1,3 +1,4 @@
+import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
import { type BuiltInAccountApp } from '@/settings/app-preferences/types/BuiltInAccountApp';
import { SettingsApplicationTableHeaderRow } from '@/settings/applications/components/SettingsApplicationTableHeaderRow';
import { SettingsApplicationsTableApplicationRow } from '@/settings/applications/components/SettingsApplicationsTableApplicationRow';
@@ -10,6 +11,7 @@ import { getSettingsApplicationsTableRowItems } from '@/settings/applications/ut
import { SettingsEmptyPlaceholder } from '@/settings/components/SettingsEmptyPlaceholder';
import { SettingsSectionSkeletonLoader } from '@/settings/components/SettingsSectionSkeletonLoader';
import { Table } from '@/ui/layout/table/components/Table';
+import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
import { type ReactNode, useState } from 'react';
@@ -69,9 +71,12 @@ export const SettingsApplicationsTable = ({
const [searchTerm, setSearchTerm] = useState('');
+ const currentWorkspace = useAtomStateValue(currentWorkspaceState);
+
const rowItems = getSettingsApplicationsTableRowItems({
applications,
builtInAccountApps,
+ currentWorkspace,
});
const filteredRowItems = filterBySearchQuery({
diff --git a/packages/twenty-front/src/modules/settings/applications/components/__stories__/SettingsApplicationsTable.stories.tsx b/packages/twenty-front/src/modules/settings/applications/components/__stories__/SettingsApplicationsTable.stories.tsx
index 007efc39417..0489593d0ef 100644
--- a/packages/twenty-front/src/modules/settings/applications/components/__stories__/SettingsApplicationsTable.stories.tsx
+++ b/packages/twenty-front/src/modules/settings/applications/components/__stories__/SettingsApplicationsTable.stories.tsx
@@ -79,6 +79,29 @@ export const SearchMatchesBuiltInAccountApps: Story = {
},
};
+export const SearchMatchesTheDescriptionShownForTheStandardApp: Story = {
+ args: {
+ applications: [
+ { ...STANDARD_APPLICATION, name: 'twenty-standard' },
+ NPM_APPLICATION,
+ ],
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await userEvent.type(
+ await canvas.findByPlaceholderText('Search an application'),
+ 'data model',
+ );
+
+ await waitFor(() =>
+ expect(getSettingsApplicationsTableRowLinks(canvasElement)).toEqual([
+ '/settings/applications/standard-application-id',
+ ]),
+ );
+ },
+};
+
export const SearchWithNoMatchShowsAnEmptyState: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
diff --git a/packages/twenty-front/src/modules/settings/applications/utils/__tests__/getSettingsApplicationsTableRowItems.test.ts b/packages/twenty-front/src/modules/settings/applications/utils/__tests__/getSettingsApplicationsTableRowItems.test.ts
index 4cc3e93d07a..19f05423551 100644
--- a/packages/twenty-front/src/modules/settings/applications/utils/__tests__/getSettingsApplicationsTableRowItems.test.ts
+++ b/packages/twenty-front/src/modules/settings/applications/utils/__tests__/getSettingsApplicationsTableRowItems.test.ts
@@ -16,6 +16,7 @@ describe('getSettingsApplicationsTableRowItems', () => {
STANDARD_APPLICATION,
],
builtInAccountApps: BUILT_IN_ACCOUNT_APPS,
+ currentWorkspace: null,
});
expect(rowItems.map(({ id }) => id)).toEqual([
@@ -36,6 +37,7 @@ describe('getSettingsApplicationsTableRowItems', () => {
STANDARD_APPLICATION,
],
builtInAccountApps: [],
+ currentWorkspace: null,
});
expect(rowItems.map(({ id }) => id)).toEqual([
@@ -49,6 +51,7 @@ describe('getSettingsApplicationsTableRowItems', () => {
const [googleRowItem, npmRowItem] = getSettingsApplicationsTableRowItems({
applications: [NPM_APPLICATION],
builtInAccountApps: BUILT_IN_ACCOUNT_APPS.slice(0, 1),
+ currentWorkspace: null,
});
expect(npmRowItem).toMatchObject({
@@ -64,4 +67,33 @@ describe('getSettingsApplicationsTableRowItems', () => {
});
expect(googleRowItem.sourceType).toBeUndefined();
});
+
+ it('gives the standard and custom apps the name and description their rows show', () => {
+ const customApplication = {
+ id: 'custom-application-id',
+ name: 'workspace-custom',
+ universalIdentifier: 'custom-application-universal-identifier',
+ };
+
+ const [standardRowItem, customRowItem] =
+ getSettingsApplicationsTableRowItems({
+ applications: [
+ { ...STANDARD_APPLICATION, name: 'twenty-standard' },
+ customApplication,
+ ],
+ builtInAccountApps: [],
+ currentWorkspace: {
+ workspaceCustomApplication: { id: customApplication.id },
+ },
+ });
+
+ expect(standardRowItem).toMatchObject({
+ name: 'Standard',
+ description: 'The base data model every Twenty workspace runs on.',
+ });
+ expect(customRowItem).toMatchObject({
+ name: 'Custom',
+ description: "Host your workspace's customizations and overrides.",
+ });
+ });
});
diff --git a/packages/twenty-front/src/modules/settings/applications/utils/getSettingsApplicationsTableRowItems.ts b/packages/twenty-front/src/modules/settings/applications/utils/getSettingsApplicationsTableRowItems.ts
index 8283d79a58a..e8198f8fa34 100644
--- a/packages/twenty-front/src/modules/settings/applications/utils/getSettingsApplicationsTableRowItems.ts
+++ b/packages/twenty-front/src/modules/settings/applications/utils/getSettingsApplicationsTableRowItems.ts
@@ -1,4 +1,7 @@
+import { getApplicationDisplayName } from '@/applications/utils/getApplicationDisplayName';
+import { getResolvedApplicationDescription } from '@/applications/utils/getResolvedApplicationDescription';
import { isTwentyStandardApplication } from '@/applications/utils/isTwentyStandardApplication';
+import { type CurrentWorkspace } from '@/auth/states/currentWorkspaceState';
import { type BuiltInAccountApp } from '@/settings/app-preferences/types/BuiltInAccountApp';
import { getBuiltInAccountAppLogoUrl } from '@/settings/app-preferences/utils/getBuiltInAccountAppLogoUrl';
import { type SettingsApplicationsTableApplication } from '@/settings/applications/types/SettingsApplicationsTableApplication';
@@ -7,12 +10,21 @@ import { sortApplicationsWithOAuthOnlyLast } from '@/settings/applications/utils
import { i18n } from '@lingui/core';
import { isNonEmptyArray } from 'twenty-shared/utils';
-const getApplicationRowItem = (
- application: SettingsApplicationsTableApplication,
-): SettingsApplicationsTableRowItem => ({
+type RowItemsWorkspace = Pick<CurrentWorkspace, 'workspaceCustomApplication'>;
+
+const getApplicationRowItem = ({
+ application,
+ currentWorkspace,
+}: {
+ application: SettingsApplicationsTableApplication;
+ currentWorkspace: RowItemsWorkspace | null | undefined;
+}): SettingsApplicationsTableRowItem => ({
id: application.id,
- name: application.name,
- description: application.description ?? null,
+ name: getApplicationDisplayName({ application, currentWorkspace }),
+ description: getResolvedApplicationDescription({
+ application,
+ currentWorkspace,
+ }),
logoUrl: application.logoUrl,
universalIdentifier: application.universalIdentifier,
sourceType: application.applicationRegistration?.sourceType,
@@ -30,23 +42,28 @@ const getBuiltInAccountAppRowItem = (
export const getSettingsApplicationsTableRowItems = ({
applications,
builtInAccountApps,
+ currentWorkspace,
}: {
applications: SettingsApplicationsTableApplication[];
builtInAccountApps: BuiltInAccountApp[];
+ currentWorkspace: RowItemsWorkspace | null | undefined;
}): SettingsApplicationsTableRowItem[] => {
const sortedApplications = sortApplicationsWithOAuthOnlyLast(applications);
+ const toApplicationRowItem = (
+ application: SettingsApplicationsTableApplication,
+ ) => getApplicationRowItem({ application, currentWorkspace });
if (!isNonEmptyArray(builtInAccountApps)) {
- return sortedApplications.map(getApplicationRowItem);
+ return sortedApplications.map(toApplicationRowItem);
}
return [
...sortedApplications
.filter(isTwentyStandardApplication)
- .map(getApplicationRowItem),
+ .map(toApplicationRowItem),
...builtInAccountApps.map(getBuiltInAccountAppRowItem),
...sortedApplications
.filter((application) => !isTwentyStandardApplication(application))
- .map(getApplicationRowItem),
+ .map(toApplicationRowItem),
];
};