Skip to content

The open alternative to Salesforce, designed for AI.

chore(front): remove unused application data table (#24513)

Félix Malfait4096ec78c294
diff --git a/packages/twenty-front/src/modules/settings/applications/hooks/useObjectAndFieldRows.ts b/packages/twenty-front/src/modules/settings/applications/hooks/useObjectAndFieldRows.ts
deleted file mode 100644
index 5713059a131..00000000000
--- a/packages/twenty-front/src/modules/settings/applications/hooks/useObjectAndFieldRows.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-import { type ApplicationDisplayData } from '@/applications/types/applicationDisplayData.type';
-import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
-import { objectMetadataItemsSelector } from '@/object-metadata/states/objectMetadataItemsSelector';
-import { getInstalledApplicationObjectAndFieldRows } from '@/settings/applications/utils/getInstalledApplicationObjectAndFieldRows';
-import { getManifestObjectAndFieldRows } from '@/settings/applications/utils/getManifestObjectAndFieldRows';
-import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
-import { useMemo } from 'react';
-import { type Manifest } from 'twenty-shared/application';
-import { isDefined } from 'twenty-shared/utils';
-import { type Application } from '~/generated-metadata/graphql';
-
-type InstalledApplicationForObjectRows = Omit<
- Application,
- 'objects' | 'frontComponents'
-> & {
- objects: { id: string }[];
-};
-
-export const useObjectAndFieldRows = ({
- installedApplication,
- manifestContent,
- applicationInfo,
-}: {
- applicationId: string;
- installedApplication?: InstalledApplicationForObjectRows;
- manifestContent?: Manifest;
- applicationInfo?: ApplicationDisplayData;
-}) => {
- const objectMetadataItems = useAtomStateValue(objectMetadataItemsSelector);
- const currentWorkspace = useAtomStateValue(currentWorkspaceState);
- const installedApplications = currentWorkspace?.installedApplications;
-
- return useMemo(() => {
- if (isDefined(installedApplication)) {
- return getInstalledApplicationObjectAndFieldRows({
- installedApplication,
- objectMetadataItems,
- installedApplications,
- });
- }
-
- return getManifestObjectAndFieldRows({
- manifestContent,
- objectMetadataItems,
- applicationInfo,
- });
- }, [
- installedApplication,
- manifestContent,
- objectMetadataItems,
- installedApplications,
- applicationInfo,
- ]);
-};
diff --git a/packages/twenty-front/src/modules/settings/applications/utils/getInstalledApplicationObjectAndFieldRows.ts b/packages/twenty-front/src/modules/settings/applications/utils/getInstalledApplicationObjectAndFieldRows.ts
deleted file mode 100644
index dc3df35931a..00000000000
--- a/packages/twenty-front/src/modules/settings/applications/utils/getInstalledApplicationObjectAndFieldRows.ts
+++ /dev/null
@@ -1,79 +0,0 @@
-import { type ApplicationDisplayData } from '@/applications/types/applicationDisplayData.type';
-import { isHiddenSystemField } from '@/object-metadata/utils/isHiddenSystemField';
-import { type EnrichedObjectMetadataItem } from '@/object-metadata/types/EnrichedObjectMetadataItem';
-import { SettingsPath } from 'twenty-shared/types';
-import { getSettingsPath } from 'twenty-shared/utils';
-import { type Application } from '~/generated-metadata/graphql';
-import { type ApplicationDataTableRow } from '~/pages/settings/applications/types/applicationDataTableRow';
-
-const FIELD_GROUP_DENY_LIST = ['timelineActivity', 'favorite'];
-
-type InstalledApplication = Omit<Application, 'objects' | 'frontComponents'> & {
- objects: { id: string }[];
-};
-
-export const getInstalledApplicationObjectAndFieldRows = ({
- installedApplication,
- objectMetadataItems,
- installedApplications,
-}: {
- installedApplication: InstalledApplication;
- objectMetadataItems: EnrichedObjectMetadataItem[];
- installedApplications?: ApplicationDisplayData[];
-}): {
- objectRows: ApplicationDataTableRow[];
- fieldGroupRows: ApplicationDataTableRow[];
-} => {
- const installedObjectIds = installedApplication.objects.map(
- (object) => object.id,
- );
-
- const objectRows: ApplicationDataTableRow[] =
- installedApplication.objects.length === 0
- ? []
- : objectMetadataItems
- .filter((item) => installedObjectIds.includes(item.id))
- .map((item) => ({
- key: item.nameSingular,
- labelPlural: item.labelPlural,
- icon: item.icon ?? undefined,
- fieldsCount: item.fields.filter((f) => !isHiddenSystemField(f))
- .length,
- link: getSettingsPath(SettingsPath.ObjectDetail, {
- objectNamePlural: item.namePlural,
- }),
- application: {
- id: installedApplication.id,
- logoUrl: installedApplication.logoUrl,
- name: installedApplication.name,
- universalIdentifier: installedApplication.universalIdentifier,
- },
- }))
- .sort((a, b) => a.labelPlural.localeCompare(b.labelPlural));
-
- const fieldGroupRows: ApplicationDataTableRow[] = objectMetadataItems
- .filter((item) => {
- if (installedObjectIds.includes(item.id)) return false;
- if (FIELD_GROUP_DENY_LIST.includes(item.nameSingular)) return false;
-
- return item.fields.some(
- (field) => field.applicationId === installedApplication.id,
- );
- })
- .map((item) => ({
- key: item.nameSingular,
- labelPlural: item.labelPlural,
- icon: item.icon ?? undefined,
- fieldsCount: item.fields.filter(
- (field) => field.applicationId === installedApplication.id,
- ).length,
- link: getSettingsPath(SettingsPath.ObjectDetail, {
- objectNamePlural: item.namePlural,
- }),
- application:
- installedApplications?.find((app) => app.id === item.applicationId) ??
- {},
- }));
-
- return { objectRows, fieldGroupRows };
-};
diff --git a/packages/twenty-front/src/modules/settings/applications/utils/getManifestObjectAndFieldRows.ts b/packages/twenty-front/src/modules/settings/applications/utils/getManifestObjectAndFieldRows.ts
deleted file mode 100644
index cd2c3999453..00000000000
--- a/packages/twenty-front/src/modules/settings/applications/utils/getManifestObjectAndFieldRows.ts
+++ /dev/null
@@ -1,102 +0,0 @@
-import { type ApplicationDisplayData } from '@/applications/types/applicationDisplayData.type';
-import { type EnrichedObjectMetadataItem } from '@/object-metadata/types/EnrichedObjectMetadataItem';
-import { type Manifest } from 'twenty-shared/application';
-import { isDefined } from 'twenty-shared/utils';
-import { type ApplicationDataTableRow } from '~/pages/settings/applications/types/applicationDataTableRow';
-import { findObjectNameByUniversalIdentifier } from '~/pages/settings/applications/utils/findObjectNameByUniversalIdentifier';
-import { isHiddenSystemField } from '@/object-metadata/utils/isHiddenSystemField';
-
-const FIELD_GROUP_DENY_LIST = ['timelineActivity', 'favorite'];
-
-export const getManifestObjectAndFieldRows = ({
- manifestContent,
- objectMetadataItems,
- applicationInfo,
-}: {
- manifestContent?: Manifest;
- objectMetadataItems: EnrichedObjectMetadataItem[];
- applicationInfo?: ApplicationDisplayData;
-}): {
- objectRows: ApplicationDataTableRow[];
- fieldGroupRows: ApplicationDataTableRow[];
-} => {
- const manifestObjects = manifestContent?.objects ?? [];
- const manifestFields = manifestContent?.fields ?? [];
-
- const objectRows: ApplicationDataTableRow[] = manifestObjects
- .map((appObject) => ({
- key: appObject.nameSingular,
- labelPlural: appObject.labelPlural,
- icon: appObject.icon ?? undefined,
- fieldsCount: appObject.fields.filter((f) => !isHiddenSystemField(f))
- .length,
- application: applicationInfo ?? {},
- }))
- .sort((a, b) => a.labelPlural.localeCompare(b.labelPlural));
-
- if (manifestFields.length === 0) {
- return { objectRows, fieldGroupRows: [] };
- }
-
- const manifestObjectUids = new Set(
- manifestObjects.map((obj) => obj.universalIdentifier),
- );
-
- const groupMap = new Map<
- string,
- { objectUniversalIdentifier: string; count: number }
- >();
-
- for (const field of manifestFields) {
- const objectUid = field.objectUniversalIdentifier;
-
- if (manifestObjectUids.has(objectUid)) {
- continue;
- }
-
- const existing = groupMap.get(objectUid);
-
- if (isDefined(existing)) {
- existing.count++;
- } else {
- groupMap.set(objectUid, {
- objectUniversalIdentifier: objectUid,
- count: 1,
- });
- }
- }
-
- const fieldGroupRows: ApplicationDataTableRow[] = Array.from(
- groupMap.values(),
- )
- .map((group) => {
- const standardObjectName = findObjectNameByUniversalIdentifier(
- group.objectUniversalIdentifier,
- );
-
- const objectMetadataItem = isDefined(standardObjectName)
- ? objectMetadataItems.find(
- (item) => item.nameSingular === standardObjectName,
- )
- : undefined;
-
- if (!isDefined(objectMetadataItem)) {
- return;
- }
-
- if (FIELD_GROUP_DENY_LIST.includes(objectMetadataItem.nameSingular)) {
- return;
- }
-
- return {
- key: objectMetadataItem.nameSingular,
- labelPlural: objectMetadataItem.labelPlural,
- icon: objectMetadataItem.icon ?? undefined,
- fieldsCount: group.count,
- application: applicationInfo ?? {},
- };
- })
- .filter(isDefined);
-
- return { objectRows, fieldGroupRows };
-};
diff --git a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationDataTable.tsx b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationDataTable.tsx
deleted file mode 100644
index 10e40ff068f..00000000000
--- a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationDataTable.tsx
+++ /dev/null
@@ -1,117 +0,0 @@
-import { SettingsEmptyPlaceholder } from '@/settings/components/SettingsEmptyPlaceholder';
-import { SETTINGS_OBJECT_TABLE_COLUMN_WIDTH } from '@/settings/data-model/object-details/components/SettingsObjectItemTableRowStyledComponents';
-import { Table } from '@/ui/layout/table/components/Table';
-import { TableHeader } from '@/ui/layout/table/components/TableHeader';
-import { TableRow } from '@/ui/layout/table/components/TableRow';
-import { TableSection } from '@/ui/layout/table/components/TableSection';
-import { styled } from '@linaria/react';
-import { t } from '@lingui/core/macro';
-import { useMemo, useState } from 'react';
-import { H2Title } from 'twenty-ui/typography';
-import { SearchInput } from 'twenty-ui/input';
-import { Section } from 'twenty-ui/layout';
-import { themeCssVariables } from 'twenty-ui/theme-constants';
-
-import { SettingsApplicationDataTableRow } from '~/pages/settings/applications/components/SettingsApplicationDataTableRow';
-import { normalizeSearchText } from '~/utils/normalizeSearchText';
-import { type ApplicationDataTableRow } from '~/pages/settings/applications/types/applicationDataTableRow';
-
-const MAIN_ROW_GRID_COLUMNS = `180px 1fr ${SETTINGS_OBJECT_TABLE_COLUMN_WIDTH} 36px`;
-
-const StyledEmptyHeaderContainer = styled.div`
- > div {
- min-width: 0;
- }
-`;
-
-const StyledSearchInputContainer = styled.div`
- padding-bottom: ${themeCssVariables.spacing[2]};
-`;
-
-export const SettingsApplicationDataTable = ({
- objectRows,
- fieldGroupRows,
-}: {
- objectRows: ApplicationDataTableRow[];
- fieldGroupRows: ApplicationDataTableRow[];
-}) => {
- const [searchTerm, setSearchTerm] = useState('');
-
- const filteredObjectRows = useMemo(() => {
- const normalizedSearch = normalizeSearchText(searchTerm);
-
- if (normalizedSearch === '') {
- return objectRows;
- }
-
- return objectRows.filter((row) =>
- normalizeSearchText(row.labelPlural).includes(normalizedSearch),
- );
- }, [objectRows, searchTerm]);
-
- const filteredFieldGroupRows = useMemo(() => {
- const normalizedSearch = normalizeSearchText(searchTerm);
-
- if (normalizedSearch === '') {
- return fieldGroupRows;
- }
-
- return fieldGroupRows.filter((row) =>
- normalizeSearchText(row.labelPlural).includes(normalizedSearch),
- );
- }, [fieldGroupRows, searchTerm]);
-
- const shouldDisplayObjects = filteredObjectRows.length > 0;
- const shouldDisplayFields = filteredFieldGroupRows.length > 0;
- const hasSearchTerm = searchTerm.trim().length > 0;
- const hasNoResults =
- hasSearchTerm && !shouldDisplayObjects && !shouldDisplayFields;
-
- if (objectRows.length === 0 && fieldGroupRows.length === 0) {
- return null;
- }
-
- return (
- <Section>
- <H2Title
- title={t`Data`}
- description={t`Objects and fields managed by this app`}
- />
- <StyledSearchInputContainer>
- <SearchInput
- placeholder={t`Search an object...`}
- value={searchTerm}
- onChange={setSearchTerm}
- />
- </StyledSearchInputContainer>
- {hasNoResults ? (
- <SettingsEmptyPlaceholder>{t`No object found`}</SettingsEmptyPlaceholder>
- ) : (
- <Table>
- <TableRow gridAutoColumns={MAIN_ROW_GRID_COLUMNS}>
- <TableHeader>{t`Name`}</TableHeader>
- <TableHeader>{t`App`}</TableHeader>
- <TableHeader align="right">{t`Fields`}</TableHeader>
- <StyledEmptyHeaderContainer>
- <TableHeader />
- </StyledEmptyHeaderContainer>
- </TableRow>
- {shouldDisplayObjects && (
- <TableSection title={t`Objects`}>
- {filteredObjectRows.map((row) => (
- <SettingsApplicationDataTableRow key={row.key} row={row} />
- ))}
- </TableSection>
- )}
- {shouldDisplayFields && (
- <TableSection title={t`Fields`}>
- {filteredFieldGroupRows.map((row) => (
- <SettingsApplicationDataTableRow key={row.key} row={row} />
- ))}
- </TableSection>
- )}
- </Table>
- )}
- </Section>
- );
-};
diff --git a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationDataTableRow.tsx b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationDataTableRow.tsx
deleted file mode 100644
index 76a439ede35..00000000000
--- a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationDataTableRow.tsx
+++ /dev/null
@@ -1,73 +0,0 @@
-import {
- SETTINGS_OBJECT_TABLE_COLUMN_WIDTH,
- 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 { styled } from '@linaria/react';
-import { useContext } from 'react';
-import { isDefined } from 'twenty-shared/utils';
-import { IconChevronRight, useIcons } from 'twenty-ui/icon';
-import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';
-
-import { type ApplicationDataTableRow } from '~/pages/settings/applications/types/applicationDataTableRow';
-import { AppChip } from '@/applications/components/AppChip';
-
-const MAIN_ROW_GRID_COLUMNS = `180px 1fr ${SETTINGS_OBJECT_TABLE_COLUMN_WIDTH} 36px`;
-
-const StyledNameContainer = styled.div`
- align-items: center;
- display: flex;
- flex: 1;
- gap: ${themeCssVariables.spacing[1]};
- min-width: 0;
-`;
-
-const StyledNameLabel = styled.div`
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-`;
-
-export const SettingsApplicationDataTableRow = ({
- row,
-}: {
- row: ApplicationDataTableRow;
-}) => {
- const { theme } = useContext(ThemeContext);
- const { getIcon } = useIcons();
-
- const Icon = getIcon(row.icon);
-
- return (
- <TableRow gridAutoColumns={MAIN_ROW_GRID_COLUMNS} to={row.link}>
- <StyledNameTableCell minWidth="0" overflow="hidden">
- {isDefined(Icon) && (
- <Icon size={theme.icon.size.md} stroke={theme.icon.stroke.sm} />
- )}
- <StyledNameContainer>
- <StyledNameLabel title={row.labelPlural}>
- {row.labelPlural}
- </StyledNameLabel>
- </StyledNameContainer>
- </StyledNameTableCell>
- <StyledNameTableCell minWidth="0" overflow="hidden">
- <AppChip
- applicationId={row.application?.id}
- fallbackApplicationData={row.application}
- />
- </StyledNameTableCell>
- <TableCell align="right">{row.fieldsCount}</TableCell>
- <StyledActionTableCell>
- {row.link && (
- <IconChevronRight
- size={theme.icon.size.md}
- stroke={theme.icon.stroke.sm}
- color={theme.font.color.light}
- />
- )}
- </StyledActionTableCell>
- </TableRow>
- );
-};
diff --git a/packages/twenty-front/src/pages/settings/applications/types/applicationDataTableRow.ts b/packages/twenty-front/src/pages/settings/applications/types/applicationDataTableRow.ts
deleted file mode 100644
index 60f16b80d54..00000000000
--- a/packages/twenty-front/src/pages/settings/applications/types/applicationDataTableRow.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { type ApplicationDisplayData } from '@/applications/types/applicationDisplayData.type';
-
-export type ApplicationDataTableRow = {
- key: string;
- labelPlural: string;
- icon?: string;
- fieldsCount: number;
- link?: string;
- application: ApplicationDisplayData;
-};
diff --git a/packages/twenty-front/src/pages/settings/applications/utils/findObjectNameByUniversalIdentifier.ts b/packages/twenty-front/src/pages/settings/applications/utils/findObjectNameByUniversalIdentifier.ts
deleted file mode 100644
index 5fa1472644a..00000000000
--- a/packages/twenty-front/src/pages/settings/applications/utils/findObjectNameByUniversalIdentifier.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import { STANDARD_OBJECTS } from 'twenty-shared/metadata';
-
-export const findObjectNameByUniversalIdentifier = (
- universalIdentifier: string,
-): string | undefined => {
- for (const [objectName, objectDefinition] of Object.entries(
- STANDARD_OBJECTS,
- )) {
- if (objectDefinition.universalIdentifier === universalIdentifier) {
- return objectName;
- }
- }
-
- return undefined;
-};