-
Notifications
You must be signed in to change notification settings - Fork 239
feat(compass-collection): Connect schema redux state to modal and filter collections based on nesting depth - CLOUDP-342665 #7283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
a298132
a3052fc
fb8505b
031c2a3
4050da7
5a4fbfc
a133e0a
0a0ab7b
18c4d75
932193f
fc34475
137267c
73e7a45
73cb0b1
e37fc16
e0c9a0a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,8 @@ type CollectionHeaderActionsProps = { | |
| sourceName?: string; | ||
| sourcePipeline?: unknown[]; | ||
| onOpenMockDataModal: () => void; | ||
| hasData: boolean; | ||
| maxNestingDepth: number; | ||
| }; | ||
|
|
||
| const CollectionHeaderActions: React.FunctionComponent< | ||
|
|
@@ -58,6 +60,8 @@ const CollectionHeaderActions: React.FunctionComponent< | |
| sourceName, | ||
| sourcePipeline, | ||
| onOpenMockDataModal, | ||
| hasData, | ||
| maxNestingDepth, | ||
| }: CollectionHeaderActionsProps) => { | ||
| const connectionInfo = useConnectionInfo(); | ||
| const { id: connectionId, atlasMetadata } = connectionInfo; | ||
|
|
@@ -84,10 +88,8 @@ const CollectionHeaderActions: React.FunctionComponent< | |
| isInMockDataTreatmentVariant && | ||
| atlasMetadata && // Only show in Atlas | ||
| !isReadonly && // Don't show for readonly collections (views) | ||
| !sourceName; // sourceName indicates it's a view | ||
| // TODO: CLOUDP-337090: also filter out overly nested collections | ||
|
|
||
| const hasData = true; // TODO: CLOUDP-337090 | ||
| !sourceName && // sourceName indicates it's a view | ||
| maxNestingDepth < 4; // Filter out overly nested collections (4+ levels) | ||
|
||
|
|
||
| return ( | ||
| <div | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,8 @@ import { getConnectionTitle } from '@mongodb-js/connection-info'; | |
| import MockDataGeneratorModal from '../mock-data-generator-modal/mock-data-generator-modal'; | ||
| import { connect } from 'react-redux'; | ||
| import { openMockDataGeneratorModal } from '../../modules/collection-tab'; | ||
| import type { CollectionState } from '../../modules/collection-tab'; | ||
| import { SCHEMA_ANALYSIS_STATE_COMPLETE } from '../../schema-analysis-types'; | ||
|
|
||
| const collectionHeaderStyles = css({ | ||
| padding: spacing[400], | ||
|
|
@@ -62,6 +64,8 @@ type CollectionHeaderProps = { | |
| editViewName?: string; | ||
| sourcePipeline?: unknown[]; | ||
| onOpenMockDataModal: () => void; | ||
| hasData: boolean; | ||
|
||
| maxNestingDepth: number; | ||
| }; | ||
|
|
||
| const getInsightsForPipeline = (pipeline: any[], isAtlas: boolean) => { | ||
|
|
@@ -97,6 +101,8 @@ const CollectionHeader: React.FunctionComponent<CollectionHeaderProps> = ({ | |
| editViewName, | ||
| sourcePipeline, | ||
| onOpenMockDataModal, | ||
| hasData, | ||
| maxNestingDepth, | ||
| }) => { | ||
| const darkMode = useDarkMode(); | ||
| const showInsights = usePreference('showInsights'); | ||
|
|
@@ -174,14 +180,32 @@ const CollectionHeader: React.FunctionComponent<CollectionHeaderProps> = ({ | |
| sourceName={sourceName} | ||
| sourcePipeline={sourcePipeline} | ||
| onOpenMockDataModal={onOpenMockDataModal} | ||
| hasData={hasData} | ||
| maxNestingDepth={maxNestingDepth} | ||
| /> | ||
| </div> | ||
| <MockDataGeneratorModal /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| const ConnectedCollectionHeader = connect(undefined, { | ||
| const mapStateToProps = (state: CollectionState) => { | ||
| const { schemaAnalysis } = state; | ||
|
|
||
| return { | ||
| hasData: | ||
| schemaAnalysis.status === SCHEMA_ANALYSIS_STATE_COMPLETE && | ||
| schemaAnalysis.processedSchema && | ||
|
||
| Object.keys(schemaAnalysis.processedSchema).length > 0, | ||
| maxNestingDepth: | ||
| schemaAnalysis.status === SCHEMA_ANALYSIS_STATE_COMPLETE && | ||
| schemaAnalysis.schemaMetadata | ||
| ? schemaAnalysis.schemaMetadata.maxNestingDepth | ||
| : 0, | ||
| }; | ||
| }; | ||
|
|
||
| const ConnectedCollectionHeader = connect(mapStateToProps, { | ||
| onOpenMockDataModal: openMockDataGeneratorModal, | ||
| })(CollectionHeader); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.