-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 field isLabelSyncedWithName #8829
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
This PR introduces a new boolean field isLabelSyncedWithName
to control synchronization between field labels and API names, particularly for enum naming patterns.
- Added
isLabelSyncedWithName
column tometadata.fieldMetadata
table with default valuetrue
in/packages/twenty-server/src/database/typeorm/metadata/migrations/1733072126592-addIsLabelSyncedWithNameToFieldMetadata.ts
- Added advanced settings section with API Name input and sync toggle in
/packages/twenty-front/src/modules/settings/data-model/fields/forms/components/SettingsDataModelFieldIconLabelForm.tsx
- Modified workspace-migration-enum.service.ts to handle enum type name retrieval before column rename operations
- Removed automatic name computation from label in
formatFieldMetadataItemInput.ts
to support independent API naming - Updated GraphQL schema, queries, and types across multiple files to support the new field synchronization functionality
15 file(s) reviewed, 8 comment(s)
Edit PR Review Bot Settings | Greptile
@@ -187,6 +187,7 @@ export type CreateFieldInput = { | |||
icon?: InputMaybe<Scalars['String']['input']>; | |||
isActive?: InputMaybe<Scalars['Boolean']['input']>; | |||
isCustom?: InputMaybe<Scalars['Boolean']['input']>; | |||
isLabelSyncedWithName: Scalars['Boolean']['input']; |
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.
logic: isLabelSyncedWithName is required in CreateFieldInput but optional in UpdateFieldInput - this inconsistency could cause issues
packages/twenty-front/src/modules/object-metadata/hooks/useFieldMetadataItem.ts
Outdated
Show resolved
Hide resolved
packages/twenty-front/src/modules/object-metadata/utils/formatFieldMetadataItemInput.ts
Show resolved
Hide resolved
packages/twenty-front/src/modules/object-metadata/validation-schemas/fieldMetadataItemSchema.ts
Show resolved
Hide resolved
.../modules/settings/data-model/fields/forms/components/SettingsDataModelFieldIconLabelForm.tsx
Show resolved
Hide resolved
type SettingsDataModelFieldIconLabelFormProps = { | ||
disabled?: boolean; | ||
fieldMetadataItem?: FieldMetadataItem; | ||
maxLength?: number; | ||
}; | ||
|
||
const infoCircleElementId = 'info-circle-id'; |
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.
style: infoCircleElementId should include a more unique prefix to avoid potential ID conflicts
packages/twenty-server/src/engine/metadata-modules/field-metadata/dtos/field-metadata.dto.ts
Show resolved
Hide resolved
@Field() | ||
isLabelSyncedWithName?: boolean; |
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.
logic: Field should be marked as nullable since it's optional
packages/twenty-front/src/modules/object-metadata/hooks/useUpdateOneFieldMetadataItem.ts
Show resolved
Hide resolved
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.
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "metadata"."fieldMetadata" ADD "isLabelSyncedWithName" boolean NOT NULL DEFAULT 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 defaults to false for objects, let's do the same?
Context
The recent addition of object renaming introduced issues with enum names. Enum names should follow the pattern
${schemaName}.${tableName}_${columnName}_enum
. To address this, and to allow users to customize the API name (which is included in the enum name, columnName), this PR implements behavior similar to object renaming by introducing aisLabelSyncedWithName
boolean.