Skip to content

The open alternative to Salesforce, designed for AI.

Remove tabs from marketplace app detail page (#27868)

martmulleedc47828b9f
diff --git a/packages/twenty-front/src/modules/logic-functions/utils/__tests__/getLogicFunctionTriggerLabel.test.ts b/packages/twenty-front/src/modules/logic-functions/utils/__tests__/getLogicFunctionTriggerLabel.test.ts
deleted file mode 100644
index c541434a963..00000000000
--- a/packages/twenty-front/src/modules/logic-functions/utils/__tests__/getLogicFunctionTriggerLabel.test.ts
+++ /dev/null
@@ -1,76 +0,0 @@
-import { getLogicFunctionTriggerLabel } from '@/logic-functions/utils/getLogicFunctionTriggerLabel';
-
-describe('getLogicFunctionTriggerLabel', () => {
- it('returns Post-install when the function matches the post-install identifier', () => {
- expect(
- getLogicFunctionTriggerLabel(
- { universalIdentifier: 'uid-post' },
- { postInstallUniversalIdentifier: 'uid-post' },
- ),
- ).toBe('Post-install');
- });
-
- it('returns Pre-install when the function matches the pre-install identifier', () => {
- expect(
- getLogicFunctionTriggerLabel(
- { universalIdentifier: 'uid-pre' },
- { preInstallUniversalIdentifier: 'uid-pre' },
- ),
- ).toBe('Pre-install');
- });
-
- it('returns Uninstall when the function matches the uninstall identifier', () => {
- expect(
- getLogicFunctionTriggerLabel(
- { universalIdentifier: 'uid-uninstall' },
- { uninstallUniversalIdentifier: 'uid-uninstall' },
- ),
- ).toBe('Uninstall');
- });
-
- it('does not match when both identifiers are undefined', () => {
- expect(getLogicFunctionTriggerLabel({}, {})).toBe('');
- });
-
- it('returns AI tool when toolTriggerSettings is set', () => {
- expect(
- getLogicFunctionTriggerLabel({
- toolTriggerSettings: { inputSchema: { type: 'object' } },
- }),
- ).toBe('AI tool');
- });
-
- it('returns Workflow action when workflowActionTriggerSettings is set', () => {
- expect(
- getLogicFunctionTriggerLabel({
- workflowActionTriggerSettings: { inputSchema: [] },
- }),
- ).toBe('Workflow action');
- });
-
- it('returns Cron when cron settings are present', () => {
- expect(getLogicFunctionTriggerLabel({ cronTriggerSettings: {} })).toBe(
- 'Cron',
- );
- });
-
- it('returns HTTP when http settings are present', () => {
- expect(getLogicFunctionTriggerLabel({ httpRouteTriggerSettings: {} })).toBe(
- 'HTTP',
- );
- });
-
- it('returns the database event name when it exists', () => {
- expect(
- getLogicFunctionTriggerLabel({
- databaseEventTriggerSettings: { eventName: 'person.created' },
- }),
- ).toBe('person.created');
- });
-
- it('falls back to a generic label when the database event name is missing', () => {
- expect(
- getLogicFunctionTriggerLabel({ databaseEventTriggerSettings: {} }),
- ).toBe('Database event');
- });
-});
diff --git a/packages/twenty-front/src/modules/logic-functions/utils/getLogicFunctionTriggerLabel.ts b/packages/twenty-front/src/modules/logic-functions/utils/getLogicFunctionTriggerLabel.ts
deleted file mode 100644
index b1436aa4e6e..00000000000
--- a/packages/twenty-front/src/modules/logic-functions/utils/getLogicFunctionTriggerLabel.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-import { t } from '@lingui/core/macro';
-import { isDefined } from 'twenty-shared/utils';
-
-type LogicFunctionLike = {
- universalIdentifier?: string | null;
- cronTriggerSettings?: unknown;
- httpRouteTriggerSettings?: unknown;
- databaseEventTriggerSettings?: { eventName?: string } | null;
- toolTriggerSettings?: unknown;
- workflowActionTriggerSettings?: unknown;
-};
-
-export const getLogicFunctionTriggerLabel = (
- lf: LogicFunctionLike,
- options: {
- postInstallUniversalIdentifier?: string;
- preInstallUniversalIdentifier?: string;
- uninstallUniversalIdentifier?: string;
- } = {},
-): string => {
- if (
- isDefined(lf.universalIdentifier) &&
- lf.universalIdentifier === options.postInstallUniversalIdentifier
- ) {
- return t`Post-install`;
- }
- if (
- isDefined(lf.universalIdentifier) &&
- lf.universalIdentifier === options.preInstallUniversalIdentifier
- ) {
- return t`Pre-install`;
- }
- if (
- isDefined(lf.universalIdentifier) &&
- lf.universalIdentifier === options.uninstallUniversalIdentifier
- ) {
- return t`Uninstall`;
- }
- if (isDefined(lf.toolTriggerSettings)) return t`AI tool`;
- if (isDefined(lf.workflowActionTriggerSettings)) return t`Workflow action`;
- if (lf.cronTriggerSettings) return t`Cron`;
- if (lf.httpRouteTriggerSettings) return t`HTTP`;
- if (lf.databaseEventTriggerSettings) {
- return lf.databaseEventTriggerSettings.eventName ?? t`Database event`;
- }
- return '';
-};
diff --git a/packages/twenty-front/src/modules/settings/applications/hooks/__tests__/useComputeApplicationContentForLayoutAndLogic.test.tsx b/packages/twenty-front/src/modules/settings/applications/hooks/__tests__/useComputeApplicationContentForLayoutAndLogic.test.tsx
deleted file mode 100644
index 84cdbfd2818..00000000000
--- a/packages/twenty-front/src/modules/settings/applications/hooks/__tests__/useComputeApplicationContentForLayoutAndLogic.test.tsx
+++ /dev/null
@@ -1,253 +0,0 @@
-import { renderHook } from '@testing-library/react';
-
-import { useComputeApplicationContentForLayoutAndLogic } from '@/settings/applications/hooks/useComputeApplicationContentForLayoutAndLogic';
-import { type Manifest } from 'twenty-shared/application';
-import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';
-import { getTestEnrichedObjectMetadataItemsMock } from '~/testing/utils/getTestEnrichedObjectMetadataItemsMock';
-
-const mockObjectMetadataItems = getTestEnrichedObjectMetadataItemsMock();
-const personObject = mockObjectMetadataItems.find(
- (item) => item.nameSingular === 'person',
-)!;
-
-const APP_ID = 'test-app-id';
-
-const wrapper = getJestMetadataAndApolloMocksWrapper({ apolloMocks: [] });
-
-const baseManifest = {
- pageLayouts: [],
- views: [],
- navigationMenuItems: [],
- agents: [],
- skills: [],
- roles: [],
-} as unknown as Manifest;
-
-describe('useComputeApplicationContentForLayoutAndLogic', () => {
- describe('pageLayoutRows', () => {
- it('builds rows from manifest pageLayouts and resolves the object label from workspace metadata', () => {
- const manifestContent = {
- ...baseManifest,
- objects: [],
- pageLayouts: [
- {
- universalIdentifier: 'pl-1',
- name: 'Person dashboard',
- objectUniversalIdentifier: personObject.universalIdentifier,
- tabs: [
- { universalIdentifier: 't1' },
- { universalIdentifier: 't2' },
- ],
- },
- ],
- } as unknown as Manifest;
-
- const { result } = renderHook(
- () =>
- useComputeApplicationContentForLayoutAndLogic({ manifestContent }),
- { wrapper },
- );
-
- expect(result.current.pageLayoutRows).toHaveLength(1);
- const [row] = result.current.pageLayoutRows;
- expect(row.key).toBe('pl-1');
- expect(row.name).toBe('Person dashboard');
- expect(row.secondary).toContain(personObject.labelSingular);
- expect(row.secondary).toContain('2 tabs');
- expect(row.link).toBeUndefined();
- });
-
- it('exposes a link to the layout detail page when an installed app is provided', () => {
- const manifestContent = {
- ...baseManifest,
- objects: [],
- pageLayouts: [
- {
- universalIdentifier: 'pl-1',
- name: 'Layout',
- tabs: [],
- },
- ],
- } as unknown as Manifest;
-
- const { result } = renderHook(
- () =>
- useComputeApplicationContentForLayoutAndLogic({
- installedApplication: { id: APP_ID, agents: [] },
- manifestContent,
- }),
- { wrapper },
- );
-
- expect(result.current.pageLayoutRows[0].link).toBeDefined();
- });
- });
-
- describe('viewRows', () => {
- it('builds rows from manifest views with type/object secondary', () => {
- const manifestContent = {
- ...baseManifest,
- objects: [],
- views: [
- {
- universalIdentifier: 'v-1',
- name: 'My table',
- type: 'TABLE',
- objectUniversalIdentifier: personObject.universalIdentifier,
- icon: 'IconTable',
- },
- {
- universalIdentifier: 'v-2',
- name: 'Record table widget',
- type: 'TABLE_WIDGET',
- objectUniversalIdentifier: personObject.universalIdentifier,
- },
- ],
- } as unknown as Manifest;
-
- const { result } = renderHook(
- () =>
- useComputeApplicationContentForLayoutAndLogic({ manifestContent }),
- { wrapper },
- );
-
- const [row] = result.current.viewRows;
- expect(row.icon).toBe('IconTable');
- expect(row.secondary).toContain('Table');
- expect(row.secondary).toContain(personObject.labelSingular);
-
- expect(result.current.viewRows[1].secondary).toContain('Table widget');
- expect(result.current.viewRows[1].secondary).not.toContain(
- 'Table_widget',
- );
- });
- });
-
- describe('navigationMenuItemRows', () => {
- it('falls back to a destination-derived display name when the item has no name', () => {
- const manifestContent = {
- ...baseManifest,
- objects: [],
- navigationMenuItems: [
- {
- universalIdentifier: 'n-1',
- type: 'OBJECT',
- targetObjectUniversalIdentifier: personObject.universalIdentifier,
- },
- { universalIdentifier: 'n-2', type: 'FOLDER' },
- {
- universalIdentifier: 'n-3',
- type: 'LINK',
- link: 'https://example.com',
- },
- ],
- } as unknown as Manifest;
-
- const { result } = renderHook(
- () =>
- useComputeApplicationContentForLayoutAndLogic({ manifestContent }),
- { wrapper },
- );
-
- expect(result.current.navigationMenuItemRows[0].name).toBe(
- personObject.labelSingular,
- );
- expect(result.current.navigationMenuItemRows[1].name).toBe('Folder');
- expect(result.current.navigationMenuItemRows[2].name).toBe(
- 'https://example.com',
- );
- });
-
- it('resolves PAGE_LAYOUT and VIEW destinations against the manifest', () => {
- const manifestContent = {
- ...baseManifest,
- objects: [],
- pageLayouts: [{ universalIdentifier: 'pl-1', name: 'Layout A' }],
- views: [{ universalIdentifier: 'v-1', name: 'View A' }],
- navigationMenuItems: [
- {
- universalIdentifier: 'n-1',
- type: 'PAGE_LAYOUT',
- pageLayoutUniversalIdentifier: 'pl-1',
- },
- {
- universalIdentifier: 'n-2',
- type: 'VIEW',
- viewUniversalIdentifier: 'v-1',
- },
- ],
- } as unknown as Manifest;
-
- const { result } = renderHook(
- () =>
- useComputeApplicationContentForLayoutAndLogic({ manifestContent }),
- { wrapper },
- );
-
- expect(result.current.navigationMenuItemRows[0].secondary).toContain(
- 'Layout A',
- );
- expect(result.current.navigationMenuItemRows[1].secondary).toContain(
- 'View A',
- );
- });
- });
-
- describe('agentRows', () => {
- it('uses installed agents (with link) when available, manifest agents otherwise', () => {
- const installed = renderHook(
- () =>
- useComputeApplicationContentForLayoutAndLogic({
- installedApplication: {
- id: APP_ID,
- agents: [
- {
- id: 'agent-1',
- label: 'Workspace Agent',
- description: 'desc',
- },
- ],
- } as never,
- manifestContent: baseManifest,
- }),
- { wrapper },
- );
- expect(installed.result.current.agentRows[0].key).toBe('agent-1');
- expect(installed.result.current.agentRows[0].link).toBeDefined();
-
- const marketplace = renderHook(
- () =>
- useComputeApplicationContentForLayoutAndLogic({
- manifestContent: {
- ...baseManifest,
- agents: [
- { universalIdentifier: 'a-uid', label: 'Manifest Agent' },
- ],
- } as unknown as Manifest,
- }),
- { wrapper },
- );
- expect(marketplace.result.current.agentRows[0].key).toBe('a-uid');
- expect(marketplace.result.current.agentRows[0].link).toBeUndefined();
- });
- });
-
- describe('skillRows and roleRows', () => {
- it('builds rows from manifest skills and roles', () => {
- const manifestContent = {
- ...baseManifest,
- skills: [{ universalIdentifier: 's-1', label: 'Skill A' }],
- roles: [{ universalIdentifier: 'r-1', label: 'Role A' }],
- } as unknown as Manifest;
-
- const { result } = renderHook(
- () =>
- useComputeApplicationContentForLayoutAndLogic({ manifestContent }),
- { wrapper },
- );
-
- expect(result.current.skillRows[0].name).toBe('Skill A');
- expect(result.current.roleRows[0].name).toBe('Role A');
- });
- });
-});
diff --git a/packages/twenty-front/src/modules/settings/applications/hooks/__tests__/useComputeObjectAndFieldsContentForApplication.test.tsx b/packages/twenty-front/src/modules/settings/applications/hooks/__tests__/useComputeObjectAndFieldsContentForApplication.test.tsx
deleted file mode 100644
index 7cb8c2f3ad6..00000000000
--- a/packages/twenty-front/src/modules/settings/applications/hooks/__tests__/useComputeObjectAndFieldsContentForApplication.test.tsx
+++ /dev/null
@@ -1,329 +0,0 @@
-import { renderHook } from '@testing-library/react';
-
-import { useComputeObjectAndFieldsContentForApplication } from '@/settings/applications/hooks/useComputeObjectAndFieldsContentForApplication';
-import { type Manifest } from 'twenty-shared/application';
-import { getJestMetadataAndApolloMocksWrapper } from '~/testing/jest/getJestMetadataAndApolloMocksWrapper';
-import { getTestEnrichedObjectMetadataItemsMock } from '~/testing/utils/getTestEnrichedObjectMetadataItemsMock';
-
-const mockObjectMetadataItems = getTestEnrichedObjectMetadataItemsMock();
-
-const personObject = mockObjectMetadataItems.find(
- (item) => item.nameSingular === 'person',
-)!;
-const companyObject = mockObjectMetadataItems.find(
- (item) => item.nameSingular === 'company',
-)!;
-
-const APP_ID = 'test-app-id';
-
-const wrapper = getJestMetadataAndApolloMocksWrapper({
- apolloMocks: [],
-});
-
-describe('useComputeObjectAndFieldsContentForApplication', () => {
- describe('with installed application', () => {
- it('should return object rows for installed application objects', () => {
- const installedApplication = {
- id: APP_ID,
- universalIdentifier: APP_ID,
- objects: [{ id: personObject.id }],
- name: 'Test App',
- logo: null,
- canBeUninstalled: true,
- isUninstallBlockedByOtherWorkspaceInstallations: false,
- autoUpgrade: false,
- createdAt: '2024-01-01T00:00:00.000Z',
- availablePackages: {},
- applicationVariables: [],
- agents: [],
- logicFunctions: [],
- frontComponents: [],
- };
-
- const { result } = renderHook(
- () =>
- useComputeObjectAndFieldsContentForApplication({
- installedApplication,
- }),
- { wrapper },
- );
-
- expect(result.current.objectRows).toHaveLength(1);
- expect(result.current.objectRows[0].key).toBe(personObject.nameSingular);
- expect(result.current.objectRows[0].name).toBe(personObject.labelPlural);
- expect(result.current.objectRows[0].secondary).toMatch(/\d+ fields/);
- expect(result.current.objectRows[0].link).toBeDefined();
- });
-
- it('should return empty object rows when application has no objects', () => {
- const installedApplication = {
- id: APP_ID,
- universalIdentifier: APP_ID,
- objects: [],
- name: 'Test App',
- logo: null,
- canBeUninstalled: true,
- isUninstallBlockedByOtherWorkspaceInstallations: false,
- autoUpgrade: false,
- createdAt: '2024-01-01T00:00:00.000Z',
- availablePackages: {},
- applicationVariables: [],
- agents: [],
- logicFunctions: [],
- frontComponents: [],
- };
-
- const { result } = renderHook(
- () =>
- useComputeObjectAndFieldsContentForApplication({
- installedApplication,
- }),
- { wrapper },
- );
-
- expect(result.current.objectRows).toHaveLength(0);
- });
-
- it("should not include the app's own objects among the field rows", () => {
- const fieldBelongingToApp = companyObject.fields[0];
-
- const installedApplication = {
- id: fieldBelongingToApp.applicationId ?? APP_ID,
- universalIdentifier: fieldBelongingToApp.applicationId ?? APP_ID,
- objects: [{ id: personObject.id }],
- name: 'Test App',
- logo: null,
- canBeUninstalled: true,
- isUninstallBlockedByOtherWorkspaceInstallations: false,
- autoUpgrade: false,
- createdAt: '2024-01-01T00:00:00.000Z',
- availablePackages: {},
- applicationVariables: [],
- agents: [],
- logicFunctions: [],
- frontComponents: [],
- };
-
- const { result } = renderHook(
- () =>
- useComputeObjectAndFieldsContentForApplication({
- installedApplication,
- }),
- { wrapper },
- );
-
- const referencesOwnObject = result.current.fieldRows.some((row) =>
- row.secondary?.includes(personObject.labelSingular),
- );
- expect(referencesOwnObject).toBe(false);
- });
-
- it('should exclude deny-listed objects from field rows', () => {
- const installedApplication = {
- id: APP_ID,
- universalIdentifier: APP_ID,
- objects: [],
- name: 'Test App',
- logo: null,
- canBeUninstalled: true,
- isUninstallBlockedByOtherWorkspaceInstallations: false,
- autoUpgrade: false,
- createdAt: '2024-01-01T00:00:00.000Z',
- availablePackages: {},
- applicationVariables: [],
- agents: [],
- logicFunctions: [],
- frontComponents: [],
- };
-
- const { result } = renderHook(
- () =>
- useComputeObjectAndFieldsContentForApplication({
- installedApplication,
- }),
- { wrapper },
- );
-
- const timelineActivityObject = mockObjectMetadataItems.find(
- (item) => item.nameSingular === 'timelineActivity',
- );
- const favoriteObject = mockObjectMetadataItems.find(
- (item) => item.nameSingular === 'favorite',
- );
-
- const hasDeniedObjectField = result.current.fieldRows.some(
- (row) =>
- row.secondary?.includes(
- timelineActivityObject?.labelSingular ?? '__never__',
- ) ||
- row.secondary?.includes(favoriteObject?.labelSingular ?? '__never__'),
- );
- expect(hasDeniedObjectField).toBe(false);
- });
- });
-
- describe('with manifest content', () => {
- it('should return object rows from manifest objects', () => {
- const manifestContent = {
- objects: [
- {
- universalIdentifier: 'uid-1',
- nameSingular: 'customObject',
- namePlural: 'customObjects',
- labelSingular: 'Custom Object',
- labelPlural: 'Custom Objects',
- icon: 'IconBox',
- fields: [{ name: 'field1' }, { name: 'field2' }],
- },
- ],
- fields: [],
- } as unknown as Manifest;
-
- const { result } = renderHook(
- () =>
- useComputeObjectAndFieldsContentForApplication({
- manifestContent,
- }),
- { wrapper },
- );
-
- expect(result.current.objectRows).toHaveLength(1);
- expect(result.current.objectRows[0].key).toBe('customObject');
- expect(result.current.objectRows[0].name).toBe('Custom Objects');
- expect(result.current.objectRows[0].secondary).toBe('2 fields');
- });
-
- it('should return one row per field when the parent object lives in the manifest', () => {
- const manifestContent = {
- objects: [
- {
- universalIdentifier: 'custom-obj-uid',
- nameSingular: 'customObj',
- namePlural: 'customObjs',
- labelSingular: 'Custom',
- labelPlural: 'Customs',
- icon: 'IconBox',
- fields: [],
- },
- ],
- fields: [
- {
- objectUniversalIdentifier: 'custom-obj-uid',
- universalIdentifier: 'field1-uid',
- name: 'field1',
- label: 'Field 1',
- },
- {
- objectUniversalIdentifier: 'custom-obj-uid',
- universalIdentifier: 'field2-uid',
- name: 'field2',
- label: 'Field 2',
- },
- {
- objectUniversalIdentifier: 'custom-obj-uid',
- universalIdentifier: 'field3-uid',
- name: 'field3',
- label: 'Field 3',
- },
- ],
- } as unknown as Manifest;
-
- const { result } = renderHook(
- () =>
- useComputeObjectAndFieldsContentForApplication({
- manifestContent,
- }),
- { wrapper },
- );
-
- expect(result.current.fieldRows).toHaveLength(3);
- expect(result.current.fieldRows.map((r) => r.name)).toEqual([
- 'Field 1',
- 'Field 2',
- 'Field 3',
- ]);
- expect(
- result.current.fieldRows.every((r) => r.secondary === 'on Custom'),
- ).toBe(true);
- });
-
- it('should return empty field rows when manifest has no fields', () => {
- const manifestContent = {
- objects: [],
- fields: [],
- } as unknown as Manifest;
-
- const { result } = renderHook(
- () =>
- useComputeObjectAndFieldsContentForApplication({
- manifestContent,
- }),
- { wrapper },
- );
-
- expect(result.current.fieldRows).toHaveLength(0);
- });
-
- it('should return empty rows when no data is provided', () => {
- const { result } = renderHook(
- () => useComputeObjectAndFieldsContentForApplication({}),
- {
- wrapper,
- },
- );
-
- expect(result.current.objectRows).toHaveLength(0);
- expect(result.current.fieldRows).toHaveLength(0);
- });
- });
-
- describe('data source priority', () => {
- it('should use installed application data when both sources are provided', () => {
- const installedApplication = {
- id: APP_ID,
- universalIdentifier: APP_ID,
- objects: [{ id: personObject.id }],
- name: 'Test App',
- logo: null,
- canBeUninstalled: true,
- isUninstallBlockedByOtherWorkspaceInstallations: false,
- autoUpgrade: false,
- createdAt: '2024-01-01T00:00:00.000Z',
- availablePackages: {},
- applicationVariables: [],
- agents: [],
- logicFunctions: [],
- frontComponents: [],
- };
-
- const manifestContent = {
- objects: [
- {
- universalIdentifier: 'uid-1',
- nameSingular: 'manifestObj',
- namePlural: 'manifestObjs',
- labelSingular: 'Manifest',
- labelPlural: 'Manifests',
- icon: 'IconBox',
- fields: [],
- },
- ],
- fields: [],
- } as unknown as Manifest;
-
- const { result } = renderHook(
- () =>
- useComputeObjectAndFieldsContentForApplication({
- installedApplication,
- manifestContent,
- }),
- { wrapper },
- );
-
- expect(result.current.objectRows[0].key).toBe(personObject.nameSingular);
- expect(
- result.current.objectRows.some((r) => r.key === 'manifestObj'),
- ).toBe(false);
- });
- });
-});
diff --git a/packages/twenty-front/src/modules/settings/applications/hooks/useComputeApplicationContentForLayoutAndLogic.ts b/packages/twenty-front/src/modules/settings/applications/hooks/useComputeApplicationContentForLayoutAndLogic.ts
deleted file mode 100644
index 2f830f3d3d6..00000000000
--- a/packages/twenty-front/src/modules/settings/applications/hooks/useComputeApplicationContentForLayoutAndLogic.ts
+++ /dev/null
@@ -1,207 +0,0 @@
-import { getCoreAgentLink } from '@/object-core/agents/utils/getCoreAgentLink';
-import { objectMetadataItemsSelector } from '@/object-metadata/states/objectMetadataItemsSelector';
-import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
-import { getViewTypeLabel } from '@/views/types/ViewType';
-import { i18n } from '@lingui/core';
-import { t } from '@lingui/core/macro';
-import { type Manifest } from 'twenty-shared/application';
-import { SettingsPath } from 'twenty-shared/types';
-import { getSettingsPath, isDefined } from 'twenty-shared/utils';
-import { type Application } from '~/generated-metadata/graphql';
-import { type ApplicationContentRow } from '@/settings/applications/types/ApplicationContentRow';
-
-type InstalledApplicationForContent = Pick<Application, 'agents' | 'id'>;
-
-export const useComputeApplicationContentForLayoutAndLogic = ({
- installedApplication,
- manifestContent,
-}: {
- installedApplication?: InstalledApplicationForContent;
- manifestContent?: Manifest;
-}) => {
- const objectMetadataItems = useAtomStateValue(objectMetadataItemsSelector);
-
- const installedAppId = installedApplication?.id;
-
- // Workspace metadata covers standard + installed-app objects; the manifest
- // fallback only matters when previewing an uninstalled marketplace app.
- const resolveLabel = (uid: string | undefined | null) => {
- if (!isDefined(uid)) return undefined;
- return (
- objectMetadataItems.find((o) => o.universalIdentifier === uid)
- ?.labelSingular ??
- manifestContent?.objects.find((o) => o.universalIdentifier === uid)
- ?.labelSingular
- );
- };
-
- const pageLayoutRows: ApplicationContentRow[] = (
- manifestContent?.pageLayouts ?? []
- ).map((layout) => {
- const objectLabel = resolveLabel(layout.objectUniversalIdentifier);
- const tabCount = layout.tabs?.length ?? 0;
-
- const parts: string[] = [];
- if (isDefined(objectLabel)) parts.push(t`for ${objectLabel}`);
- if (tabCount > 0) {
- parts.push(tabCount === 1 ? t`1 tab` : t`${tabCount} tabs`);
- }
-
- return {
- key: layout.universalIdentifier,
- name: layout.name,
- secondary: parts.length > 0 ? parts.join(' · ') : undefined,
- link: isDefined(installedAppId)
- ? getSettingsPath(SettingsPath.ApplicationPageLayoutDetail, {
- applicationId: installedAppId,
- pageLayoutUniversalIdentifier: layout.universalIdentifier,
- })
- : undefined,
- };
- });
-
- const viewRows: ApplicationContentRow[] = (manifestContent?.views ?? []).map(
- (view) => {
- const objectLabel = resolveLabel(view.objectUniversalIdentifier);
- const formattedType = i18n._(getViewTypeLabel(view.type));
-
- return {
- key: view.universalIdentifier,
- name: view.name,
- icon: view.icon ?? undefined,
- secondary: isDefined(objectLabel)
- ? t`${formattedType} of ${objectLabel}`
- : formattedType,
- link: isDefined(installedAppId)
- ? getSettingsPath(SettingsPath.ApplicationViewDetail, {
- applicationId: installedAppId,
- viewUniversalIdentifier: view.universalIdentifier,
- })
- : undefined,
- };
- },
- );
-
- const navigationMenuItemRows: ApplicationContentRow[] = (
- manifestContent?.navigationMenuItems ?? []
- ).map((item) => {
- const destination = (() => {
- switch (item.type) {
- case 'FOLDER':
- return { label: t`Folder`, displayName: t`Folder` };
- case 'LINK': {
- const link = item.link ?? t`Link`;
- return { label: link, displayName: link };
- }
- case 'OBJECT': {
- const label = resolveLabel(item.targetObjectUniversalIdentifier);
- return {
- label: isDefined(label) ? t`${label} list` : t`Object`,
- displayName: label,
- };
- }
- case 'PAGE_LAYOUT': {
- const layout = manifestContent?.pageLayouts?.find(
- (pl) =>
- pl.universalIdentifier === item.pageLayoutUniversalIdentifier,
- );
- return {
- label: isDefined(layout)
- ? t`${layout.name} layout`
- : t`Page layout`,
- displayName: layout?.name,
- };
- }
- case 'VIEW': {
- const view = manifestContent?.views?.find(
- (v) => v.universalIdentifier === item.viewUniversalIdentifier,
- );
- return {
- label: isDefined(view) ? t`${view.name} view` : t`View`,
- displayName: view?.name,
- };
- }
- case 'RECORD':
- return { label: t`Record`, displayName: t`Record` };
- default:
- return { label: undefined, displayName: undefined };
- }
- })();
-
- const displayName =
- isDefined(item.name) && item.name !== ''
- ? item.name
- : (destination.displayName ?? item.type);
-
- return {
- key: item.universalIdentifier,
- name: displayName,
- icon: item.icon ?? undefined,
- secondary: destination.label,
- };
- });
-
- const agentRows: ApplicationContentRow[] = isDefined(installedApplication)
- ? (installedApplication.agents ?? []).map((agent) => ({
- key: agent.id,
- name: agent.label,
- icon: agent.icon ?? undefined,
- secondary: agent.description ?? undefined,
- link: getCoreAgentLink(agent.id),
- }))
- : (manifestContent?.agents ?? []).map((agent) => ({
- key: agent.universalIdentifier,
- name: agent.label,
- icon: agent.icon ?? undefined,
- secondary: agent.description ?? undefined,
- }));
-
- const skillRows: ApplicationContentRow[] = (
- manifestContent?.skills ?? []
- ).map((skill) => ({
- key: skill.universalIdentifier,
- name: skill.label,
- icon: skill.icon ?? undefined,
- secondary: skill.description ?? undefined,
- }));
-
- const roleRows: ApplicationContentRow[] = (manifestContent?.roles ?? []).map(
- (role) => ({
- key: role.universalIdentifier,
- name: role.label,
- icon: role.icon ?? undefined,
- secondary: role.description ?? undefined,
- }),
- );
-
- const connectionProviderRows: ApplicationContentRow[] = (
- manifestContent?.connectionProviders ?? []
- ).map((provider) => {
- const parts: string[] = [];
-
- if (provider.type === 'oauth') {
- parts.push(t`OAuth 2.0`);
- const scopeCount = provider.oauth.scopes.length;
- if (scopeCount > 0) {
- parts.push(scopeCount === 1 ? t`1 scope` : t`${scopeCount} scopes`);
- }
- }
-
- return {
- key: provider.universalIdentifier,
- name: provider.displayName,
- icon: undefined,
- secondary: parts.length > 0 ? parts.join(' · ') : undefined,
- };
- });
-
- return {
- pageLayoutRows,
- viewRows,
- navigationMenuItemRows,
- agentRows,
- skillRows,
- roleRows,
- connectionProviderRows,
- };
-};
diff --git a/packages/twenty-front/src/modules/settings/applications/hooks/useComputeObjectAndFieldsContentForApplication.ts b/packages/twenty-front/src/modules/settings/applications/hooks/useComputeObjectAndFieldsContentForApplication.ts
deleted file mode 100644
index ff91c883f79..00000000000
--- a/packages/twenty-front/src/modules/settings/applications/hooks/useComputeObjectAndFieldsContentForApplication.ts
+++ /dev/null
@@ -1,127 +0,0 @@
-import { objectMetadataItemsSelector } from '@/object-metadata/states/objectMetadataItemsSelector';
-import { isHiddenSystemField } from '@/object-metadata/utils/isHiddenSystemField';
-import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
-import { t } from '@lingui/core/macro';
-import { type Manifest } from 'twenty-shared/application';
-import { SettingsPath } from 'twenty-shared/types';
-import { getSettingsPath, isDefined } from 'twenty-shared/utils';
-import { type Application } from '~/generated-metadata/graphql';
-import { type ApplicationContentRow } from '@/settings/applications/types/ApplicationContentRow';
-
-type InstalledApplicationForObjectAndFields = Omit<
- Application,
- | 'objects'
- | 'universalIdentifier'
- | 'frontComponents'
- | 'commandMenuItems'
- | 'settingsMenuItems'
-> & {
- objects: { id: string }[];
-};
-
-const FIELD_GROUP_DENY_LIST = new Set(['timelineActivity', 'favorite']);
-
-export const useComputeObjectAndFieldsContentForApplication = ({
- installedApplication,
- manifestContent,
-}: {
- installedApplication?: InstalledApplicationForObjectAndFields;
- manifestContent?: Manifest;
-}) => {
- const objectMetadataItems = useAtomStateValue(objectMetadataItemsSelector);
-
- const installedObjectIds = new Set(
- installedApplication?.objects.map((object) => object.id),
- );
-
- const objectRows: ApplicationContentRow[] = isDefined(installedApplication)
- ? objectMetadataItems
- .filter((item) => installedObjectIds.has(item.id))
- .map((item) => {
- const fieldsCount = item.fields.filter(
- (f) => !isHiddenSystemField(f),
- ).length;
- return {
- key: item.nameSingular,
- name: item.labelPlural,
- icon: item.icon ?? undefined,
- secondary: t`${fieldsCount} fields`,
- link: getSettingsPath(SettingsPath.ObjectDetail, {
- objectNamePlural: item.namePlural,
- }),
- };
- })
- : (manifestContent?.objects ?? []).map((appObject) => ({
- key: appObject.nameSingular,
- name: appObject.labelPlural,
- icon: appObject.icon ?? undefined,
- secondary: t`${appObject.fields.length} fields`,
- }));
-
- const fieldRows: ApplicationContentRow[] = isDefined(installedApplication)
- ? objectMetadataItems
- .filter(
- (item) =>
- !installedObjectIds.has(item.id) &&
- !FIELD_GROUP_DENY_LIST.has(item.nameSingular),
- )
- .flatMap((item) =>
- item.fields
- .filter((field) => field.applicationId === installedApplication.id)
- .map((field) => ({
- key: `${item.id}-${field.id}`,
- name: field.label,
- applicationId: item?.applicationId ?? undefined,
- icon: field.icon ?? undefined,
- secondary: t`on ${item.labelSingular}`,
- link: getSettingsPath(SettingsPath.ObjectFieldEdit, {
- objectNamePlural: item.namePlural,
- fieldName: field.name,
- }),
- })),
- )
- : (() => {
- const manifestFields = manifestContent?.fields ?? [];
- const manifestObjectByUid = new Map(
- (manifestContent?.objects ?? []).map((obj) => [
- obj.universalIdentifier,
- obj,
- ]),
- );
-
- return manifestFields
- .map((field) => {
- const appObject = manifestObjectByUid.get(
- field.objectUniversalIdentifier,
- );
-
- if (isDefined(appObject)) {
- return {
- key: `${appObject.nameSingular}-${field.universalIdentifier}`,
- name: field.label ?? field.name,
- icon: field.icon ?? undefined,
- secondary: t`on ${appObject.labelSingular}`,
- };
- }
-
- const objectMetadataItem = objectMetadataItems.find(
- (item) =>
- item.universalIdentifier === field.objectUniversalIdentifier,
- );
-
- if (!isDefined(objectMetadataItem)) {
- return undefined;
- }
-
- return {
- key: `${objectMetadataItem.nameSingular}-${field.universalIdentifier}`,
- name: field.label ?? field.name,
- icon: field.icon ?? undefined,
- secondary: t`on ${objectMetadataItem.labelSingular}`,
- };
- })
- .filter(isDefined);
- })();
-
- return { objectRows, fieldRows };
-};
diff --git a/packages/twenty-front/src/modules/settings/applications/types/ApplicationContentRow.ts b/packages/twenty-front/src/modules/settings/applications/types/ApplicationContentRow.ts
deleted file mode 100644
index 1c2a8298df3..00000000000
--- a/packages/twenty-front/src/modules/settings/applications/types/ApplicationContentRow.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-export type ApplicationContentRow = {
- key: string;
- name: string;
- applicationId?: string;
- icon?: string;
- secondary?: string;
- link?: string;
-};
diff --git a/packages/twenty-front/src/modules/settings/applications/utils/__tests__/buildFieldMetadataItemFromMarketplaceField.test.ts b/packages/twenty-front/src/modules/settings/applications/utils/__tests__/buildFieldMetadataItemFromMarketplaceField.test.ts
deleted file mode 100644
index 549a13d7397..00000000000
--- a/packages/twenty-front/src/modules/settings/applications/utils/__tests__/buildFieldMetadataItemFromMarketplaceField.test.ts
+++ /dev/null
@@ -1,28 +0,0 @@
-import { buildFieldMetadataItemFromMarketplaceField } from '@/settings/applications/utils/buildFieldMetadataItemFromMarketplaceField';
-
-import { type ObjectFieldManifest } from 'twenty-shared/application';
-import { FieldMetadataType } from 'twenty-shared/types';
-
-const marketplaceField: ObjectFieldManifest = {
- universalIdentifier: '20202020-1111-4111-8111-111111111111',
- name: 'companyName',
- label: 'Company name',
- type: FieldMetadataType.TEXT,
-};
-
-describe('buildFieldMetadataItemFromMarketplaceField', () => {
- it('uses the canonical field icon when the app does not provide one', () => {
- expect(
- buildFieldMetadataItemFromMarketplaceField(marketplaceField).icon,
- ).toBe('IconListDetails');
- });
-
- it('preserves the icon provided by the app', () => {
- expect(
- buildFieldMetadataItemFromMarketplaceField({
- ...marketplaceField,
- icon: 'IconBuilding',
- }).icon,
- ).toBe('IconBuilding');
- });
-});
diff --git a/packages/twenty-front/src/modules/settings/applications/utils/buildFieldMetadataItemFromMarketplaceField.ts b/packages/twenty-front/src/modules/settings/applications/utils/buildFieldMetadataItemFromMarketplaceField.ts
deleted file mode 100644
index 54a1e856005..00000000000
--- a/packages/twenty-front/src/modules/settings/applications/utils/buildFieldMetadataItemFromMarketplaceField.ts
+++ /dev/null
@@ -1,33 +0,0 @@
-import { type FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
-
-import { type ObjectFieldManifest } from 'twenty-shared/application';
-import { v4 as uuidv4 } from 'uuid';
-import { FieldMetadataType } from '~/generated-metadata/graphql';
-
-export const buildFieldMetadataItemFromMarketplaceField = (
- field: ObjectFieldManifest,
-): FieldMetadataItem => {
- const now = new Date().toISOString();
- const universalIdentifier = field.universalIdentifier ?? uuidv4();
-
- return {
- id: universalIdentifier,
- universalIdentifier,
- name: field.name,
- label: field.label,
- type: (field.type as FieldMetadataType) ?? FieldMetadataType.TEXT,
- description: field.description ?? '',
- icon: field.icon ?? 'IconListDetails',
- isActive: true,
- isSystem: false,
- isNullable: true,
- isUnique: false,
- isUIEditable: true,
- createdAt: now,
- updatedAt: now,
- defaultValue: null,
- options: null,
- relation: null,
- settings: null,
- };
-};
diff --git a/packages/twenty-front/src/modules/settings/roles/role-permissions/components/SettingsRolePermissions.tsx b/packages/twenty-front/src/modules/settings/roles/role-permissions/components/SettingsRolePermissions.tsx
index ec40f0d1bcc..6124b37d549 100644
--- a/packages/twenty-front/src/modules/settings/roles/role-permissions/components/SettingsRolePermissions.tsx
+++ b/packages/twenty-front/src/modules/settings/roles/role-permissions/components/SettingsRolePermissions.tsx
@@ -1,4 +1,3 @@
-import { type EnrichedObjectMetadataItem } from '@/object-metadata/types/EnrichedObjectMetadataItem';
import { SettingsRolePermissionsObjectLevelSection } from '@/settings/roles/role-permissions/object-level-permissions/components/SettingsRolePermissionsObjectLevelSection';
import { SettingsRolePermissionsObjectsSection } from '@/settings/roles/role-permissions/objects-permissions/components/SettingsRolePermissionsObjectsSection';
import { SettingsRolePermissionsSettingsSection } from '@/settings/roles/role-permissions/permission-flags/components/SettingsRolePermissionsSettingsSection';
@@ -17,14 +16,12 @@ type SettingsRolePermissionsProps = {
roleId: string;
isEditable: boolean;
fromAgentId?: string;
- objectMetadataItemsFromMarketplaceApp?: EnrichedObjectMetadataItem[];
};
export const SettingsRolePermissions = ({
roleId,
isEditable,
fromAgentId,
- objectMetadataItemsFromMarketplaceApp,
}: SettingsRolePermissionsProps) => {
return (
<StyledRolePermissionsContainer>
@@ -37,9 +34,6 @@ export const SettingsRolePermissions = ({
roleId={roleId}
fromAgentId={fromAgentId}
isEditable={isEditable}
- objectMetadataItemsFromMarketplaceApp={
- objectMetadataItemsFromMarketplaceApp
- }
/>
<SettingsRolePermissionsSettingsSection
roleId={roleId}
diff --git a/packages/twenty-front/src/modules/settings/roles/role-permissions/object-level-permissions/components/SettingsRolePermissionsObjectLevelSection.tsx b/packages/twenty-front/src/modules/settings/roles/role-permissions/object-level-permissions/components/SettingsRolePermissionsObjectLevelSection.tsx
index fb0411602b1..c39c0de6565 100644
--- a/packages/twenty-front/src/modules/settings/roles/role-permissions/object-level-permissions/components/SettingsRolePermissionsObjectLevelSection.tsx
+++ b/packages/twenty-front/src/modules/settings/roles/role-permissions/object-level-permissions/components/SettingsRolePermissionsObjectLevelSection.tsx
@@ -1,4 +1,3 @@
-import { type EnrichedObjectMetadataItem } from '@/object-metadata/types/EnrichedObjectMetadataItem';
import { SettingsRolePermissionsObjectLevelTableHeader } from '@/settings/roles/role-permissions/object-level-permissions/components/SettingsRolePermissionsObjectLevelTableHeader';
import { SettingsRolePermissionsObjectLevelTableRow } from '@/settings/roles/role-permissions/object-level-permissions/components/SettingsRolePermissionsObjectLevelTableRow';
import { useFilterObjectMetadataItemsWithPermissionOverride } from '@/settings/roles/role-permissions/object-level-permissions/hooks/useFilterObjectWithPermissionOverride';
@@ -9,7 +8,6 @@ import { useAtomFamilyStateValue } from '@/ui/utilities/state/jotai/hooks/useAto
import { TableCell } from '@/ui/layout/table/components/TableCell';
import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
-import { useMemo } from 'react';
import { SettingsPath } from 'twenty-shared/types';
import { isDefined } from 'twenty-shared/utils';
import { Section } from 'twenty-ui/components/layout';
@@ -37,14 +35,12 @@ type SettingsRolePermissionsObjectLevelSectionProps = {
roleId: string;
isEditable: boolean;
fromAgentId?: string;
- objectMetadataItemsFromMarketplaceApp?: EnrichedObjectMetadataItem[];
};
export const SettingsRolePermissionsObjectLevelSection = ({
roleId,
fromAgentId,
isEditable,
- objectMetadataItemsFromMarketplaceApp,
}: SettingsRolePermissionsObjectLevelSectionProps) => {
const navigateSettings = useNavigateSettings();
@@ -56,45 +52,19 @@ export const SettingsRolePermissionsObjectLevelSection = ({
const { objectMetadataItemsThatCanHavePermission } =
useObjectMetadataItemsThatCanHavePermission();
- const allObjectMetadataItems = useMemo(() => {
- if (
- !isDefined(objectMetadataItemsFromMarketplaceApp) ||
- objectMetadataItemsFromMarketplaceApp.length === 0
- ) {
- return objectMetadataItemsThatCanHavePermission;
- }
-
- const existingIds = new Set(
- objectMetadataItemsThatCanHavePermission.map((item) => item.id),
- );
-
- const additionalObjectMetadataItemsFromApp =
- objectMetadataItemsFromMarketplaceApp.filter(
- (item) => !existingIds.has(item.id),
- );
-
- return [
- ...objectMetadataItemsThatCanHavePermission,
- ...additionalObjectMetadataItemsFromApp,
- ];
- }, [
- objectMetadataItemsThatCanHavePermission,
- objectMetadataItemsFromMarketplaceApp,
- ]);
-
const { filterObjectMetadataItemsWithPermissionOverride } =
useFilterObjectMetadataItemsWithPermissionOverride({
roleId,
});
const objectMetadataItemsWithPermissionOverride =
- allObjectMetadataItems.filter(
+ objectMetadataItemsThatCanHavePermission.filter(
filterObjectMetadataItemsWithPermissionOverride,
);
const allObjectsHaveSetPermission =
objectMetadataItemsWithPermissionOverride.length ===
- allObjectMetadataItems.length;
+ objectMetadataItemsThatCanHavePermission.length;
const handleAddRule = () => {
navigateSettings(
diff --git a/packages/twenty-front/src/pages/settings/applications/SettingsAvailableApplicationDetails.tsx b/packages/twenty-front/src/pages/settings/applications/SettingsAvailableApplicationDetails.tsx
index 1eede489784..1dfa4218ecd 100644
--- a/packages/twenty-front/src/pages/settings/applications/SettingsAvailableApplicationDetails.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/SettingsAvailableApplicationDetails.tsx
@@ -8,38 +8,23 @@ import { SettingsApplicationActionButton } from '@/settings/applications/compone
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
import { SettingsSectionSkeletonLoader } from '@/settings/components/SettingsSectionSkeletonLoader';
import { SettingsPageLayout } from '@/settings/components/layout/SettingsPageLayout';
-import { SettingsTabBar } from '@/settings/components/layout/SettingsTabBar';
import { useHasPermissionFlag } from '@/settings/roles/hooks/useHasPermissionFlag';
-import { activeTabIdComponentState } from '@/ui/layout/tab-list/states/activeTabIdComponentState';
-import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { useQuery } from '@apollo/client/react';
import { t } from '@lingui/core/macro';
import { useCallback } from 'react';
import { useParams } from 'react-router-dom';
-import { type Manifest } from 'twenty-shared/application';
import { SettingsPath } from 'twenty-shared/types';
import { getSettingsPath, isDefined } from 'twenty-shared/utils';
import { InlineBanner } from 'twenty-ui/components/feedback';
-import {
- IconBox,
- IconEyeOff,
- IconInfoSquareRounded,
- IconLock,
-} from 'twenty-ui/icon';
+import { IconEyeOff } from 'twenty-ui/icon';
import {
ApplicationRegistrationSourceType,
FindMarketplaceAppDetailDocument,
- FindMarketplaceAppManifestDocument,
FindOneApplicationByUniversalIdentifierDocument,
- FindOneApplicationDocument,
PermissionFlagType,
} from '~/generated-metadata/graphql';
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
-import { SettingsApplicationDetailAboutTab } from '~/pages/settings/applications/tabs/SettingsApplicationDetailAboutTab';
-import { SettingsApplicationDetailContentTab } from '~/pages/settings/applications/tabs/SettingsApplicationDetailContentTab';
-import { SettingsApplicationPermissionsTab } from '~/pages/settings/applications/tabs/SettingsApplicationPermissionsTab';
-
-const AVAILABLE_APPLICATION_DETAIL_ID = 'available-application-detail';
+import { SettingsApplicationDetailAbout } from '~/pages/settings/applications/components/SettingsApplicationDetailAbout';
export const SettingsAvailableApplicationDetails = () => {
const { availableApplicationId = '' } = useParams<{
@@ -84,27 +69,9 @@ export const SettingsAvailableApplicationDetails = () => {
skip: !availableApplicationId,
});
- const { data: manifestData } = useQuery(FindMarketplaceAppManifestDocument, {
- variables: { universalIdentifier: availableApplicationId },
- skip: !availableApplicationId,
- });
-
const application = applicationData?.findOneApplication;
- const { data: installedApplicationData } = useQuery(
- FindOneApplicationDocument,
- {
- variables: { id: application?.id ?? '' },
- skip: !application?.id,
- },
- );
-
- const installedApplication = installedApplicationData?.findOneApplication;
-
const detail = detailData?.findMarketplaceAppDetail;
- const manifest = manifestData?.findMarketplaceAppDetail?.manifest as
- | Manifest
- | undefined;
const displayName = detail?.name ?? t`Application details`;
@@ -121,77 +88,6 @@ export const SettingsAvailableApplicationDetails = () => {
const defaultRole = getMarketplaceAppDefaultRoleManifest(detail);
- const activeTabId = useAtomComponentStateValue(
- activeTabIdComponentState,
- AVAILABLE_APPLICATION_DETAIL_ID,
- );
-
- const tabs = [
- { id: 'about', title: t`About`, Icon: IconInfoSquareRounded },
- { id: 'content', title: t`Content`, Icon: IconBox },
- { id: 'permissions', title: t`Permissions`, Icon: IconLock },
- ];
-
- const renderActiveTabContent = () => {
- if (!isDefined(detail)) {
- return <SettingsSectionSkeletonLoader />;
- }
-
- switch (activeTabId) {
- case 'about':
- return (
- <SettingsApplicationDetailAboutTab
- applicationId={application?.id}
- logoUrl={detail.logoUrl}
- displayName={displayName}
- description={detail.description ?? undefined}
- aboutDescription={detail.aboutDescription ?? undefined}
- pricingDescription={detail.pricingDescription ?? undefined}
- billsCredits={detail.billsCredits}
- screenshots={detail.galleryImages}
- author={detail.author ?? undefined}
- version={currentVersion ?? latestAvailableVersion ?? undefined}
- installCount={detail.installCount}
- category={detail.category ?? undefined}
- developerLinks={{
- websiteUrl: detail.websiteUrl ?? undefined,
- termsUrl: detail.termsUrl ?? undefined,
- emailSupport: detail.emailSupport ?? undefined,
- issueReportUrl: detail.issueReportUrl ?? undefined,
- sourcePackageUrl,
- }}
- onShare={() => copyMarketplaceAppLink(detail.universalIdentifier)}
- />
- );
- case 'content':
- return (
- <SettingsApplicationDetailContentTab
- applicationId={
- installedApplication?.id ?? detail.universalIdentifier
- }
- installedApplication={installedApplication ?? undefined}
- manifestContent={manifest}
- applicationInfo={{
- id: installedApplication?.id,
- name: displayName,
- logoUrl: detail.logoUrl,
- universalIdentifier: detail.universalIdentifier,
- }}
- />
- );
- case 'permissions':
- return (
- <SettingsApplicationPermissionsTab
- marketplaceAppDefaultRole={defaultRole}
- marketplaceAppObjects={manifest?.objects}
- />
- );
-
- default:
- return null;
- }
- };
-
return (
<CurrentApplicationContext.Provider value={application?.id ?? null}>
<SettingsPageLayout
@@ -231,13 +127,6 @@ export const SettingsAvailableApplicationDetails = () => {
/>
) : undefined
}
- secondaryBar={
- <SettingsTabBar
- aria-label={t`Available application details`}
- tabs={tabs}
- componentInstanceId={AVAILABLE_APPLICATION_DETAIL_ID}
- />
- }
>
<SettingsPageContainer overflow="visible">
{isUnlisted && (
@@ -245,7 +134,32 @@ export const SettingsAvailableApplicationDetails = () => {
icon={<IconEyeOff aria-hidden="true" />}
>{t`Application not listed on the marketplace. It was shared via a direct link`}</InlineBanner>
)}
- {renderActiveTabContent()}
+ {isDefined(detail) ? (
+ <SettingsApplicationDetailAbout
+ applicationId={application?.id}
+ logoUrl={detail.logoUrl}
+ displayName={displayName}
+ description={detail.description ?? undefined}
+ aboutDescription={detail.aboutDescription ?? undefined}
+ pricingDescription={detail.pricingDescription ?? undefined}
+ billsCredits={detail.billsCredits}
+ screenshots={detail.galleryImages}
+ author={detail.author ?? undefined}
+ version={currentVersion ?? latestAvailableVersion ?? undefined}
+ installCount={detail.installCount}
+ category={detail.category ?? undefined}
+ developerLinks={{
+ websiteUrl: detail.websiteUrl ?? undefined,
+ termsUrl: detail.termsUrl ?? undefined,
+ emailSupport: detail.emailSupport ?? undefined,
+ issueReportUrl: detail.issueReportUrl ?? undefined,
+ sourcePackageUrl,
+ }}
+ onShare={() => copyMarketplaceAppLink(detail.universalIdentifier)}
+ />
+ ) : (
+ <SettingsSectionSkeletonLoader />
+ )}
</SettingsPageContainer>
</SettingsPageLayout>
<SettingsApplicationInstallPermissionValidationModal
diff --git a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationContentSubtable.tsx b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationContentSubtable.tsx
deleted file mode 100644
index f9012a100f9..00000000000
--- a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationContentSubtable.tsx
+++ /dev/null
@@ -1,86 +0,0 @@
-import { AppChip } from '@/applications/components/AppChip';
-import { type ApplicationContentRow } from '@/settings/applications/types/ApplicationContentRow';
-import {
- StyledActionTableCell,
- 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';
-import { TableSection } from '@/ui/layout/table/components/TableSection';
-import { isDefined } from 'twenty-shared/utils';
-import { OverflowingTextWithTooltip } from 'twenty-ui/primitives/typography';
-import { IconChevronRight, useIcons } from 'twenty-ui/icon';
-import { useTheme, themeCssVariables } from 'twenty-ui/theme';
-
-const GRID_TEMPLATE_COLUMNS = '200px 1fr 160px 32px';
-
-export const SettingsApplicationContentSubtable = ({
- title,
- rows,
- applicationId,
- fallbackApplicationData,
-}: {
- title: string;
- rows: ApplicationContentRow[];
- applicationId?: string;
- fallbackApplicationData?: {
- logoUrl?: string | null;
- name?: string | null;
- };
-}) => {
- const theme = useTheme();
- const { getIcon } = useIcons();
-
- if (rows.length === 0) {
- return null;
- }
-
- return (
- <TableSection title={title}>
- {rows.map((row) => {
- const Icon = getIcon(row.icon);
-
- return (
- <TableRow
- key={row.key}
- gridAutoColumns={GRID_TEMPLATE_COLUMNS}
- to={row.link}
- >
- <StyledNameTableCell minWidth="0" overflow="hidden">
- {isDefined(Icon) && (
- <Icon size={theme.icon.size.md} stroke={theme.icon.stroke.sm} />
- )}
- <OverflowingTextWithTooltip text={row.name} />
- </StyledNameTableCell>
- <StyledNameTableCell minWidth="0" overflow="hidden" align={'right'}>
- <AppChip
- applicationId={row.applicationId ?? applicationId}
- fallbackApplicationData={fallbackApplicationData}
- />
- </StyledNameTableCell>
- <TableCell
- align="right"
- color={themeCssVariables.font.color.secondary}
- minWidth="0"
- overflow="hidden"
- whiteSpace="nowrap"
- >
- {isDefined(row.secondary) && (
- <OverflowingTextWithTooltip text={row.secondary} />
- )}
- </TableCell>
- <StyledActionTableCell>
- {isDefined(row.link) && (
- <IconChevronRight
- size={theme.icon.size.md}
- stroke={theme.icon.stroke.sm}
- color={theme.font.color.light}
- />
- )}
- </StyledActionTableCell>
- </TableRow>
- );
- })}
- </TableSection>
- );
-};
diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationDetailAboutTab.tsx b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationDetailAbout.tsx
similarity index 97%
rename from packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationDetailAboutTab.tsx
rename to packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationDetailAbout.tsx
index e33ed61e3e2..d1fc64797c4 100644
--- a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationDetailAboutTab.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationDetailAbout.tsx
@@ -11,7 +11,7 @@ import { isDefined } from 'twenty-shared/utils';
import { themeCssVariables } from 'twenty-ui/theme';
import { getApplicationDescriptionSummary } from '~/pages/settings/applications/utils/getApplicationDescriptionSummary';
-type SettingsApplicationDetailAboutTabProps = {
+type SettingsApplicationDetailAboutProps = {
applicationId?: string | null;
logoUrl?: string | null;
displayName: string;
@@ -126,7 +126,7 @@ const StyledMarkdownContent = styled.div`
}
`;
-export const SettingsApplicationDetailAboutTab = ({
+export const SettingsApplicationDetailAbout = ({
applicationId,
logoUrl,
displayName,
@@ -141,7 +141,7 @@ export const SettingsApplicationDetailAboutTab = ({
category,
developerLinks,
onShare,
-}: SettingsApplicationDetailAboutTabProps) => {
+}: SettingsApplicationDetailAboutProps) => {
const hasScreenshots = isDefined(screenshots) && screenshots.length > 0;
const descriptionSummary = getApplicationDescriptionSummary(description);
diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/__tests__/SettingsApplicationDetailAboutTab.test.tsx b/packages/twenty-front/src/pages/settings/applications/components/__tests__/SettingsApplicationDetailAbout.test.tsx
similarity index 90%
rename from packages/twenty-front/src/pages/settings/applications/tabs/__tests__/SettingsApplicationDetailAboutTab.test.tsx
rename to packages/twenty-front/src/pages/settings/applications/components/__tests__/SettingsApplicationDetailAbout.test.tsx
index bf9d7cf1bbf..1537461044c 100644
--- a/packages/twenty-front/src/pages/settings/applications/tabs/__tests__/SettingsApplicationDetailAboutTab.test.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/components/__tests__/SettingsApplicationDetailAbout.test.tsx
@@ -4,7 +4,7 @@ import { render, screen, waitFor, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { type DeveloperLinks } from '@/settings/applications/components/SettingsApplicationAboutSidebar';
-import { SettingsApplicationDetailAboutTab } from '~/pages/settings/applications/tabs/SettingsApplicationDetailAboutTab';
+import { SettingsApplicationDetailAbout } from '~/pages/settings/applications/components/SettingsApplicationDetailAbout';
jest.mock('@/ai/components/LazyMarkdownRenderer', () => ({
LazyMarkdownRenderer: ({
@@ -36,7 +36,7 @@ const DEVELOPER_LINKS: DeveloperLinks = {
sourcePackageUrl: 'https://www.npmjs.com/package/stripe-app',
};
-type RenderAboutTabOptions = {
+type RenderAboutOptions = {
aboutDescription?: string | null;
billsCredits?: boolean;
description?: string | null;
@@ -46,17 +46,17 @@ type RenderAboutTabOptions = {
};
// null opts out of a default, undefined keeps it.
-const renderAboutTab = ({
+const renderAbout = ({
aboutDescription = ABOUT_DESCRIPTION,
billsCredits = false,
description = SHORT_DESCRIPTION,
developerLinks = DEVELOPER_LINKS,
installCount = 7,
onShare = jest.fn(),
-}: RenderAboutTabOptions = {}) =>
+}: RenderAboutOptions = {}) =>
render(
<I18nProvider i18n={i18n}>
- <SettingsApplicationDetailAboutTab
+ <SettingsApplicationDetailAbout
displayName="Stripe"
description={description ?? undefined}
aboutDescription={aboutDescription ?? undefined}
@@ -76,15 +76,15 @@ const renderAboutTab = ({
</I18nProvider>,
);
-describe('SettingsApplicationDetailAboutTab', () => {
+describe('SettingsApplicationDetailAbout', () => {
it('hides the install count when nobody installed the application', () => {
- renderAboutTab({ installCount: 0 });
+ renderAbout({ installCount: 0 });
expect(screen.queryByText(/installs?$/)).not.toBeInTheDocument();
});
it('estimates large install counts and reveals the exact count on hover', async () => {
- renderAboutTab({ installCount: 1098 });
+ renderAbout({ installCount: 1098 });
const estimatedInstallCount = screen.getByText('+1,000 installs');
@@ -97,7 +97,7 @@ describe('SettingsApplicationDetailAboutTab', () => {
});
it('shows that the application bills credits, with its pricing on hover', async () => {
- renderAboutTab({ billsCredits: true });
+ renderAbout({ billsCredits: true });
await userEvent.setup().hover(screen.getByText('Bills credits'));
@@ -105,13 +105,13 @@ describe('SettingsApplicationDetailAboutTab', () => {
});
it('does not claim credit billing for an application that bills none', () => {
- renderAboutTab();
+ renderAbout();
expect(screen.queryByText('Bills credits')).not.toBeInTheDocument();
});
it('renders the application identity, metadata and resources', () => {
- renderAboutTab();
+ renderAbout();
expect(screen.getByText('Stripe')).toBeVisible();
expect(screen.getByText(SHORT_DESCRIPTION)).toBeVisible();
@@ -151,7 +151,7 @@ describe('SettingsApplicationDetailAboutTab', () => {
it('shows the selected screenshot and lets the user switch it', async () => {
const user = userEvent.setup();
- renderAboutTab();
+ renderAbout();
expect(screen.getByAltText('Stripe screenshot 1')).toHaveAttribute(
'src',
@@ -169,7 +169,7 @@ describe('SettingsApplicationDetailAboutTab', () => {
it('opens the screenshots in full screen and navigates between them', async () => {
const user = userEvent.setup();
- renderAboutTab();
+ renderAbout();
await user.click(
screen.getByRole('button', { name: 'View screenshot in full screen' }),
@@ -200,7 +200,7 @@ describe('SettingsApplicationDetailAboutTab', () => {
const user = userEvent.setup();
const onShare = jest.fn();
- renderAboutTab({ onShare });
+ renderAbout({ onShare });
await user.click(screen.getByRole('button', { name: /^Share\b/ }));
@@ -208,7 +208,7 @@ describe('SettingsApplicationDetailAboutTab', () => {
});
it('hides the share button when the application cannot be shared', () => {
- renderAboutTab({ onShare: null });
+ renderAbout({ onShare: null });
expect(
screen.queryByRole('button', { name: /^Share\b/ }),
@@ -216,7 +216,7 @@ describe('SettingsApplicationDetailAboutTab', () => {
});
it('skips resource links that are not http, https or mailto', () => {
- renderAboutTab({ developerLinks: { websiteUrl: 'ftp://stripe.com' } });
+ renderAbout({ developerLinks: { websiteUrl: 'ftp://stripe.com' } });
expect(screen.queryByText('Resources')).not.toBeInTheDocument();
expect(
@@ -225,14 +225,14 @@ describe('SettingsApplicationDetailAboutTab', () => {
});
it('does not repeat the short description as the about content', () => {
- renderAboutTab({ aboutDescription: null });
+ renderAbout({ aboutDescription: null });
expect(screen.getByText(SHORT_DESCRIPTION)).toBeVisible();
expect(screen.queryByTestId('markdown-renderer')).not.toBeInTheDocument();
});
it('renders a long description as the about content and summarizes it in the sidebar', () => {
- renderAboutTab({
+ renderAbout({
aboutDescription: null,
description:
'Host your workspace customizations.\n\n#### What it includes\n\nEverything you build on top of the standard app.',
@@ -247,7 +247,7 @@ describe('SettingsApplicationDetailAboutTab', () => {
});
it('shows a placeholder when the application has no description at all', () => {
- renderAboutTab({ aboutDescription: null, description: null });
+ renderAbout({ aboutDescription: null, description: null });
expect(screen.getByTestId('markdown-renderer')).toHaveTextContent(
'No description available for this application',
diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationDetailContentTab.tsx b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationDetailContentTab.tsx
deleted file mode 100644
index bd3090626ea..00000000000
--- a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationDetailContentTab.tsx
+++ /dev/null
@@ -1,343 +0,0 @@
-import { type ApplicationDisplayData } from '@/applications/types/ApplicationDisplayData';
-import { getLogicFunctionTriggerLabel } from '@/logic-functions/utils/getLogicFunctionTriggerLabel';
-import { useComputeApplicationContentForLayoutAndLogic } from '@/settings/applications/hooks/useComputeApplicationContentForLayoutAndLogic';
-import { useComputeObjectAndFieldsContentForApplication } from '@/settings/applications/hooks/useComputeObjectAndFieldsContentForApplication';
-import { Table } from '@/ui/layout/table/components/Table';
-import { useLingui } from '@lingui/react/macro';
-import { useState } from 'react';
-import { type Manifest } from 'twenty-shared/application';
-import { SettingsPath } from 'twenty-shared/types';
-import { getSettingsPath, isDefined } from 'twenty-shared/utils';
-import { SearchInput } from 'twenty-ui/components/input';
-import { Section } from 'twenty-ui/components/layout';
-import { type Application } from '~/generated-metadata/graphql';
-import { SettingsApplicationContentSubtable } from '~/pages/settings/applications/components/SettingsApplicationContentSubtable';
-import { type ApplicationContentRow } from '@/settings/applications/types/ApplicationContentRow';
-import { useInstalledTimelineActivityTypes } from '~/pages/settings/applications/hooks/useInstalledTimelineActivityTypes';
-import { filterSettingsApplicationTimelineActivityTypes } from '~/pages/settings/applications/utils/filterSettingsApplicationTimelineActivityTypes';
-import { getSettingsApplicationTimelineActivityTypes } from '~/pages/settings/applications/utils/getSettingsApplicationTimelineActivityTypes';
-import { normalizeSearchText } from 'twenty-ui/utilities';
-
-type InstalledApplicationForContentTab = Omit<
- Application,
- 'objects' | 'frontComponents' | 'commandMenuItems' | 'settingsMenuItems'
-> & {
- objects: { id: string }[];
- frontComponents?: {
- id: string;
- name: string;
- description?: string | null;
- }[];
- commandMenuItems?: {
- id: string;
- label: string;
- shortLabel?: string | null;
- }[];
-};
-
-type SettingsApplicationDetailContentTabProps = {
- applicationId: string;
- installedApplication?: InstalledApplicationForContentTab;
- manifestContent?: Manifest;
- applicationInfo: ApplicationDisplayData;
-};
-
-const filterRows = (rows: ApplicationContentRow[], normalizedSearch: string) =>
- normalizedSearch === ''
- ? rows
- : rows.filter(
- (row) =>
- normalizeSearchText(row.name).includes(normalizedSearch) ||
- (isDefined(row.secondary) &&
- normalizeSearchText(row.secondary).includes(normalizedSearch)),
- );
-
-export const SettingsApplicationDetailContentTab = ({
- applicationId,
- installedApplication,
- manifestContent,
- applicationInfo,
-}: SettingsApplicationDetailContentTabProps) => {
- const { t } = useLingui();
- const isInstalledApplication = isDefined(installedApplication);
-
- const { installedTimelineActivityTypes } = useInstalledTimelineActivityTypes({
- isInstalledApplication,
- });
-
- const { objectRows, fieldRows } =
- useComputeObjectAndFieldsContentForApplication({
- installedApplication,
- manifestContent,
- });
-
- const {
- pageLayoutRows,
- viewRows,
- navigationMenuItemRows,
- agentRows,
- skillRows,
- roleRows,
- connectionProviderRows,
- } = useComputeApplicationContentForLayoutAndLogic({
- installedApplication,
- manifestContent,
- });
-
- const fallbackApplicationData = {
- logoUrl: applicationInfo?.logoUrl,
- name: applicationInfo?.name,
- };
-
- const lifecycleOptions = {
- postInstallUniversalIdentifier:
- manifestContent?.application?.postInstallLogicFunction
- ?.universalIdentifier,
- preInstallUniversalIdentifier:
- manifestContent?.application?.preInstallLogicFunction
- ?.universalIdentifier,
- uninstallUniversalIdentifier:
- manifestContent?.application?.uninstallLogicFunction?.universalIdentifier,
- };
-
- const logicFunctionRows: ApplicationContentRow[] = isDefined(
- installedApplication,
- )
- ? (installedApplication.logicFunctions ?? []).map((lf) => ({
- key: lf.id,
- name: lf.name,
- secondary: getLogicFunctionTriggerLabel(lf, lifecycleOptions),
- link: getSettingsPath(SettingsPath.ApplicationLogicFunctionDetail, {
- applicationId,
- logicFunctionId: lf.id,
- }),
- }))
- : (manifestContent?.logicFunctions ?? []).map((lf) => ({
- key: lf.universalIdentifier,
- name: lf.name ?? lf.universalIdentifier,
- secondary: getLogicFunctionTriggerLabel(lf, lifecycleOptions),
- }));
-
- const frontComponentRows: ApplicationContentRow[] = isDefined(
- installedApplication,
- )
- ? (installedApplication.frontComponents ?? []).map((fc) => ({
- key: fc.id,
- name: fc.name,
- secondary: fc.description ?? undefined,
- link: getSettingsPath(SettingsPath.ApplicationFrontComponentDetail, {
- applicationId,
- frontComponentId: fc.id,
- }),
- }))
- : (manifestContent?.frontComponents ?? []).map((fc) => ({
- key: fc.universalIdentifier,
- name: fc.name ?? fc.universalIdentifier,
- secondary: fc.description ?? undefined,
- }));
-
- const commandMenuItemRows: ApplicationContentRow[] = isDefined(
- installedApplication,
- )
- ? (installedApplication.commandMenuItems ?? []).map((item) => ({
- key: item.id,
- name: item.label,
- secondary: item.shortLabel ?? undefined,
- link: getSettingsPath(SettingsPath.ApplicationCommandMenuItemDetail, {
- applicationId,
- commandMenuItemId: item.id,
- }),
- }))
- : (manifestContent?.commandMenuItems ?? []).map((item) => ({
- key: item.universalIdentifier,
- name: item.label,
- secondary: item.shortLabel ?? undefined,
- }));
-
- const [searchTerm, setSearchTerm] = useState('');
- const normalizedSearch = normalizeSearchText(searchTerm);
-
- const timelineActivityTypes = getSettingsApplicationTimelineActivityTypes({
- applicationId,
- isInstalledApplication,
- installedTimelineActivityTypes,
- manifestTimelineActivityTypes: manifestContent?.timelineActivityTypes ?? [],
- });
- const filteredTimelineActivityTypes =
- filterSettingsApplicationTimelineActivityTypes({
- timelineActivityTypes,
- searchTerm,
- });
- const timelineActivityTypeRows: ApplicationContentRow[] =
- filteredTimelineActivityTypes.map((timelineActivityType) => ({
- key: timelineActivityType.id,
- name: timelineActivityType.label,
- icon: timelineActivityType.icon ?? undefined,
- secondary: isDefined(timelineActivityType.action)
- ? `${timelineActivityType.name} · ${timelineActivityType.action}`
- : timelineActivityType.name,
- link: isInstalledApplication
- ? getSettingsPath(SettingsPath.ApplicationTimelineActivityTypeDetail, {
- applicationId,
- timelineActivityTypeId: timelineActivityType.id,
- })
- : undefined,
- }));
-
- const filtered = {
- objects: filterRows(objectRows, normalizedSearch),
- fields: filterRows(fieldRows, normalizedSearch),
- pageLayouts: filterRows(pageLayoutRows, normalizedSearch),
- views: filterRows(viewRows, normalizedSearch),
- navigation: filterRows(navigationMenuItemRows, normalizedSearch),
- frontComponents: filterRows(frontComponentRows, normalizedSearch),
- commandMenuItems: filterRows(commandMenuItemRows, normalizedSearch),
- logicFunctions: filterRows(logicFunctionRows, normalizedSearch),
- agents: filterRows(agentRows, normalizedSearch),
- skills: filterRows(skillRows, normalizedSearch),
- roles: filterRows(roleRows, normalizedSearch),
- connectionProviders: filterRows(connectionProviderRows, normalizedSearch),
- };
-
- const hasData = filtered.objects.length > 0 || filtered.fields.length > 0;
- const hasLayout =
- filtered.pageLayouts.length > 0 ||
- filtered.views.length > 0 ||
- filtered.navigation.length > 0 ||
- filtered.frontComponents.length > 0 ||
- filtered.commandMenuItems.length > 0;
- const hasLogic =
- filtered.logicFunctions.length > 0 ||
- filtered.agents.length > 0 ||
- filtered.skills.length > 0 ||
- filtered.roles.length > 0 ||
- filtered.connectionProviders.length > 0 ||
- timelineActivityTypeRows.length > 0;
-
- if (!hasData && !hasLayout && !hasLogic && normalizedSearch === '') {
- return null;
- }
-
- return (
- <>
- <Section.Root>
- <SearchInput
- placeholder={t`Search...`}
- value={searchTerm}
- onValueChange={setSearchTerm}
- />
- </Section.Root>
-
- {hasData && (
- <Section.Root>
- <Section.Header
- title={t`Data`}
- description={t`Schema this app contributes to your workspace`}
- />
- <Table>
- <SettingsApplicationContentSubtable
- title={t`Objects`}
- rows={filtered.objects}
- applicationId={applicationId}
- fallbackApplicationData={fallbackApplicationData}
- />
- <SettingsApplicationContentSubtable
- title={t`Fields added to other objects`}
- rows={filtered.fields}
- applicationId={applicationId}
- fallbackApplicationData={fallbackApplicationData}
- />
- </Table>
- </Section.Root>
- )}
-
- {hasLayout && (
- <Section.Root>
- <Section.Header
- title={t`Layout`}
- description={t`How records, pages, and navigation are displayed`}
- />
- <Table>
- <SettingsApplicationContentSubtable
- title={t`Page layouts`}
- rows={filtered.pageLayouts}
- applicationId={applicationId}
- fallbackApplicationData={fallbackApplicationData}
- />
- <SettingsApplicationContentSubtable
- title={t`Views`}
- rows={filtered.views}
- applicationId={applicationId}
- fallbackApplicationData={fallbackApplicationData}
- />
- <SettingsApplicationContentSubtable
- title={t`Navigation menu items`}
- rows={filtered.navigation}
- applicationId={applicationId}
- fallbackApplicationData={fallbackApplicationData}
- />
- <SettingsApplicationContentSubtable
- title={t`Front components`}
- rows={filtered.frontComponents}
- applicationId={applicationId}
- fallbackApplicationData={fallbackApplicationData}
- />
- <SettingsApplicationContentSubtable
- title={t`Command menu items`}
- rows={filtered.commandMenuItems}
- applicationId={applicationId}
- fallbackApplicationData={fallbackApplicationData}
- />
- </Table>
- </Section.Root>
- )}
-
- {hasLogic && (
- <Section.Root>
- <Section.Header
- title={t`Logic`}
- description={t`Automation, AI, and access this app provides`}
- />
- <Table>
- <SettingsApplicationContentSubtable
- title={t`Logic functions`}
- rows={filtered.logicFunctions}
- applicationId={applicationId}
- fallbackApplicationData={fallbackApplicationData}
- />
- <SettingsApplicationContentSubtable
- title={t`Agents`}
- rows={filtered.agents}
- applicationId={applicationId}
- fallbackApplicationData={fallbackApplicationData}
- />
- <SettingsApplicationContentSubtable
- title={t`Skills`}
- rows={filtered.skills}
- applicationId={applicationId}
- fallbackApplicationData={fallbackApplicationData}
- />
- <SettingsApplicationContentSubtable
- title={t`Roles`}
- rows={filtered.roles}
- applicationId={applicationId}
- fallbackApplicationData={fallbackApplicationData}
- />
- <SettingsApplicationContentSubtable
- title={t`Connection providers`}
- rows={filtered.connectionProviders}
- applicationId={applicationId}
- fallbackApplicationData={fallbackApplicationData}
- />
- <SettingsApplicationContentSubtable
- title={t`Timeline activity types`}
- rows={timelineActivityTypeRows}
- applicationId={applicationId}
- fallbackApplicationData={fallbackApplicationData}
- />
- </Table>
- </Section.Root>
- )}
- </>
- );
-};
diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationPermissionsTab.tsx b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationPermissionsTab.tsx
deleted file mode 100644
index 1f65f9a44fd..00000000000
--- a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationPermissionsTab.tsx
+++ /dev/null
@@ -1,366 +0,0 @@
-import {
- MetadataReadability,
- ObjectOpenRecordIn,
- ObjectSharingReach,
-} from 'twenty-shared/types';
-import { objectMetadataItemsSelector } from '@/object-metadata/states/objectMetadataItemsSelector';
-import { type EnrichedObjectMetadataItem } from '@/object-metadata/types/EnrichedObjectMetadataItem';
-import { buildFieldMetadataItemFromMarketplaceField } from '@/settings/applications/utils/buildFieldMetadataItemFromMarketplaceField';
-import { SettingsRolesQueryEffect } from '@/settings/roles/components/SettingsRolesQueryEffect';
-import { SettingsRolePermissions } from '@/settings/roles/role-permissions/components/SettingsRolePermissions';
-import { settingsDraftRoleFamilyState } from '@/settings/roles/states/settingsDraftRoleFamilyState';
-import { type RoleWithPartialMembers } from '@/settings/roles/types/RoleWithPartialMembers';
-import { SettingsEmptyPlaceholder } from '@/settings/components/SettingsEmptyPlaceholder';
-import { useSetAtomFamilyState } from '@/ui/utilities/state/jotai/hooks/useSetAtomFamilyState';
-import { t } from '@lingui/core/macro';
-import { useCallback, useEffect, useMemo, useState } from 'react';
-import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
-import {
- type ObjectManifest,
- type RoleManifest,
-} from 'twenty-shared/application';
-import {
- type PermissionFlagType,
- SystemPermissionFlag,
-} from 'twenty-shared/constants';
-import { isDefined } from 'twenty-shared/utils';
-import { v4 as uuidv4 } from 'uuid';
-import { MetadataWritability } from '~/generated-metadata/graphql';
-
-const SYSTEM_PERMISSION_FLAG_BY_UNIVERSAL_IDENTIFIER = Object.fromEntries(
- Object.entries(SystemPermissionFlag).map(([key, uuid]) => [
- uuid,
- key as PermissionFlagType,
- ]),
-);
-
-type SettingsApplicationPermissionsTabProps = {
- defaultRoleId?: string | null;
- marketplaceAppDefaultRole?: RoleManifest;
- marketplaceAppObjects?: ObjectManifest[];
-};
-
-const resolvePermissionIds = (
- defaultRole: RoleManifest,
- objectMetadataItems: EnrichedObjectMetadataItem[],
-): {
- objectUniversalIdToIdMap: Record<string, string>;
- fieldUniversalIdToIdMap: Record<string, string>;
-} => {
- const objectUniversalIdToIdMap: Record<string, string> = {};
- const fieldUniversalIdToIdMap: Record<string, string> = {};
-
- const objectsByUid = new Map(
- objectMetadataItems.map((item) => [item.universalIdentifier, item]),
- );
- const fieldsByUid = new Map(
- objectMetadataItems.flatMap((item) =>
- item.fields.map((field) => [field.universalIdentifier, field] as const),
- ),
- );
-
- const allObjectUniversalIds = new Set<string>();
- for (const permission of defaultRole.objectPermissions ?? []) {
- allObjectUniversalIds.add(permission.objectUniversalIdentifier);
- }
- for (const permission of defaultRole.fieldPermissions ?? []) {
- allObjectUniversalIds.add(permission.objectUniversalIdentifier);
- }
-
- for (const universalId of allObjectUniversalIds) {
- const workspaceObject = objectsByUid.get(universalId);
- if (isDefined(workspaceObject)) {
- objectUniversalIdToIdMap[universalId] = workspaceObject.id;
- }
- }
-
- for (const permission of defaultRole.fieldPermissions ?? []) {
- const workspaceField = fieldsByUid.get(permission.fieldUniversalIdentifier);
- if (isDefined(workspaceField)) {
- fieldUniversalIdToIdMap[permission.fieldUniversalIdentifier] =
- workspaceField.id;
- }
- }
-
- return { objectUniversalIdToIdMap, fieldUniversalIdToIdMap };
-};
-
-const buildSyntheticRole = (
- defaultRole: RoleManifest,
- objectUniversalIdToIdMap: Record<string, string>,
- fieldUniversalIdToIdMap: Record<string, string>,
-): RoleWithPartialMembers => ({
- __typename: 'Role',
- id: defaultRole.universalIdentifier,
- label: defaultRole.label,
- description: defaultRole.description ?? '',
- icon: '',
- isEditable: false,
- canReadAllObjectRecords: defaultRole.canReadAllObjectRecords ?? false,
- canUpdateAllObjectRecords: defaultRole.canUpdateAllObjectRecords ?? false,
- canSoftDeleteAllObjectRecords:
- defaultRole.canSoftDeleteAllObjectRecords ?? false,
- canDestroyAllObjectRecords: defaultRole.canDestroyAllObjectRecords ?? false,
- canUpdateAllSettings: defaultRole.canUpdateAllSettings ?? false,
- canAccessAllTools: defaultRole.canAccessAllTools ?? false,
- canBeAssignedToUsers: false,
- canBeAssignedToAgents: false,
- canBeAssignedToApiKeys: false,
- workspaceMembers: [],
- agents: [],
- apiKeys: [],
- rowLevelPermissionPredicates: [],
- rowLevelPermissionPredicateGroups: [],
- objectPermissions: (defaultRole.objectPermissions ?? []).map(
- (permission) => ({
- __typename: 'ObjectPermission' as const,
- objectMetadataId:
- objectUniversalIdToIdMap[permission.objectUniversalIdentifier] ??
- permission.objectUniversalIdentifier,
- canReadObjectRecords: permission.canReadObjectRecords,
- canUpdateObjectRecords: permission.canUpdateObjectRecords,
- canSoftDeleteObjectRecords: permission.canSoftDeleteObjectRecords,
- canDestroyObjectRecords: permission.canDestroyObjectRecords,
- }),
- ),
- fieldPermissions: (defaultRole.fieldPermissions ?? []).map((permission) => ({
- __typename: 'FieldPermission' as const,
- id: uuidv4(),
- roleId: defaultRole.universalIdentifier,
- objectMetadataId:
- objectUniversalIdToIdMap[permission.objectUniversalIdentifier] ??
- permission.objectUniversalIdentifier,
- fieldMetadataId:
- fieldUniversalIdToIdMap[permission.fieldUniversalIdentifier] ??
- permission.fieldUniversalIdentifier,
- canReadFieldValue: permission.canReadFieldValue,
- canUpdateFieldValue: permission.canUpdateFieldValue,
- })),
- permissionFlags: (defaultRole.permissionFlagUniversalIdentifiers ?? []).map(
- (permissionFlagUniversalIdentifier) => ({
- __typename: 'RolePermissionFlag' as const,
- id: uuidv4(),
- roleId: defaultRole.universalIdentifier,
- flag: SYSTEM_PERMISSION_FLAG_BY_UNIVERSAL_IDENTIFIER[
- permissionFlagUniversalIdentifier
- ],
- }),
- ),
-});
-
-const buildObjectMetadataItemsFromMarketplaceApp = (
- defaultRole: RoleManifest,
- objectUniversalIdToIdMap: Record<string, string>,
- marketplaceAppObjects: ObjectManifest[],
-): EnrichedObjectMetadataItem[] => {
- const unresolvedUniversalIds = new Set<string>();
-
- for (const permission of defaultRole.objectPermissions ?? []) {
- if (
- !isDefined(objectUniversalIdToIdMap[permission.objectUniversalIdentifier])
- ) {
- unresolvedUniversalIds.add(permission.objectUniversalIdentifier);
- }
- }
- for (const permission of defaultRole.fieldPermissions ?? []) {
- if (
- !isDefined(objectUniversalIdToIdMap[permission.objectUniversalIdentifier])
- ) {
- unresolvedUniversalIds.add(permission.objectUniversalIdentifier);
- }
- }
-
- const appObjectsByUniversalId = new Map(
- marketplaceAppObjects.map((obj) => [obj.universalIdentifier, obj]),
- );
-
- return [...unresolvedUniversalIds]
- .map((universalId) => {
- const appObject = appObjectsByUniversalId.get(universalId);
-
- if (!isDefined(appObject)) {
- return undefined;
- }
-
- const fields = appObject.fields.map(
- buildFieldMetadataItemFromMarketplaceField,
- );
-
- const objectFieldPermissions = (
- defaultRole.fieldPermissions ?? []
- ).filter(
- (permission) => permission.objectUniversalIdentifier === universalId,
- );
-
- const nonReadableFieldIds = new Set(
- objectFieldPermissions
- .filter((permission) => permission.canReadFieldValue === false)
- .map((permission) => permission.fieldUniversalIdentifier),
- );
-
- const nonUpdatableFieldIds = new Set(
- objectFieldPermissions
- .filter((permission) => permission.canUpdateFieldValue === false)
- .map((permission) => permission.fieldUniversalIdentifier),
- );
-
- const item: EnrichedObjectMetadataItem = {
- __typename: 'Object',
- id: universalId,
- universalIdentifier: universalId,
- nameSingular: appObject.nameSingular,
- namePlural: appObject.namePlural,
- labelSingular: appObject.labelSingular,
- labelPlural: appObject.labelPlural,
- description: appObject.description ?? '',
- icon: appObject.icon ?? 'IconBox',
- isRemote: false,
- isActive: true,
- isSystem: false,
- isSearchable: false,
- isUIEditable: true,
- isUICreatable: true,
- writability: MetadataWritability.OPEN,
- openRecordIn: ObjectOpenRecordIn.USER_CHOICE,
- sharingReach: ObjectSharingReach.WORKSPACE,
- readability: MetadataReadability.OPEN,
- isLabelSyncedWithName: false,
- labelIdentifierFieldMetadataId: '',
- fields,
- readableFields: fields.filter(
- (field) => !nonReadableFieldIds.has(field.id),
- ),
- updatableFields: fields.filter(
- (field) => !nonUpdatableFieldIds.has(field.id),
- ),
- indexMetadatas: [],
- searchFieldMetadatas: [],
- createdAt: new Date().toISOString(),
- updatedAt: new Date().toISOString(),
- };
-
- return item;
- })
- .filter(isDefined);
-};
-
-const MarketplaceRoleEffect = ({
- defaultRole,
- marketplaceAppObjects,
- onObjectMetadataItemsFromMarketplaceApp,
-}: {
- defaultRole: RoleManifest;
- marketplaceAppObjects: ObjectManifest[];
- onObjectMetadataItemsFromMarketplaceApp: (
- items: EnrichedObjectMetadataItem[],
- ) => void;
-}) => {
- const objectMetadataItems = useAtomStateValue(objectMetadataItemsSelector);
- const setSettingsDraftRole = useSetAtomFamilyState(
- settingsDraftRoleFamilyState,
- defaultRole.universalIdentifier,
- );
-
- const { resolvedRole, objectMetadataItemsFromMarketplaceApp } =
- useMemo(() => {
- const { objectUniversalIdToIdMap, fieldUniversalIdToIdMap } =
- resolvePermissionIds(defaultRole, objectMetadataItems);
-
- return {
- resolvedRole: buildSyntheticRole(
- defaultRole,
- objectUniversalIdToIdMap,
- fieldUniversalIdToIdMap,
- ),
- objectMetadataItemsFromMarketplaceApp:
- buildObjectMetadataItemsFromMarketplaceApp(
- defaultRole,
- objectUniversalIdToIdMap,
- marketplaceAppObjects,
- ),
- };
- }, [defaultRole, objectMetadataItems, marketplaceAppObjects]);
-
- useEffect(() => {
- setSettingsDraftRole(resolvedRole);
- }, [resolvedRole, setSettingsDraftRole]);
-
- useEffect(() => {
- onObjectMetadataItemsFromMarketplaceApp(
- objectMetadataItemsFromMarketplaceApp,
- );
- }, [
- objectMetadataItemsFromMarketplaceApp,
- onObjectMetadataItemsFromMarketplaceApp,
- ]);
-
- return null;
-};
-
-const MarketplaceAppPermissions = ({
- defaultRole,
- marketplaceAppObjects,
-}: {
- defaultRole: RoleManifest;
- marketplaceAppObjects: ObjectManifest[];
-}) => {
- const [
- objectMetadataItemsFromMarketplaceApp,
- setObjectMetadataItemsFromMarketplaceApp,
- ] = useState<EnrichedObjectMetadataItem[]>([]);
-
- const handleObjectsFromMarketplaceApp = useCallback(
- (objects: EnrichedObjectMetadataItem[]) =>
- setObjectMetadataItemsFromMarketplaceApp(objects),
- [],
- );
-
- return (
- <>
- <MarketplaceRoleEffect
- defaultRole={defaultRole}
- marketplaceAppObjects={marketplaceAppObjects}
- onObjectMetadataItemsFromMarketplaceApp={
- handleObjectsFromMarketplaceApp
- }
- />
- <SettingsRolePermissions
- roleId={defaultRole.universalIdentifier}
- isEditable={false}
- objectMetadataItemsFromMarketplaceApp={
- objectMetadataItemsFromMarketplaceApp
- }
- />
- </>
- );
-};
-
-export const SettingsApplicationPermissionsTab = ({
- defaultRoleId,
- marketplaceAppDefaultRole,
- marketplaceAppObjects,
-}: SettingsApplicationPermissionsTabProps) => {
- if (isDefined(marketplaceAppDefaultRole)) {
- return (
- <MarketplaceAppPermissions
- defaultRole={marketplaceAppDefaultRole}
- marketplaceAppObjects={marketplaceAppObjects ?? []}
- />
- );
- }
-
- if (isDefined(defaultRoleId)) {
- return (
- <>
- <SettingsRolesQueryEffect />
- <SettingsRolePermissions roleId={defaultRoleId} isEditable={false} />
- </>
- );
- }
-
- return (
- <SettingsEmptyPlaceholder padding="0">
- {t`No permissions configured for this application.`}
- </SettingsEmptyPlaceholder>
- );
-};
diff --git a/packages/twenty-front/src/pages/settings/applications/utils/__tests__/filterSettingsApplicationTimelineActivityTypes.test.ts b/packages/twenty-front/src/pages/settings/applications/utils/__tests__/filterSettingsApplicationTimelineActivityTypes.test.ts
deleted file mode 100644
index cebd025c2af..00000000000
--- a/packages/twenty-front/src/pages/settings/applications/utils/__tests__/filterSettingsApplicationTimelineActivityTypes.test.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-import { filterSettingsApplicationTimelineActivityTypes } from '~/pages/settings/applications/utils/filterSettingsApplicationTimelineActivityTypes';
-import { type SettingsApplicationTimelineActivityType } from '~/pages/settings/applications/types/SettingsApplicationTimelineActivityType';
-
-const timelineActivityTypes: SettingsApplicationTimelineActivityType[] = [
- {
- action: 'restored',
- icon: 'IconPaperclip',
- id: 'attachment-linked',
- isActive: true,
- label: 'Attached a file',
- name: 'attachmentLinked',
- universalIdentifier: 'attachment-linked-universal-identifier',
- },
- {
- action: 'unlinked',
- icon: 'IconUnlink',
- id: 'attachment-unlinked',
- isActive: false,
- label: 'Removed an attachment',
- name: 'attachmentUnlinked',
- universalIdentifier: 'attachment-unlinked-universal-identifier',
- },
-];
-
-describe('filterSettingsApplicationTimelineActivityTypes', () => {
- it('returns every type for an empty search', () => {
- expect(
- filterSettingsApplicationTimelineActivityTypes({
- timelineActivityTypes,
- searchTerm: ' ',
- }),
- ).toEqual(timelineActivityTypes);
- });
-
- it.each([
- ['label', 'FILE', 'attachment-linked'],
- ['name', 'attachmentUnlinked', 'attachment-unlinked'],
- ['action', 'restored', 'attachment-linked'],
- ])('filters by %s', (_field, searchTerm, expectedId) => {
- expect(
- filterSettingsApplicationTimelineActivityTypes({
- timelineActivityTypes,
- searchTerm,
- }).map(({ id }) => id),
- ).toEqual([expectedId]);
- });
-});
diff --git a/packages/twenty-front/src/pages/settings/applications/utils/filterSettingsApplicationTimelineActivityTypes.ts b/packages/twenty-front/src/pages/settings/applications/utils/filterSettingsApplicationTimelineActivityTypes.ts
deleted file mode 100644
index adea66932d1..00000000000
--- a/packages/twenty-front/src/pages/settings/applications/utils/filterSettingsApplicationTimelineActivityTypes.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import { isNonEmptyString } from '@sniptt/guards';
-import { isDefined } from 'twenty-shared/utils';
-import { type SettingsApplicationTimelineActivityType } from '~/pages/settings/applications/types/SettingsApplicationTimelineActivityType';
-import { normalizeSearchText } from 'twenty-ui/utilities';
-
-export const filterSettingsApplicationTimelineActivityTypes = ({
- timelineActivityTypes,
- searchTerm,
-}: {
- timelineActivityTypes: SettingsApplicationTimelineActivityType[];
- searchTerm: string;
-}): SettingsApplicationTimelineActivityType[] => {
- const normalizedSearchTerm = normalizeSearchText(searchTerm).trim();
-
- if (!isNonEmptyString(normalizedSearchTerm)) {
- return timelineActivityTypes;
- }
-
- return timelineActivityTypes.filter(
- (timelineActivityType) =>
- normalizeSearchText(timelineActivityType.label).includes(
- normalizedSearchTerm,
- ) ||
- normalizeSearchText(timelineActivityType.name).includes(
- normalizedSearchTerm,
- ) ||
- (isDefined(timelineActivityType.action) &&
- normalizeSearchText(timelineActivityType.action).includes(
- normalizedSearchTerm,
- )),
- );
-};