Migrate domainName field from text type to links type (#6410)

Closes #5759.
This commit is contained in:
Marie
2024-07-30 11:47:37 +02:00
committed by GitHub
parent fb0fd99a38
commit 8e35edad30
44 changed files with 888 additions and 217 deletions

View File

@ -61,6 +61,11 @@ linkedinLink
secondaryLinks
}
domainName
{
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
annualRecurringRevenue
{
amountMicros
@ -95,7 +100,11 @@ idealCustomerProfile
people: true,
xLink: true,
linkedinLink: true,
domainName: true,
domainName: {
primaryLinkUrl: true,
primaryLinkLabel: true,
secondaryLinks: true,
},
annualRecurringRevenue: true,
createdAt: true,
address: { addressStreet1: true },
@ -136,6 +145,11 @@ linkedinLink
secondaryLinks
}
domainName
{
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
annualRecurringRevenue
{
amountMicros

View File

@ -61,6 +61,11 @@ linkedinLink
secondaryLinks
}
domainName
{
primaryLinkUrl
primaryLinkLabel
secondaryLinks
}
annualRecurringRevenue
{
amountMicros

View File

@ -5,6 +5,8 @@ import { getLogoUrlFromDomainName } from '~/utils';
import { getImageAbsoluteURI } from '~/utils/image/getImageAbsoluteURI';
import { isDefined } from '~/utils/isDefined';
import { Company } from '@/companies/types/Company';
import { getCompanyDomainName } from '@/object-metadata/utils/getCompanyDomainName';
import { getImageIdentifierFieldValue } from './getImageIdentifierFieldValue';
export const getAvatarUrl = (
@ -17,7 +19,9 @@ export const getAvatarUrl = (
}
if (objectNameSingular === CoreObjectNameSingular.Company) {
return getLogoUrlFromDomainName(record.domainName ?? '');
return getLogoUrlFromDomainName(
getCompanyDomainName(record as Company) ?? '',
);
}
if (objectNameSingular === CoreObjectNameSingular.Person) {

View File

@ -0,0 +1,14 @@
import { Company } from '@/companies/types/Company';
import { isDefined } from 'twenty-ui';
// temporary, to remove once domainName has been fully migrated to Links type
export const getCompanyDomainName = (company: Company) => {
if (!isDefined(company.domainName)) {
return company.domainName;
}
if (typeof company.domainName === 'string') {
return company.domainName;
} else {
return company.domainName.primaryLinkUrl;
}
};

View File

@ -2940,7 +2940,7 @@ export const getObjectMetadataItemsMock = () => {
{
__typename: 'field',
id: '20202020-5e4e-4007-a630-8a2617914889',
type: 'TEXT',
type: 'LINKS',
name: 'domainName',
label: 'Domain Name',
description: