Connect - Import Relation (#13419)

re-opened https://github.com/twentyhq/twenty/pull/13213
This commit is contained in:
Etienne
2025-07-25 09:48:17 +02:00
committed by GitHub
parent ca27995ca6
commit 741924751b
92 changed files with 1612 additions and 1153 deletions
@@ -3,10 +3,11 @@ import { ReadonlyDeep } from 'type-fest';
import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem';
import { isCompositeFieldType } from '@/object-record/object-filter-dropdown/utils/isCompositeFieldType';
import { getSubFieldOptionKey } from '@/object-record/spreadsheet-import/utils/getSubFieldOptionKey';
import { MatchColumnSelectFieldSelectDropdownContent } from '@/spreadsheet-import/components/MatchColumnSelectFieldSelectDropdownContent';
import { MatchColumnSelectSubFieldSelectDropdownContent } from '@/spreadsheet-import/components/MatchColumnSelectSubFieldSelectDropdownContent';
import { DO_NOT_IMPORT_OPTION_KEY } from '@/spreadsheet-import/constants/DoNotImportOptionKey';
import { SpreadsheetImportFieldOption } from '@/spreadsheet-import/types/SpreadsheetImportFieldOption';
import { hasNestedFields } from '@/spreadsheet-import/utils/spreadsheetImportHasNestedFields';
import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';
import { useCloseDropdown } from '@/ui/layout/dropdown/hooks/useCloseDropdown';
import styled from '@emotion/styled';
@@ -19,7 +20,7 @@ interface MatchColumnToFieldSelectProps {
columnIndex: string;
onChange: (value: ReadonlyDeep<SelectOption> | null) => void;
value?: ReadonlyDeep<SelectOption>;
options: readonly ReadonlyDeep<SelectOption>[];
options: readonly Readonly<SpreadsheetImportFieldOption>[];
suggestedOptions: readonly ReadonlyDeep<SelectOption>[];
placeholder?: string;
}
@@ -70,12 +71,7 @@ export const MatchColumnToFieldSelect = ({
}
const correspondingOption = options.find((option) => {
const optionKey = getSubFieldOptionKey(
selectedFieldMetadataItem,
subFieldNameSelected,
);
return option.value === optionKey;
return option.value === subFieldNameSelected;
});
if (isDefined(correspondingOption)) {
@@ -112,9 +108,9 @@ export const MatchColumnToFieldSelect = ({
closeDropdown(dropdownId);
};
const shouldShowSubField =
const shouldShowNestedField =
isDefined(selectedFieldMetadataItem) &&
isCompositeFieldType(selectedFieldMetadataItem.type);
hasNestedFields(selectedFieldMetadataItem);
return (
<Dropdown
@@ -129,7 +125,7 @@ export const MatchColumnToFieldSelect = ({
/>
}
dropdownComponents={
shouldShowSubField ? (
shouldShowNestedField ? (
<MatchColumnSelectSubFieldSelectDropdownContent
fieldMetadataItem={selectedFieldMetadataItem}
onSubFieldSelect={handleSubFieldSelect}