Skip to content

Support Full Name as Record Text Identifier #11610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 19, 2025

Conversation

b9aurav
Copy link
Contributor

@b9aurav b9aurav commented Apr 17, 2025

closes #11296

recording.webm

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR adds support for using full name fields as record text identifiers, allowing them to be clickable and selectable in the settings form.

  • Added FieldMetadataType.FULL_NAME to LABEL_IDENTIFIER_FIELD_METADATA_TYPES array in /packages/twenty-front/src/modules/object-metadata/constants/LabelIdentifierFieldMetadataTypes.ts
  • Removed 'fullName' from reserved keywords in /packages/twenty-server/src/engine/metadata-modules/utils/validate-metadata-name-is-not-reserved-keyword.ts
  • Enhanced RecordChip component in /packages/twenty-front/src/modules/object-record/components/RecordChip.tsx to handle full name concatenation
  • Modified ChipFieldDisplay and useChipFieldDisplay to properly handle full name fields as identifiers
  • Updated SettingsDataModelObjectIdentifiersForm to keep identifier fields clickable even with single field

💡 (5/5) You can turn off certain types of comments like style here!

6 file(s) reviewed, 2 comment(s)
Edit PR Review Bot Settings | Greptile

let name = recordChipData.name;

if (field?.type === FieldMetadataType.FULL_NAME) {
name = `${record[field.name]?.firstName || ''} ${record[field.name]?.lastName || ''}`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider adding .trim() to remove extra space when either firstName or lastName is empty

Suggested change
name = `${record[field.name]?.firstName || ''} ${record[field.name]?.lastName || ''}`;
name = `${record[field.name]?.firstName || ''} ${record[field.name]?.lastName || ''}`.trim();

Comment on lines 49 to 50
'currencies',
'fullName',
'fullNames',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider whether 'fullNames' should also be removed for consistency since 'fullName' is now allowed

fullWidth
dropdownId={`${fieldName}-select`}
emptyOption={emptyOption}
options={options}
value={value}
withSearchInput={label === t`Record label`}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Issue, required change is only in 'Record Label' dropdown, Not in 'Record Image' dropdown.

@@ -22,6 +23,10 @@ export const ChipFieldDisplay = () => {
size={ChipSize.Small}
to={labelIdentifierLink}
isLabelHidden={isLabelIdentifierCompact}
field={{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment above

Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @b9aurav, thanks for the PR
I have left comments :)

@b9aurav
Copy link
Contributor Author

b9aurav commented Apr 17, 2025

@charlesBochet Thanks for your comments, I'll take a look at requested changes.

@@ -13,7 +13,7 @@ export const getLabelIdentifierFieldValue = (
objectNameSingular === CoreObjectNameSingular.WorkspaceMember ||
labelIdentifierFieldMetadataItem?.type === FieldMetadataType.FULL_NAME
) {
return `${record.name?.firstName ?? ''} ${record.name?.lastName ?? ''}`;
return `${record[labelIdentifierFieldMetadataItem?.name ?? '']?.firstName ?? ''} ${record[labelIdentifierFieldMetadataItem?.name ?? '']?.lastName ?? ''}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should throw if we can't find the labelIdentifierFieldMetadataItem

@@ -20,19 +22,26 @@ export const useRecordChipData = ({
PreComputedChipGeneratorsContext,
);

const { fieldDefinition } = useContext(FieldContext);
const updatedRecord = { ...record };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's avoid creating a fake record having a "name", this will create confusion in the code. Instead, we can passe to identifierChipGenerator and generateDefaultRecordChipData what we need

@charlesBochet
Copy link
Member

Thank you @b9aurav, I've made some small modifications to remove previous technical debt

Copy link
Contributor

github-actions bot commented May 19, 2025

🚀 Preview Environment Ready!

Your preview environment is available at: http://bore.pub:31034

This environment will automatically shut down when the PR is closed or after 5 hours.

@charlesBochet charlesBochet merged commit 98e199c into twentyhq:main May 19, 2025
29 checks passed
Copy link
Contributor

Thanks @b9aurav for your contribution!
This marks your 10th PR on the repo. You're top 4% of all our contributors 🎉
See contributor page - Share on LinkedIn - Share on Twitter

Contributions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Full Name as Record Text Identifier
2 participants