-
Notifications
You must be signed in to change notification settings - Fork 246
feat(data-modeling): allow inline field type changes COMPASS-9799 #7514
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
base: main
Are you sure you want to change the base?
Conversation
278cbbf to
48f4e93
Compare
55dde32 to
56d6196
Compare
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.
Pull request overview
This PR enables inline editing of field types in diagram nodes when double-clicked, similar to the existing field name editing capability. The change centralizes the derivation of oldTypes within the changeFieldType function rather than requiring callers to provide it, improving the API design and reducing redundancy.
Key changes:
- Refactored
changeFieldTypeto deriveoldTypesinternally from the schema - Extracted BSON types into a shared utility module (
FIELD_TYPES) - Connected field type change handler to diagram component
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/compass-data-modeling/src/utils/field-types.ts | New utility module exporting FIELD_TYPES constant for BSON type enumeration |
| packages/compass-data-modeling/src/store/diagram.ts | Refactored changeFieldType to derive oldTypes internally, removing it from the function signature |
| packages/compass-data-modeling/src/components/drawer/field-drawer-content.tsx | Updated to use shared FIELD_TYPES constant and removed oldTypes parameter from changeFieldType call |
| packages/compass-data-modeling/src/components/diagram-editor.tsx | Added onChangeFieldType handler to enable inline field type editing in diagram nodes |
| packages/compass-components/package.json | Bumped @mongodb-js/diagramming to ^2.2.2 to support the new inline editing functionality |
| const oldTypes = field?.fieldTypes; | ||
| if (!field) throw new Error('Field not found in schema'); |
Copilot
AI
Dec 11, 2025
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.
The oldTypes is assigned from field?.fieldTypes before checking if field exists. If field is undefined, oldTypes will be undefined, which could cause issues in telemetry or undo logic. Move this assignment after the null check on line 868.
| const oldTypes = field?.fieldTypes; | |
| if (!field) throw new Error('Field not found in schema'); | |
| if (!field) throw new Error('Field not found in schema'); | |
| const oldTypes = field.fieldTypes; |
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.
🤦
| onNodeExpandToggle: isCollapseFlagEnabled | ||
| ? handleNodeExpandedToggle | ||
| : undefined, | ||
| fieldTypes: FIELD_TYPES, |
Copilot
AI
Dec 11, 2025
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.
The new fieldTypes prop being passed to the diagram is not covered by tests. Consider adding test coverage to verify that the field types are correctly passed and rendered in the diagram component.
|
Assigned |
|
Somehow the change of a field type in diagram doesn't update the drawer. this works for field name but I don't remember if we had to do something for it, I would have expected this to work out of the box 🤔 |
Allow users to edit field type on diagram node when a field is double clicked (like field name).
Preview
Editable.Field.mov
Description
Checklist
Motivation and Context
Open Questions
Dependents
Types of changes