Skip to content

Conversation

@paula-stacho
Copy link
Collaborator

@paula-stacho paula-stacho commented Jan 26, 2026

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.

Screenshot 2026-01-26 at 12 06 06 Screenshot 2026-01-26 at 12 06 13

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • If this change could impact the load on the MongoDB cluster, please describe the expected and worst case impact
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@paula-stacho paula-stacho marked this pull request as ready for review January 26, 2026 11:43
@paula-stacho paula-stacho requested a review from a team as a code owner January 26, 2026 11:43
Copy link
Contributor

Copilot AI left a 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

@codeowners-service-app
Copy link

Assigned lerouxb for team compass-developers because mabaasit is out of office.

Copy link
Collaborator

@gribnoysup gribnoysup left a 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)

@paula-stacho
Copy link
Collaborator Author

paula-stacho commented Jan 26, 2026

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?

@paula-stacho paula-stacho added the no-title-validation Skips validation of PR titles (conventional commit adherence + JIRA ticket inclusion) label Jan 26, 2026
@gribnoysup
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix no-title-validation Skips validation of PR titles (conventional commit adherence + JIRA ticket inclusion) release notes wip

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants