Skip to content

Conversation

@jcobis
Copy link
Collaborator

@jcobis jcobis commented Sep 4, 2025

Description

  • Connects Redux hasData state to collection-header-actions component to disable Mock Data Generator button for empty collections
  • Filters deeply nested collections: The Mock Data Generator button now only appears for collections with a maximum nesting depth of 3 levels or fewer. Collections with 4 or more levels of nested documents or arrays will not show the button
  • Gates schema analysis action behind experiment check

Collection Has Data - Button Displayed and Enabled

Screenshot 2025-09-05 at 10 33 10 AM

Empty Collection - Button Disabled

Screenshot 2025-09-05 at 10 44 28 AM

Button Opens Modal

Screenshot 2025-09-05 at 10 33 21 AM

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)

@Copilot Copilot AI review requested due to automatic review settings September 4, 2025 14:33
@jcobis jcobis requested a review from a team as a code owner September 4, 2025 14:33
@github-actions github-actions bot added the feat label Sep 4, 2025
@jcobis jcobis added the no release notes Fix or feature not for release notes label Sep 4, 2025
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@jcobis jcobis requested review from kpamaran and ncarbon September 4, 2025 14:44
editViewName?: string;
sourcePipeline?: unknown[];
onOpenMockDataModal: () => void;
hasData: boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rename hasData to hasSchemaAnalysisData and maxNestingDepth to something like analyzedSchemaDepth (see my other comment)

return {
hasData:
schemaAnalysis.status === SCHEMA_ANALYSIS_STATE_COMPLETE &&
schemaAnalysis.processedSchema &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] Remove the check for schemaAnalysis.processedSchema. The typing of schemaAnalysis dictates if the status is complete then processedSchema will always exist. This suggestion applies to schemaAnalysis.schemaMetadata as well


const hasData = true; // TODO: CLOUDP-337090
!sourceName && // sourceName indicates it's a view
maxNestingDepth < 4; // Filter out overly nested collections (4+ levels)
Copy link
Collaborator

@kpamaran kpamaran Sep 4, 2025

Choose a reason for hiding this comment

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

The name maxNestingDepth sounds like a configuration that should be holding the 4, but maxNestingDepth is computed from calculateSchemaDepth . It should be renamed to schemaDepth while the name maxNestingDepth should be re-purposed *(or renamed using "limit") to hold the magic value

edit*

@jcobis jcobis requested a review from kpamaran September 4, 2025 16:21

const hasData = true; // TODO: CLOUDP-337090
!sourceName && // sourceName indicates it's a view
analyzedSchemaDepth < MAX_COLLECTION_NESTING_DEPTH; // Filter out overly nested collections
Copy link
Collaborator

Choose a reason for hiding this comment

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

q - Do we care about observing when analyzedSchemaDepth < MAX_COLLECTION_NESTING_DEPTH ? If so, might be worth doing this check in the thunk and logging it there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Interesting thought. I can ask analytics

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the meantime, if we do decide on this, how about we include this change as part of the analytics ticket?


const hasData = true; // TODO: CLOUDP-337090
!sourceName && // sourceName indicates it's a view
analyzedSchemaDepth < MAX_COLLECTION_NESTING_DEPTH; // Filter out overly nested collections
Copy link
Collaborator

@kpamaran kpamaran Sep 4, 2025

Choose a reason for hiding this comment

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

nit: max is an inclusive term so use <= and change to 3 instead

@kpamaran
Copy link
Collaborator

kpamaran commented Sep 4, 2025

lgtm. did a line by line level review and tests seems consistent with the repo's code style. of course, deferring to compass-developers for final approval

@jcobis jcobis requested a review from ncarbon September 4, 2025 17:47

const hasData = true; // TODO: CLOUDP-337090
!sourceName && // sourceName indicates it's a view
analyzedSchemaDepth <= MAX_COLLECTION_NESTING_DEPTH; // Filter out overly nested collections
Copy link
Member

Choose a reason for hiding this comment

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

Filters deeply nested collections: The Mock Data Generator button now only appears for collections with a maximum nesting depth of 3 levels or fewer. Collections with 4 or more levels of nested documents or arrays will not show the button

Have we considered instead keeping the button and having it disabled with a tooltip? As a user I could see it being confusing why its showing up on one collection and not another. Additionally if the button is showing and then vanishes.

I'm also a bit curious on this requirement, what is the cause of this limitation? Maybe we can mention that in a comment.

Copy link
Collaborator Author

@jcobis jcobis Sep 8, 2025

Choose a reason for hiding this comment

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

Good question, this was something that I brought up to Designs as well, and where they decided to hide the button. (See Kevin's question about the same thing)

Copy link
Member

Choose a reason for hiding this comment

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

Left a comment in that thread, I think we should bring it back up with design with the considerations. Right now this would be introducing some confusing UX for users and some UI that asynchronously disappears without indication.

Copy link
Member

Choose a reason for hiding this comment

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

Got the okay from design in the thread, not too sure on the text though, left a suggestion but feel free to interpret it in a way that makes sense to you!

At this time we are unable to generate mock data for collections with documents that have a deeply nested schema.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Responded in the Figma thread with a few slight copy suggestions!

}
};

void shouldRunSchemaAnalysis().then((shouldRun) => {
Copy link
Member

Choose a reason for hiding this comment

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

We want to cancel or skip the analysis if the tab is closed / plugin is deactivated and the cleanup method is called. One way other places in Compass do this is with an abort controller which is passed to methods that take it, like sample() in analyzeCollectionSchema(). We can use the addCleanup helper and abort then.

Here's an example:

addCleanup(() => store.dispatch(cancelExportSchema()));

Copy link
Member

@Anemy Anemy left a comment

Choose a reason for hiding this comment

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

Nice! Thanks for also addressing the analysis being run without the experiment here!

@jcobis jcobis merged commit d8a0d16 into main Sep 9, 2025
56 of 60 checks passed
@jcobis jcobis deleted the CLOUDP-342665 branch September 9, 2025 13:28
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