Skip to content

Conversation

@kylelai1
Copy link
Collaborator

@kylelai1 kylelai1 commented Oct 24, 2025

Description

  • Enables the next button before confirming the mappings
  • Clicking on confirm mappings will proceed to the next screen
  • Adds a warning icon to unrecognized fields
  • Drive-by copy fix

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)
image

Fixes the following copy:
Screenshot 2025-10-23 at 11 41 08 PM

Screenshot 2025-10-23 at 11 42 06 PM

@kylelai1 kylelai1 marked this pull request as ready for review October 24, 2025 14:05
@kylelai1 kylelai1 requested a review from a team as a code owner October 24, 2025 14:05
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 implements UI/UX improvements for the mock data generator's schema mapping workflow. The changes streamline the user flow by removing the intermediate confirmation step and adding visual indicators for unrecognized field mappings.

Key Changes:

  • Removed the isSchemaConfirmed state requirement - clicking "Confirm mappings" now directly advances to the next screen
  • Added warning icons to fields with unrecognized or invalid faker method mappings
  • Fixed a typo in the error message tooltip text

Reviewed Changes

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

Show a summary per file
File Description
script-generation-utils.ts Replaced magic string with constant for unrecognized faker method
schema-field-selector.tsx Added warning icon display logic for unrecognized/invalid field mappings
mock-data-generator-modal.tsx Simplified state management by removing isSchemaConfirmed state and related logic
mock-data-generator-modal.spec.tsx Updated tests to reflect new flow where confirm mappings advances directly to next step
faker-schema-editor-screen.tsx Simplified callback signature by removing boolean parameter and state reset calls
collection-header-actions.tsx Fixed typo in error message (added missing space after closing quote)

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

fakerSchema,
}) => {
const darkMode = useDarkMode();
const logger = createNoopLogger();
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

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

The noop logger is being recreated on every render of the FieldSelector component. Move this outside the component or memoize it to avoid unnecessary object creation on each render.

Copilot uses AI. Check for mistakes.
Comment on lines 96 to 105
const shouldShowUnrecognizedIcon = (field: string): boolean => {
const mapping = fakerSchema?.[field];
if (!mapping) return false;

return (
mapping.fakerMethod === UNRECOGNIZED_FAKER_METHOD ||
!isValidFakerMethod(mapping.fakerMethod, mapping.fakerArgs, logger)
.isValid
);
};
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

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

The shouldShowUnrecognizedIcon function is being recreated on every render and called for each field in the list. Consider memoizing this function with useCallback and/or computing the results for all fields once using useMemo to avoid repeated validation calls.

Copilot uses AI. Check for mistakes.
@kylelai1 kylelai1 requested review from jcobis and kpamaran October 24, 2025 14:06
fakerSchema,
}) => {
const darkMode = useDarkMode();
const logger = createNoopLogger();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why was noop logger added here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We are already logging when we validate the faker schema when we generate the faker method mappings, so we don't need to log again here when we are validating the faker schema for the "warning" icons.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean, I guess it's fair it's not really obvious unless you look at the usage, but noop logger wasn't created to plug into functions just to satisfy the interface outside the test code 🙂

If you want to use this validation method in the context where logger is not available or not needed, it would be better to change the interface and make it clear that the function can be used without the logger when needed. But also as I mentioned below it doesn't look like you need to do this check because, being an expensive operation, backend response validation and mapping already happened and in UI all methods are either valid or UNRECOGNIZED_FAKER_METHOD, so you don't need to use this check here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah good point, we were already thorough there so we don't need to be doing another check here for the valid faker method. Good thing is that we don't need the noop logger, but yeah, you're right, the function should have logger as an optional arg if it isn't needed.

Comment on lines 100 to 104
return (
mapping.fakerMethod === UNRECOGNIZED_FAKER_METHOD ||
!isValidFakerMethod(mapping.fakerMethod, mapping.fakerArgs, logger)
.isValid
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Invalid faker methods are mapped to unrecognized, so this second check is not doing anything

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll remove the redundancy and simplify things here a bit

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.

LGTM, someone from growth should also take a look probably

@jcobis
Copy link
Collaborator

jcobis commented Oct 27, 2025

Note: that tooltip copy is being updated anyway: #7495

@jcobis
Copy link
Collaborator

jcobis commented Oct 27, 2025

Just want to confirm that this was done, from the ticket description, since I noticed some inconsistency with the fallback method appearing for fields marked unrecognized: Confirm fallback logic for "Unrecognized" fields works to provide a default faker method.
i.e. for unrecognized fields, are defaults from script-generation-utils::getDefaultFakerMethod successfully supplied to the output script?

@kylelai1
Copy link
Collaborator Author

Just want to confirm that this was done, from the ticket description, since I noticed some inconsistency with the fallback method appearing for fields marked unrecognized: Confirm fallback logic for "Unrecognized" fields works to provide a default faker method. i.e. for unrecognized fields, are defaults from script-generation-utils::getDefaultFakerMethod successfully supplied to the output script?

Yes, I've confirmed the default fallback faker method applies here. Changed the string comparison to use our constant for "Unrecognized"

@kylelai1 kylelai1 merged commit 23270b2 into main Oct 27, 2025
54 of 56 checks passed
@kylelai1 kylelai1 deleted the CLOUDP-352955 branch October 27, 2025 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants