Skip to content

Conversation

ncarbon
Copy link
Collaborator

@ncarbon ncarbon commented Sep 25, 2025

Description

This PR adds the "Document Count" step (Figma) to the mock data generator modal in the compass-collection package, allowing users to specify the number of documents to generate and view an estimated disk size based on the avg_document_size obtained from the collection model during schema analysis. It introduces validation, error handling, and updates the Redux state to support average document size (avgDocumentSize).

  • Note: I did not implement the vertical stepper since it's in the private leafygreen-ui-private repo.
    • awaiting response from leafygreen team to see if this is something we can import from Artifactory (MANA access is pending), or can be made public.
Screenshot 2025-09-25 at 3 56 36 PM Screenshot 2025-09-25 at 3 56 47 PM Screenshot 2025-09-25 at 3 56 16 PM

Mock Data Generator Modal Enhancements:

  • Added a new DocumentCountScreen component that lets users specify the number of documents to generate, shows estimated disk size (using the new avgDocumentSize from schema analysis), and validates input with error messaging for out-of-range values. [1] [2] [3]
  • Updated modal logic to disable the Next button when the document count is invalid (less than 1 or greater than 100,000).

Schema Analysis & State Updates:

  • Extended schema analysis state and Redux actions to include avgDocumentSize, sourced from the collection model, enabling accurate disk size estimation in the modal. [1] [2] [3] [4] [5] [6]

Dependency Updates:

  • Added the numeral library for formatting byte sizes in the UI.

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
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

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)

@ncarbon ncarbon added the no release notes Fix or feature not for release notes label Sep 25, 2025
@ncarbon ncarbon force-pushed the CLOUDP-333856/document-count-screen branch from 73d67ae to a9b7f37 Compare September 25, 2025 20:31
@github-actions github-actions bot added the feat label Sep 25, 2025
@ncarbon ncarbon marked this pull request as ready for review September 25, 2025 20:32
@ncarbon ncarbon requested a review from a team as a code owner September 25, 2025 20:32
@ncarbon ncarbon requested review from johnjackweir and Copilot and removed request for johnjackweir September 25, 2025 20:32
Copy link
Contributor

@Copilot 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 adds a "Document Count Screen" to the mock data generator modal in the compass-collection package, allowing users to specify the number of documents to generate with estimated disk size calculation based on average document size from schema analysis.

  • Implements document count input with validation (1-100,000 range) and error handling
  • Integrates average document size from collection model into schema analysis state
  • Adds estimated disk size calculation and display using the numeral library

Reviewed Changes

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

Show a summary per file
File Description
stores/collection-tab.ts Adds collection model to Redux thunk extra arguments
schema-analysis-types.ts Extends schema metadata type to include average document size
modules/collection-tab.ts Updates schema analysis to capture and store average document size from collection model
mock-data-generator-modal.tsx Integrates DocumentCountScreen component and adds validation logic for next button
mock-data-generator-modal.spec.tsx Adds comprehensive test coverage for document count screen functionality
document-count-screen.tsx Implements new document count input screen with disk size estimation
constants.ts Defines default and maximum document count constants
package.json Adds numeral dependency for byte formatting

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Collaborator

@jcobis jcobis left a comment

Choose a reason for hiding this comment

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

Nice work Nataly!

@ncarbon ncarbon requested a review from gribnoysup September 29, 2025 16:08
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.

Nothing blocking, a few suggestions that I think should make this a bit tighter, otherwise looks good

<Body className={descriptionStyles}>
Indicate the amount of documents you want to generate below.
<br />
Note: We have defaulted to {DEFAULT_DOCUMENT_COUNT}.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Super small nit: I know it's in the designs, but this "Note" here feels redundant, we already prefill the input with the default count, so doesn't seem to be a reason to spell it

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree fully, was going to flag this actually

import { connect } from 'react-redux';
import type { CollectionState } from '../../modules/collection-tab';
import type { SchemaAnalysisState } from '../../schema-analysis-types';
import numeral from 'numeral';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: instead of adding a dependency I would suggest to move the formatting helpers in https://github.com/mongodb-js/compass/blob/main/packages/databases-collections-list/src/format.ts to compass-components package, and use them here, this way we will have consistent formatting across the code

Comment on lines +103 to +104

return schemaAnalysisState.status === 'complete' ? (
Copy link
Collaborator

@gribnoysup gribnoysup Sep 30, 2025

Choose a reason for hiding this comment

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

Super duper nit: for readability it might be easier to short circuit here first, then return the form instead of using a ternary for the whole return statement

Suggested change
return schemaAnalysisState.status === 'complete' ? (
if (schemaAnalysisState.status !== 'complete') {
return <div>We are analyzing your collection.</div>
}
// ... rest of the form

/>
<div>
<Body className={boldStyles}>Estimated Disk Size</Body>
<Body className={estimatedDiskSizeStyles}>{estimatedDiskSize}</Body>
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] the estimated size is a bit off visually, we can probably center it wrt to input field?
Image

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you for the keen eye. We're basing off the designs for now and can bring this up with them

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat no release notes Fix or feature not for release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants