fix link validation and matching during csv import (#9890)
### Context [Issue 9019](https://github.com/twentyhq/twenty/issues/9019) opens by user having domain name not imported while importing through CSV. @samyakpiya (thank you for your investigation !) has tested various domain imports and has reported issue with its import test. Issues that no longer exist : when I test your import, I get all records imported. ### Solution - Remove "Link label" (cf screenshot - before fix) composite field in matching options, not used in front that could mislead the user. <img width="300" alt="Screenshot 2025-01-28 at 15 39 18" src="https://github.com/user-attachments/assets/0ea24d9e-b339-42f3-b8d9-e271b33dbcfd" /> - Check links type fields validity in "Validate data" step closes #9019 --------- Co-authored-by: etiennejouan <jouan.etienne@gmail.com>
This commit is contained in:
@ -29,8 +29,8 @@ export const COMPOSITE_FIELD_IMPORT_LABELS = {
|
|||||||
addressLngLabel: 'Longitude',
|
addressLngLabel: 'Longitude',
|
||||||
} satisfies CompositeFieldLabels<FieldAddressValue>,
|
} satisfies CompositeFieldLabels<FieldAddressValue>,
|
||||||
[FieldMetadataType.LINKS]: {
|
[FieldMetadataType.LINKS]: {
|
||||||
|
// primaryLinkLabelLabel excluded from composite field import labels since it's not used in Links input
|
||||||
primaryLinkUrlLabel: 'Link URL',
|
primaryLinkUrlLabel: 'Link URL',
|
||||||
primaryLinkLabelLabel: 'Link Label',
|
|
||||||
} satisfies Partial<CompositeFieldLabels<FieldLinksValue>>,
|
} satisfies Partial<CompositeFieldLabels<FieldLinksValue>>,
|
||||||
[FieldMetadataType.EMAILS]: {
|
[FieldMetadataType.EMAILS]: {
|
||||||
primaryEmailLabel: 'Email',
|
primaryEmailLabel: 'Email',
|
||||||
|
|||||||
@ -33,7 +33,7 @@ export const buildRecordFromImportedStructuredRow = (
|
|||||||
},
|
},
|
||||||
CURRENCY: { amountMicrosLabel, currencyCodeLabel },
|
CURRENCY: { amountMicrosLabel, currencyCodeLabel },
|
||||||
FULL_NAME: { firstNameLabel, lastNameLabel },
|
FULL_NAME: { firstNameLabel, lastNameLabel },
|
||||||
LINKS: { primaryLinkLabelLabel, primaryLinkUrlLabel },
|
LINKS: { primaryLinkUrlLabel },
|
||||||
EMAILS: { primaryEmailLabel },
|
EMAILS: { primaryEmailLabel },
|
||||||
PHONES: { primaryPhoneNumberLabel, primaryPhoneCountryCodeLabel },
|
PHONES: { primaryPhoneNumberLabel, primaryPhoneCountryCodeLabel },
|
||||||
} = COMPOSITE_FIELD_IMPORT_LABELS;
|
} = COMPOSITE_FIELD_IMPORT_LABELS;
|
||||||
@ -118,14 +118,11 @@ export const buildRecordFromImportedStructuredRow = (
|
|||||||
case FieldMetadataType.LINKS: {
|
case FieldMetadataType.LINKS: {
|
||||||
if (
|
if (
|
||||||
isDefined(
|
isDefined(
|
||||||
importedStructuredRow[`${primaryLinkUrlLabel} (${field.name})`] ||
|
importedStructuredRow[`${primaryLinkUrlLabel} (${field.name})`],
|
||||||
importedStructuredRow[`${primaryLinkLabelLabel} (${field.name})`],
|
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
recordToBuild[field.name] = {
|
recordToBuild[field.name] = {
|
||||||
primaryLinkLabel: castToString(
|
primaryLinkLabel: '',
|
||||||
importedStructuredRow[`${primaryLinkLabelLabel} (${field.name})`],
|
|
||||||
),
|
|
||||||
primaryLinkUrl: castToString(
|
primaryLinkUrl: castToString(
|
||||||
importedStructuredRow[`${primaryLinkUrlLabel} (${field.name})`],
|
importedStructuredRow[`${primaryLinkUrlLabel} (${field.name})`],
|
||||||
),
|
),
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { FieldValidationDefinition } from '@/spreadsheet-import/types';
|
|||||||
import { isDefined } from 'twenty-ui';
|
import { isDefined } from 'twenty-ui';
|
||||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||||
import { isValidUuid } from '~/utils/isValidUuid';
|
import { isValidUuid } from '~/utils/isValidUuid';
|
||||||
|
import { absoluteUrlSchema } from '~/utils/validation-schemas/absoluteUrlSchema';
|
||||||
|
|
||||||
export const getSpreadSheetFieldValidationDefinitions = (
|
export const getSpreadSheetFieldValidationDefinitions = (
|
||||||
type: FieldMetadataType,
|
type: FieldMetadataType,
|
||||||
@ -48,6 +49,16 @@ export const getSpreadSheetFieldValidationDefinitions = (
|
|||||||
level: 'error',
|
level: 'error',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
case FieldMetadataType.LINKS:
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
rule: 'function',
|
||||||
|
isValid: (value: string) =>
|
||||||
|
absoluteUrlSchema.safeParse(value).success,
|
||||||
|
errorMessage: fieldName + ' is not valid',
|
||||||
|
level: 'error',
|
||||||
|
},
|
||||||
|
];
|
||||||
default:
|
default:
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user