-
Notifications
You must be signed in to change notification settings - Fork 251
fix: rename diagram improved #7752
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 replaces the simple confirmation dialog for renaming diagrams with a proper form modal that includes validation for empty names and duplicate names.
Changes:
- Replaced confirmation dialog with a validated form modal for renaming diagrams
- Created new Redux state management for the rename dialog modal
- Extracted and reorganized validation logic and utilities into reusable hooks and functions
Reviewed changes
Copilot reviewed 17 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/compass-data-modeling/src/utils/utils.ts | Moved getDefaultRelationshipName function from utils.ts to this utils file |
| packages/compass-data-modeling/src/utils/use-new-name-validation.ts | New hook for validating diagram/collection names (empty check and duplicate check) |
| packages/compass-data-modeling/src/utils.ts | Removed file - function moved to utils/utils.ts |
| packages/compass-data-modeling/src/store/rename-diagram-modal.ts | New Redux module for managing rename diagram modal state |
| packages/compass-data-modeling/src/store/reducer.ts | Integrated new rename modal reducer into main reducer |
| packages/compass-data-modeling/src/store/diagram.ts | Refactored renameDiagram to be async thunk with proper error handling |
| packages/compass-data-modeling/src/components/list/saved-diagrams-list.tsx | Updated imports and signature for rename handler to include name parameter |
| packages/compass-data-modeling/src/components/list/saved-diagrams-list.spec.tsx | Added comprehensive test for rename functionality with validation |
| packages/compass-data-modeling/src/components/list/rename-modal.tsx | New modal component with form validation for renaming diagrams |
| packages/compass-data-modeling/src/components/list/diagram-card.tsx | Updated to pass diagram name to rename handler |
| packages/compass-data-modeling/src/components/list/diagram-card.spec.tsx | Updated import path |
| packages/compass-data-modeling/src/components/drawer/util.ts | Removed file - validation logic moved to reusable hook |
| packages/compass-data-modeling/src/components/drawer/relationships-section.tsx | Updated imports to use consolidated utils |
| packages/compass-data-modeling/src/components/drawer/diagram-overview-drawer-content.tsx | Replaced inline validation with useNewNameValidation hook |
| packages/compass-data-modeling/src/components/drawer/diagram-editor-side-panel.tsx | Updated imports to use consolidated utils |
| packages/compass-data-modeling/src/components/drawer/collection-drawer-content.tsx | Replaced inline validation with useNewNameValidation hook |
| packages/compass-data-modeling/src/components/data-modeling.tsx | Added RenameModal component to main app |
packages/compass-data-modeling/src/components/list/rename-modal.tsx
Outdated
Show resolved
Hide resolved
|
Assigned |
gribnoysup
left a comment
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 would suggest to consider to build this functionality into showConfirmation / showPrompt in some way because inevitably we'd want an easy way to get a single-line custom validated input like that in other places and these small redux slices to keep modal state around are a PITA to bootstrap and maintain every time we need one (same reason why we added these show methods in the first place)
Fair point, I did consider extending the prompt to support validation, but I'm not sure to which point do we want to make these reusable? Sounds like the repetitive/code-expensive part maybe isn't the modal-form, but the modal state management? |
|
You're not wrong that modal management is a decent chunk of what creates this churn in setting this stuff up, but so is specifically this case where we either want users to just see something in the modal and dismiss / confirm it or they need to provide like a single value in the input that passes some custom validation, and we have a lot of places where you'd have exactly that: have a single text input, some optional custom validation on top, the user will be promped and the state should disappear after. We use this pattern in renaming "my queries", saving and renaming aggregations in builder, creating views, renaming views / collections, confirming deleting almost anything, now here. Seems like a very clear pattern to account for as we already have a decent setup to add on top without changing too much. |
Description
We've been using a confirmation dialog for the renaming, without any validation. In this PR, I'm replacing it with a simple form that includes validation.
The rest is mostly reorganizing.
Checklist
Motivation and Context
Open Questions
Dependents
Types of changes