diff --git a/packages/twenty-front/src/modules/object-record/graphql/types/RecordGqlOperationFilter.ts b/packages/twenty-front/src/modules/object-record/graphql/types/RecordGqlOperationFilter.ts index fd6de3f7090d..3b81d20d6931 100644 --- a/packages/twenty-front/src/modules/object-record/graphql/types/RecordGqlOperationFilter.ts +++ b/packages/twenty-front/src/modules/object-record/graphql/types/RecordGqlOperationFilter.ts @@ -85,6 +85,11 @@ export type AddressFilter = { addressPostcode?: StringFilter; }; +export type LinksFilter = { + primaryLinkUrl?: StringFilter; + primaryLinkLabel?: StringFilter; +}; + export type LeafFilter = | UUIDFilter | StringFilter @@ -95,6 +100,7 @@ export type LeafFilter = | FullNameFilter | BooleanFilter | AddressFilter + | LinksFilter | undefined; export type AndObjectRecordFilter = { diff --git a/packages/twenty-front/src/modules/object-record/record-filter/utils/isRecordMatchingFilter.spec.ts b/packages/twenty-front/src/modules/object-record/record-filter/utils/isRecordMatchingFilter.spec.ts index d42f97215f08..ed0b22070777 100644 --- a/packages/twenty-front/src/modules/object-record/record-filter/utils/isRecordMatchingFilter.spec.ts +++ b/packages/twenty-front/src/modules/object-record/record-filter/utils/isRecordMatchingFilter.spec.ts @@ -125,13 +125,17 @@ describe('isRecordMatchingFilter', () => { const companyMockNotInFilter = { ...companiesMock[0], - domainName: - getCompanyDomainName(companyMockInFilter as Company) + 'Different', + domainName: { + primaryLinkUrl: + getCompanyDomainName(companyMockInFilter as Company) + 'Different', + }, }; const filter = { domainName: { - eq: getCompanyDomainName(companyMockInFilter as Company), + primaryLinkUrl: { + eq: getCompanyDomainName(companyMockInFilter as Company), + }, }, }; @@ -235,7 +239,9 @@ describe('isRecordMatchingFilter', () => { and: [ { domainName: { - eq: getCompanyDomainName(companyMockInFilter as Company), + primaryLinkUrl: { + eq: getCompanyDomainName(companyMockInFilter as Company), + }, }, }, { @@ -324,8 +330,10 @@ describe('isRecordMatchingFilter', () => { const companyMockNotInFilter = { ...companiesMock[0], - domainName: - getCompanyDomainName(companyMockInFilter as Company) + 'Different', + domainName: { + primaryLinkUrl: + getCompanyDomainName(companyMockInFilter as Company) + 'Different', + }, employees: 5, name: companyMockInFilter.name + 'Different', }; @@ -334,7 +342,9 @@ describe('isRecordMatchingFilter', () => { and: [ { domainName: { - eq: getCompanyDomainName(companyMockInFilter as Company), + primaryLinkUrl: { + eq: getCompanyDomainName(companyMockInFilter as Company), + }, }, }, { @@ -490,14 +500,16 @@ describe('isRecordMatchingFilter', () => { const companyMockNotInFilter = { ...companiesMock[0], name: companyMockInFilter.name + 'Different', - domainName: companyMockInFilter.name + 'Different', + domainName: { primaryLinkUrl: companyMockInFilter.name + 'Different' }, }; const filter = { or: { name: { eq: companyMockInFilter.name }, domainName: { - eq: getCompanyDomainName(companyMockInFilter as Company), + primaryLinkUrl: { + eq: getCompanyDomainName(companyMockInFilter as Company), + }, }, }, }; diff --git a/packages/twenty-front/src/modules/object-record/record-filter/utils/isRecordMatchingFilter.ts b/packages/twenty-front/src/modules/object-record/record-filter/utils/isRecordMatchingFilter.ts index b5ec81678ec2..53f50c3a9401 100644 --- a/packages/twenty-front/src/modules/object-record/record-filter/utils/isRecordMatchingFilter.ts +++ b/packages/twenty-front/src/modules/object-record/record-filter/utils/isRecordMatchingFilter.ts @@ -9,6 +9,7 @@ import { DateFilter, FloatFilter, FullNameFilter, + LinksFilter, NotObjectRecordFilter, OrObjectRecordFilter, RecordGqlOperationFilter, @@ -207,6 +208,23 @@ export const isRecordMatchingFilter = ({ }); }); } + case FieldMetadataType.Links: { + const linksFilter = filterValue as LinksFilter; + + const keys = ['primaryLinkLabel', 'primaryLinkUrl'] as const; + + return keys.some((key) => { + const value = linksFilter[key]; + if (value === undefined) { + return false; + } + + return isMatchingStringFilter({ + stringFilter: value, + value: record[filterKey][key], + }); + }); + } case FieldMetadataType.DateTime: { return isMatchingDateFilter({ dateFilter: filterValue as DateFilter,