Skip to content

Conversation

@mabaasit
Copy link
Collaborator

@mabaasit mabaasit commented Dec 18, 2025

In draft while working on e2e tests.

Preview
New.DM.Diagram.Creation.mov

Description

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)

@@ -0,0 +1,410 @@
import React from 'react';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the code in this file is from new-diagram-form.spec.tsx, moved it to this folder

// 1. Import the components we use from leafygreen.
import { Copyable } from '@leafygreen-ui/copyable';
import { Badge } from '@leafygreen-ui/badge';
import { default as Banner } from '@leafygreen-ui/banner';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG showed deprecated for default import and I changed it to named one.

Comment on lines +71 to +87
if (isFetchingCollections) {
return (
<div className={loadingStyles}>
<SpinLoaderWithLabel progressText="">
Fetching collections ...
</SpinLoaderWithLabel>
</div>
);
}

if (error) {
return (
<div className={errorStyles}>
<WarningSummary warnings={[error.message]} />
</div>
);
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of the code in this file was already existent in new-diagram-form except for these two views.

@mabaasit mabaasit marked this pull request as ready for review December 19, 2025 14:03
@mabaasit mabaasit requested a review from a team as a code owner December 19, 2025 14:03
@mabaasit mabaasit requested review from Copilot and ivandevp December 19, 2025 14:03
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 refactors the diagram creation flow in the data modeling feature by consolidating multi-step wizard interactions into a more streamlined two-step process. The changes simplify state management by introducing a form-fields-based approach and remove redundant intermediate "loading" states.

Key changes:

  • Replaced the old multi-step wizard (name → connection → database → collections) with a consolidated two-step flow (setup diagram → select collections)
  • Refactored state management to use a formFields structure with inline error/loading states instead of separate top-level step states
  • Split the monolithic new-diagram-form.tsx component into separate modular components for better maintainability

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/compass-e2e-tests/tests/data-modeling-tab.test.ts Removed redundant confirm button clicks from the e2e test setup
packages/compass-data-modeling/test/setup-store.tsx Updated test storage service from noop to in-memory implementation
packages/compass-data-modeling/src/store/generate-diagram-wizard.ts Refactored wizard state machine with consolidated steps and form-field-based state management
packages/compass-data-modeling/src/components/new-diagram/setup-diagram-step.tsx New component for the consolidated setup step (connection, database, diagram name)
packages/compass-data-modeling/src/components/new-diagram/select-collections-step.tsx Extracted collections selection into a separate component
packages/compass-data-modeling/src/components/new-diagram/new-diagram-modal.tsx New modal wrapper managing the two-step wizard flow
packages/compass-data-modeling/src/components/new-diagram/new-diagram-modal.spec.tsx Comprehensive tests for the new modal component
packages/compass-data-modeling/src/components/new-diagram-form.tsx Removed legacy monolithic component
packages/compass-data-modeling/src/components/new-diagram-form.spec.tsx Removed legacy test file
packages/compass-data-modeling/src/components/data-modeling.tsx Updated import path for the new modal component
packages/compass-components/src/components/leafygreen.tsx Changed Banner import from default to named export

Comment on lines +516 to +521
const newDiagramName = [
database,
date.getDate(),
date.getMonth() + 1,
date.getFullYear(),
].join('_');
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The date components (day and month) are not zero-padded, which could result in inconsistent diagram names like database_1_5_2024 vs database_15_12_2024. Consider padding to ensure consistent naming: date.getDate().toString().padStart(2, '0') and (date.getMonth() + 1).toString().padStart(2, '0').

Suggested change
const newDiagramName = [
database,
date.getDate(),
date.getMonth() + 1,
date.getFullYear(),
].join('_');
const day = date.getDate().toString().padStart(2, '0');
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const year = date.getFullYear();
const newDiagramName = [database, day, month, year].join('_');

Copilot uses AI. Check for mistakes.
database,
});

// If the current diagram name is empty, we want to auto-generate the it
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'the it' to 'it'

Suggested change
// If the current diagram name is empty, we want to auto-generate the it
// If the current diagram name is empty, we want to auto-generate it

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@ivandevp ivandevp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes LGTM

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants