-
Notifications
You must be signed in to change notification settings - Fork 251
feat(crud): add UUID type editing support in document editor COMPASS-10194 #7768
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
…10194 Add comprehensive support for UUID types (UUID, LegacyJavaUUID, LegacyCSharpUUID, LegacyPythonUUID) in the document editing interface. Changes include: - Add UUID types to type dropdown menu in document editor - Implement UUIDEditor for editing UUID values as strings - Add byte-order conversion for legacy UUID formats - Display UUID (subtype 4) as $uuid format in JSON view - Standardize on single quotes for UUID display consistency - Pass legacyUUIDDisplayEncoding preference to table view
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 adds comprehensive support for UUID types (UUID, LegacyJavaUUID, LegacyCSharpUUID, LegacyPythonUUID) in MongoDB Compass's document editing interface, enabling users to view and edit both standard UUID (Binary subtype 4) and legacy UUID formats (Binary subtype 3) with proper byte-order handling.
Changes:
- Added four new UUID types to the type system with proper casting and validation
- Implemented UUID-specific editor and display components with appropriate byte-order conversions
- Added context-aware UUID display based on legacy encoding preferences
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/hadron-type-checker/src/type-checker.ts | Added UUID types to TypeCastMap, implemented casting functions with byte-order conversions, and extended type() method to accept legacyUUIDEncoding parameter |
| packages/hadron-type-checker/src/index.ts | Exported UUID_REGEX for validation |
| packages/hadron-type-checker/test/type-checker.test.ts | Updated tests to include new UUID types in expected type lists |
| packages/hadron-document/src/element.ts | Added UUID_TYPES constant, modified changeType() and isValueEditable() to handle UUID types |
| packages/hadron-document/src/editor/uuid.ts | Implemented UUIDEditor with byte-order conversion logic for all UUID formats |
| packages/hadron-document/src/editor/index.ts | Integrated UUIDEditor into the editor system |
| packages/hadron-document/src/utils.ts | Added base64 to UUID string conversion for JSON view |
| packages/hadron-document/test/editor/uuid.spec.ts | Added comprehensive tests for UUID editor functionality |
| packages/compass-components/src/components/bson-value.tsx | Added display components for all UUID types and updated quote style from double to single |
| packages/compass-components/src/components/bson-value.spec.tsx | Updated test expectations for quote style change |
| packages/compass-components/src/components/document-list/element.tsx | Added getDisplayType() function to determine UUID display type based on context |
| packages/compass-components/src/components/document-list/element-editors.tsx | Added UUID-specific input editor with validation styling |
| packages/compass-components/src/components/document-list/index.ts | Exported LegacyUUIDDisplayContext |
| packages/compass-crud/src/components/document-list.tsx | Added legacyUUIDDisplayEncoding preference to document list |
| packages/compass-crud/src/components/table-view/document-table-view.tsx | Propagated legacyUUIDDisplayEncoding to table cells |
| packages/compass-crud/src/components/table-view/cell-renderer.tsx | Added LegacyUUIDDisplayContext.Provider to cell renderer |
packages/compass-components/src/components/document-list/element-editors.tsx
Outdated
Show resolved
Hide resolved
|
Assigned |
Address code review feedback by extracting duplicated byte reversal logic into shared utility functions in hadron-type-checker: - uuidHexToString: converts hex string to UUID format with hyphens - reverseJavaUUIDBytes: reverses byte order for Java legacy UUID format - reverseCSharpUUIDBytes: reverses byte order for C# legacy UUID format These utilities are now used in both type-checker.ts and uuid.ts, eliminating code duplication and improving maintainability.
Address code review feedback by using useMemo for the UUID input style object instead of creating it inline on every render.
When changing from one UUID type to another (e.g., LegacyCSharpUUID to LegacyJavaUUID), the system was producing corrupted data because toString() was being called on Binary objects. This fix: - Adds convertBinaryUUID() function that properly handles encoding/decoding - Updates changeType() to detect UUID-to-UUID conversions and use the special conversion function - Ensures the Binary is first decoded using the source encoding, then re-encoded using the target encoding
…value.tsx Removes duplicated byte reversal logic (toUUIDWithHyphens, toLegacyJavaUUID, toLegacyCSharpUUID, toLegacyPythonUUID) and uses the shared utilities (uuidHexToString, reverseJavaUUIDBytes, reverseCSharpUUIDBytes) from hadron-type-checker instead.
- Modified isValueEditable() in element.ts to allow editing Binary UUIDs (subtype 3 and 4) - Updated useElementEditor() in element.tsx to use display type for editor selection - Updated UUIDEditor constructor to accept displayType parameter - Modified UUIDEditor start() and complete() methods to preserve UUID type during editing
Description
Add comprehensive support for UUID types (UUID, LegacyJavaUUID, LegacyCSharpUUID, LegacyPythonUUID) in MongoDB Compass's document editing interface.
edit-uuid-support.mov
Changes
hadron-type-checker:
TypeCastMap:UUID,LegacyJavaUUID,LegacyCSharpUUID,LegacyPythonUUIDUUID_REGEXfor validationtype()method to accept optionallegacyUUIDEncodingparameterhadron-document:
UUID_TYPESconstant andUUIDTypetype to ElementUUIDEditorfor editing UUID values as strings with validationchangeType()to explicitly setcurrentTypefor UUID typesisValueEditable()to allow UUID editing$uuidformat in JSON view for better readabilitycompass-components:
UUIDValue,LegacyJavaUUIDValue,LegacyCSharpUUIDValue,LegacyPythonUUIDValueChecklist
Motivation and Context
Types of changes