-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add label identifier to object decorator #6227
Add label identifier to object decorator #6227
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
- Added
labelIdentifierFieldMetadataId
andimageIdentifierFieldMetadataId
toObjectMetadataInterface
in/packages/twenty-server/src/engine/metadata-modules/field-metadata/interfaces/object-metadata.interface.ts
- Updated
ObjectMetadataDTO
with new identifier fields in/packages/twenty-server/src/engine/metadata-modules/object-metadata/dtos/object-metadata.dto.ts
- Enhanced
ObjectMetadataEntity
to support new identifier properties in/packages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.entity.ts
- Introduced
WorkspaceSyncObjectMetadataIdentifiersService
for synchronizing metadata identifiers in/packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/services/workspace-sync-object-metadata-identifiers.service.ts
- Modified
WorkspaceEntity
decorator to include label and image identifiers in/packages/twenty-server/src/engine/twenty-orm/decorators/workspace-entity.decorator.ts
11 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
- Refactored synchronization logic to handle label and image identifiers in
packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/services/workspace-sync-object-metadata-identifiers.service.ts
- Added methods to fetch original object metadata and create a standard object metadata map
- Processed object metadata collection to include identifier fields
- Validated field metadata types for label and image identifiers
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
|
||
@Field({ nullable: true }) | ||
imageIdentifierFieldMetadataId?: string; | ||
@Field(() => String, { nullable: true }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed because nestjs/graphql usually infers the type from the property bellow but since now it can be either a string or null it does not know what to do so you have to specify the return type in the Field decorator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
- No major changes found since last review.
1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
- Added
labelIdentifier
andimageIdentifier
toWorkspaceEntity
decorator for better record display (packages/twenty-server/src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids.ts
,packages/twenty-server/src/modules/opportunity/standard-objects/opportunity.workspace-entity.ts
). - Removed
probability
field from various GraphQL queries and mock data (packages/twenty-front/src/modules/object-record/hooks/__mocks__/useFindManyRecords.ts
,packages/twenty-front/src/modules/search/hooks/__mocks__/useFilteredSearchEntityQuery.ts
). - Introduced new command to add new address field to views with deprecated address field (
packages/twenty-server/src/database/commands/0-22-add-new-address-field-to-views-with-deprecated-address.command.ts
). - Updated imports and dependencies to support new metadata functionality (
packages/twenty-server/src/engine/core-modules/workspace/workspace.module.ts
,packages/twenty-server/src/engine/workspace-manager/workspace-manager.module.ts
). - Enhanced
sync-workspace-metadata.command.ts
to support multi-workspace metadata sync and error handling.
25 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
imageIdentifierFieldMetadata, | ||
); | ||
|
||
// TODO: Add image identifier field metadata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind tackling this in this PR? I feel it's going to get lost otherwise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what to do with them. I feel like except for people we don't really have any use case of imageIdentifier for standard objects. Also we don't have a file/image field type yet so I wanted to wait to implement properly. Wdyt?
...nager/workspace-sync-metadata/services/workspace-sync-object-metadata-identifiers.service.ts
Outdated
Show resolved
Hide resolved
...ne/workspace-manager/workspace-sync-metadata/interfaces/partial-object-metadata.interface.ts
Show resolved
Hide resolved
packages/twenty-server/src/modules/activity/standard-objects/activity.workspace-entity.ts
Show resolved
Hide resolved
Thanks @FelixMalfait, answered your comments! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM,
IMO: we should not implement imageIdentifier as long as we don't have a robust field type. It's completely fine for chips to fallback on taking the first letter of the labelIdentifier
We can't put the labelIdentifierFieldMetadataId to non nullable in database as the current process of object creation is: create object, then create fields, then set identifier (for standard, we could wrap in a transaction but for custom these steps are done by the FE in different calls).
But we could make it required in the decorator and use Ids for standard object that do not have a legit TEXT field that could be used as labelIdentifier
Thanks @charlesBochet - agree, except I think we should do a fast-follow after this PR and implement a file field type. It might not be perfect but it takes 30 min to create a very basic one and then we can avoid creating more debt (like here, or like when Thomas built the token protection, or in the frontend code as we try to make "attachments" fit in the global model, etc.) |
I've updated the PR @charlesBochet @FelixMalfait, this should now include a fallback logic on PK and set a label for the rest when possible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
- Added
labelIdentifierStandardId
toWorkspaceEntity
decorator in multiple files for better record readability (e.g.,packages/twenty-server/src/modules/activity/standard-objects/activity.workspace-entity.ts
,packages/twenty-server/src/modules/api-key/standard-objects/api-key.workspace-entity.ts
). - Updated
workspace-entity.decorator.ts
to provide a default value forlabelIdentifierStandardId
. - Enhanced
workspace-sync-object-metadata-identifiers.service.ts
to support additional field types for label identifiers. - Reordered and added imports in
workspace-sync-metadata/standard-objects/index.ts
for better organization. - Reorganized imports in several files for improved clarity and consistency.
21 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
- Added migration to
objectMetadata
table for UUID columns and constraints (packages/twenty-server/src/database/typeorm/metadata/migrations/1720792873225-createIdentifiersFK.ts
) - Introduced OneToOne relations for
labelIdentifier
andimageIdentifier
fields (packages/twenty-server/src/engine/metadata-modules/field-metadata/field-metadata.entity.ts
) - Added new columns and relations for
labelIdentifierFieldMetadata
andimageIdentifierFieldMetadata
(packages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.entity.ts
)
3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
@FelixMalfait fast follow implying data migration is not cheap! Can't we stay with the computed coloured avatar based on labelIdentifer for now? Not sure the users will value being able to add a picture manually anyway |
@charlesBochet I'm doing similar migrations on the PR to standardize of Activity, should I introduce the FILE field type myself in that PR to manage all migrations at once? I have a feeling this would be a similar migration that the activity.body TEXT -> RICH_TEXT migration I added, so if it helps I'm happy to do it at the same time? |
(Discussed in DM - I thought it was a fast follow but it's not) |
This reverts commit fab4b56.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
- Deleted migration file
packages/twenty-server/src/database/typeorm/metadata/migrations/1720792873225-createIdentifiersFK.ts
- Removed relations to
labelIdentifierFieldMetadata
andimageIdentifierFieldMetadata
inpackages/twenty-server/src/engine/metadata-modules/field-metadata/field-metadata.entity.ts
- Updated column types for
labelIdentifierFieldMetadataId
andimageIdentifierFieldMetadataId
from 'uuid' to 'text' inpackages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.entity.ts
- Removed OneToOne relations for
labelIdentifierFieldMetadataId
andimageIdentifierFieldMetadataId
inpackages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.entity.ts
3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
- Added migration file
packages/twenty-server/src/database/typeorm/metadata/migrations/1721057142509-fixIdentifierTypes.ts
to change column types touuid
- Updated
packages/twenty-server/src/engine/metadata-modules/object-metadata/object-metadata.entity.ts
to change column types touuid
forlabelIdentifierFieldMetadataId
andimageIdentifierFieldMetadataId
2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
- Added
labelIdentifier
andimageIdentifier
toWorkspaceEntity
decorator in multiple files for better metadata display - Introduced new hooks and utilities for fetching and managing record data in
packages/twenty-front
- Refactored import paths and module structures in
packages/twenty-server
for better organization - Added new constants for batch sizes and query limits in
packages/twenty-front
- Updated test files to cover new functionalities and ensure robustness
148 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
- Added
labelIdentifier
andimageIdentifier
toWorkspaceEntity
decorator for enhanced metadata display (packages/twenty-front/package.json
,packages/twenty-server/package.json
) - Introduced
useScrollToPosition
hook for custom scroll behavior (packages/twenty-front/src/hooks/useScrollToPosition.ts
) - Added
CalendarEventDetailsEffect
component for upserting calendar event records (packages/twenty-front/src/modules/activities/calendar/components/CalendarEventDetailsEffect.tsx
) - Replaced
EntityChip
withRecordChip
andAvatarChip
components for better record display (packages/twenty-front/src/modules/object-record/record-field/components/FieldDisplay.tsx
,packages/twenty-front/src/modules/object-record/record-field/meta-types/display/components/ChipFieldDisplay.tsx
) - Updated pagination logic and added cursor-based pagination support (
packages/twenty-front/src/modules/object-record/hooks/useFindManyRecords.ts
,packages/twenty-front/src/modules/object-record/hooks/useFetchAllRecordIds.ts
)
136 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
(updates since last review)
- Ensured URLs in
LinkDisplay.tsx
are absolute by prepending 'https://' - Added 'upgrade-guide' entry to 'Self-Hosting' section in
packages/twenty-website/src/content/developers/constants/DocsIndex.ts
- Created new upgrade guide in
packages/twenty-website/src/content/developers/self-hosting/upgrade-guide.mdx
3 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings
Context
LabelIdentifier and ImageIdentifier are metadata info attached to objectMetadata that are used to display a record in a more readable way. Those columns point to existing fields that are part of the object.
For example, for a relation picker of a person, we will show a record using the "name" labelIdentifier and the "avatarUrl" imageIdentifier.
Currently, the FE has a specific logic for company and people objects and we have a way to update this value via the API for custom objects, but the code is not flexible enough to change other standard objects.
This PR updates the WorkspaceEntity API so we can now provide the labelIdentifier and imageIdentifier in the WorkspaceEntity decorator.
Example: