File tree Expand file tree Collapse file tree 4 files changed +12
-7
lines changed
packages/compass-indexes/src Expand file tree Collapse file tree 4 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import { usePreference } from 'compass-preferences-model/provider';
2121import IndexFlowSection from './index-flow-section' ;
2222import QueryFlowSection from './query-flow-section' ;
2323import toNS from 'mongodb-ns' ;
24+ import type { Document as BsonDocument } from 'bson' ;
2425
2526const createIndexModalFieldsStyles = css ( {
2627 margin : `${ spacing [ 600 ] } px 0 ${ spacing [ 800 ] } px 0` ,
@@ -49,7 +50,7 @@ export type CreateIndexFormProps = {
4950 onRemoveFieldClick : ( idx : number ) => void ; // Minus icon.
5051 onTabClick : ( tab : Tab ) => void ;
5152 showIndexesGuidanceVariant ?: boolean ;
52- query : string | null ;
53+ query : BsonDocument | null ;
5354} ;
5455
5556function CreateIndexForm ( {
Original file line number Diff line number Diff line change 77 useFocusRing ,
88 ParagraphSkeleton ,
99} from '@mongodb-js/compass-components' ;
10+ import type { Document as BsonDocument } from 'bson' ;
1011import React , { useMemo , useCallback } from 'react' ;
1112import { css , spacing } from '@mongodb-js/compass-components' ;
1213import {
@@ -106,9 +107,11 @@ const QueryFlowSection = ({
106107 } : SuggestedIndexFetchedProps ) => Promise < void > ;
107108 indexSuggestions : Record < string , number > | null ;
108109 fetchingSuggestionsState : IndexSuggestionState ;
109- initialQuery : string | null ;
110+ initialQuery : BsonDocument | null ;
110111} ) => {
111- const [ inputQuery , setInputQuery ] = React . useState ( initialQuery || '' ) ;
112+ const [ inputQuery , setInputQuery ] = React . useState (
113+ JSON . stringify ( initialQuery ?? '' , null , 2 )
114+ ) ;
112115 const [ hasNewChanges , setHasNewChanges ] = React . useState (
113116 initialQuery !== null
114117 ) ;
Original file line number Diff line number Diff line change @@ -29,13 +29,14 @@ import {
2929import { useConnectionInfoRef } from '@mongodb-js/compass-connections/provider' ;
3030import { usePreference } from 'compass-preferences-model/provider' ;
3131import CreateIndexModalHeader from './create-index-modal-header' ;
32+ import type { Document as BsonDocument } from 'bson' ;
3233
3334type CreateIndexModalProps = React . ComponentProps < typeof CreateIndexForm > & {
3435 isVisible : boolean ;
3536 namespace : string ;
3637 error : string | null ;
3738 currentTab : Tab ;
38- query : string | null ;
39+ query : BsonDocument | null ;
3940 onErrorBannerCloseClick : ( ) => void ;
4041 onCreateIndexClick : ( ) => void ;
4142 onCancelCreateIndexClick : ( ) => void ;
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ type ErrorClearedAction = {
7777
7878export type CreateIndexOpenedAction = {
7979 type : ActionTypes . CreateIndexOpened ;
80- query ?: string ;
80+ query ?: BsonDocument ;
8181} ;
8282
8383type CreateIndexClosedAction = {
@@ -314,7 +314,7 @@ export type State = {
314314 sampleDocs : Array < Document > | null ;
315315
316316 // base query to be used for query flow index creation
317- query : string | null ;
317+ query : BsonDocument | null ;
318318} ;
319319
320320export const INITIAL_STATE : State = {
@@ -339,7 +339,7 @@ function getInitialState(): State {
339339
340340//-------
341341
342- export const createIndexOpened = ( query ?: BsonDocument ) => ( {
342+ export const createIndexOpened = ( query ?: Document ) => ( {
343343 type : ActionTypes . CreateIndexOpened ,
344344 query,
345345} ) ;
You can’t perform that action at this time.
0 commit comments