-
Notifications
You must be signed in to change notification settings - Fork 246
fix: moveMultipleConnections edit COMPASS-10008 #7646
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
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 fixes a bug where moving multiple collections simultaneously in the diagram editor was not being saved. The fix adds support for a new MoveMultipleCollections edit type that can handle batch position updates when users drag multiple selected collections.
Key Changes:
- Introduces a new
MoveMultipleCollectionsedit type to handle batch collection moves - Updates the diagram editor to detect multi-node drags and dispatch the appropriate edit action
- Adds schema validation and test coverage for the new edit type
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/compass-data-modeling/src/store/diagram.ts | Adds moveMultipleCollections action creator for the new edit type |
| packages/compass-data-modeling/src/store/diagram.spec.ts | Adds test coverage for the MoveMultipleCollections edit functionality |
| packages/compass-data-modeling/src/store/apply-edit.ts | Implements the logic to apply MoveMultipleCollections edits to the model |
| packages/compass-data-modeling/src/services/data-model-storage.ts | Adds Zod schema validation for the new edit type |
| packages/compass-data-modeling/src/components/diagram-editor.tsx | Updates UI component to handle multi-node drag events and dispatch appropriate actions |
| const movedCollections = Object.keys(edit.newPositions); | ||
| for (const ns of movedCollections) { | ||
| assertCollectionExists(model.collections, ns); | ||
| } |
Copilot
AI
Dec 12, 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.
Use a for-of loop over Object.keys() for better readability and consistency with modern JavaScript patterns. Consider: for (const ns of Object.keys(edit.newPositions)) to eliminate the intermediate variable.
| for (const ns of movedCollections) { | ||
| assertCollectionExists(model.collections, ns); | ||
| } | ||
| return { | ||
| ...model, | ||
| collections: model.collections.map((collection) => { | ||
| if (movedCollections.includes(collection.ns)) { |
Copilot
AI
Dec 12, 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.
Using includes() inside a map() results in O(n*m) complexity. Convert movedCollections to a Set before the map operation for O(1) lookup performance when dealing with multiple collections.
| for (const ns of movedCollections) { | |
| assertCollectionExists(model.collections, ns); | |
| } | |
| return { | |
| ...model, | |
| collections: model.collections.map((collection) => { | |
| if (movedCollections.includes(collection.ns)) { | |
| const movedCollectionsSet = new Set(movedCollections); | |
| for (const ns of movedCollections) { | |
| assertCollectionExists(model.collections, ns); | |
| } | |
| return { | |
| ...model, | |
| collections: model.collections.map((collection) => { | |
| if (movedCollectionsSet.has(collection.ns)) { |
Description
Saving multiple connections move.
Steps to Reproduce
These steps are a bit inconvenient, I think we might add proper support multi-item selections (the relational migrator has it), but that's for another day. This just fixes the issue that the users were able to drag multiple collections, but we weren't saving it.
Screen.Recording.2025-12-12.at.19.52.29.mov
Checklist
Motivation and Context
Open Questions
Dependents
Types of changes