Discard empty and null links in Links fields (#12188)

This PR has several objectives:

- Ignore invalid and empty links in the frontend
- Ignore empty links when creating or updating a link field in the
backend
- Throw an error when trying to create or update a link field with an
invalid link

The logic is mostly the same in the frontend and the backend: we take
the initial primaryLink and the secondaryLinks, we discard all the empty
links (with `url === '' || url === null`), and the primaryLink becomes
the first remaining link.

## Frontend

There are three parts in the frontend where we have to remove the empty
links:

- LinksDisplay
- LinksFieldInput
- isFieldValueEmpty; used in RecordInlineCell

## Backend

I put the logic in
`packages/twenty-server/src/engine/core-modules/record-transformer/services/record-input-transformer.service.ts`
as it's used by the REST API, the GraphQL API, and by Create Record and
Update Record actions in the workflows.
This commit is contained in:
Baptiste Devessier
2025-05-23 11:13:10 +02:00
committed by GitHub
parent 75e4a5d19b
commit ec9d8e4e95
17 changed files with 544 additions and 31 deletions

View File

@ -23,6 +23,7 @@ describe('isValidUrl', () => {
expect(isValidUrl('')).toBe(false);
expect(isValidUrl('\\')).toBe(false);
expect(isValidUrl('wwwexamplecom')).toBe(false);
expect(isValidUrl('lydia,com')).toBe(false);
expect(isValidUrl('2/toto')).toBe(false);
expect(isValidUrl('2')).toBe(false);
});