44 spacing ,
55 Accordion ,
66 Body ,
7- palette ,
8- Button ,
97 RadioBoxGroup ,
108 RadioBox ,
119} from '@mongodb-js/compass-components' ;
@@ -20,6 +18,7 @@ import {
2018 useConnectionSupports ,
2119} from '@mongodb-js/compass-connections/provider' ;
2220import { usePreference } from 'compass-preferences-model/provider' ;
21+ import IndexFlowSection from './index-flow-section' ;
2322
2423const createIndexModalFieldsStyles = css ( {
2524 margin : `${ spacing [ 600 ] } px 0 ${ spacing [ 800 ] } px 0` ,
@@ -37,19 +36,6 @@ const createIndexModalFlowsStyles = css({
3736 marginBottom : spacing [ 600 ] ,
3837} ) ;
3938
40- const plainBorderedCalloutStyles = css ( {
41- border : `1px solid ${ palette . gray . light2 } ` ,
42- borderRadius : '12px' ,
43- padding : spacing [ 600 ] ,
44- minHeight : '132px' ,
45- } ) ;
46-
47- const coveredQueriesButtonStyles = css ( {
48- height : spacing [ 600 ] + 4 ,
49- float : 'right' ,
50- marginTop : spacing [ 400 ] ,
51- } ) ;
52-
5339export type CreateIndexFormProps = {
5440 namespace : string ;
5541 fields : Field [ ] ;
@@ -94,67 +80,106 @@ function CreateIndexForm({
9480 } ) ;
9581 } , [ schemaFields ] ) ;
9682
97- return (
98- < >
83+ const showIndexesGuidanceIndexFlow =
84+ showIndexesGuidanceVariant && currentTab === 'IndexFlow' ;
85+
86+ // Default / Control view
87+ if ( ! showIndexesGuidanceVariant ) {
88+ return (
9989 < div
10090 className = { createIndexModalFieldsStyles }
10191 data-testid = "create-index-form"
10292 >
103- { showIndexesGuidanceVariant ? (
104- < RadioBoxGroup
105- aria-labelledby = "index-flows"
106- data-testid = "create-index-form-flows"
107- id = "create-index-form-flows"
108- onChange = { ( e ) => {
109- onTabClick ( e . target . value as Tab ) ;
110- } }
111- value = { currentTab }
112- className = { createIndexModalFlowsStyles }
113- >
114- < RadioBox id = "index-flow" value = { 'IndexFlow' } >
115- Start with an Index
116- </ RadioBox >
117- < RadioBox id = "query-flow" value = { 'QueryFlow' } >
118- Start with a Query
119- </ RadioBox >
120- </ RadioBoxGroup >
121- ) : (
122- < Body weight = "medium" className = { indexFieldsHeaderStyles } >
123- Index fields
124- </ Body >
125- ) }
93+ < Body weight = "medium" className = { indexFieldsHeaderStyles } >
94+ Index fields
95+ </ Body >
96+ { fields . length > 0 &&
97+ ( ! showIndexesGuidanceVariant || showIndexesGuidanceIndexFlow ) ? (
98+ < CreateIndexFields
99+ schemaFields = { schemaFieldNames }
100+ fields = { fields }
101+ serverVersion = { serverVersion }
102+ isRemovable = { ! ( fields . length > 1 ) }
103+ onSelectFieldNameClick = { onSelectFieldNameClick }
104+ onSelectFieldTypeClick = { onSelectFieldTypeClick }
105+ onAddFieldClick = { onAddFieldClick }
106+ onRemoveFieldClick = { onRemoveFieldClick }
107+ />
108+ ) : null }
126109
127- { /* Only show the fields if user is in the Start with an index flow or if they're in the control */ }
128- < div
129- className = {
130- showIndexesGuidanceVariant ? plainBorderedCalloutStyles : ''
131- }
110+ < Accordion
111+ data-testid = "create-index-modal-toggle-options"
112+ text = "Options"
132113 >
133- { fields . length > 0 &&
134- ( ! showIndexesGuidanceVariant || currentTab === 'IndexFlow' ) ? (
135- < CreateIndexFields
136- schemaFields = { schemaFieldNames }
137- fields = { fields }
138- serverVersion = { serverVersion }
139- isRemovable = { ! ( fields . length > 1 ) }
140- onSelectFieldNameClick = { onSelectFieldNameClick }
141- onSelectFieldTypeClick = { onSelectFieldTypeClick }
142- onAddFieldClick = { onAddFieldClick }
143- onRemoveFieldClick = { onRemoveFieldClick }
144- />
145- ) : null }
146- < Button
147- className = { coveredQueriesButtonStyles }
148- onClick = { ( ) => {
149- // TODO in CLOUDP-311782
150- // TODO in CLOUDP-311783
151- } }
114+ < div
115+ data-testid = "create-index-modal-options"
116+ className = { createIndexModalOptionStyles }
152117 >
153- Show me covered queries
154- </ Button >
155- </ div >
118+ < CheckboxInput name = "unique" > </ CheckboxInput >
119+ < CollapsibleInput name = "name" > </ CollapsibleInput >
120+ < CollapsibleInput name = "expireAfterSeconds" > </ CollapsibleInput >
121+ < CollapsibleInput name = "partialFilterExpression" > </ CollapsibleInput >
122+ < CollapsibleInput name = "wildcardProjection" > </ CollapsibleInput >
123+ < CollapsibleInput name = "collation" > </ CollapsibleInput >
124+ { hasColumnstoreIndexesSupport ( serverVersion ) && (
125+ < CollapsibleInput name = "columnstoreProjection" > </ CollapsibleInput >
126+ ) }
127+ < CheckboxInput name = "sparse" > </ CheckboxInput >
128+ { showRollingIndexOption && (
129+ < CheckboxInput name = "buildInRollingProcess" > </ CheckboxInput >
130+ ) }
131+ </ div >
132+ </ Accordion >
156133 </ div >
134+ ) ;
135+ }
136+
137+ // Indexes Guidance Variant View
138+ return (
139+ < >
140+ < div
141+ className = { createIndexModalFieldsStyles }
142+ data-testid = "create-index-form"
143+ >
144+ < RadioBoxGroup
145+ aria-labelledby = "index-flows"
146+ data-testid = "create-index-form-flows"
147+ id = "create-index-form-flows"
148+ onChange = { ( e ) => {
149+ onTabClick ( e . target . value as Tab ) ;
150+ } }
151+ value = { currentTab }
152+ className = { createIndexModalFlowsStyles }
153+ >
154+ < RadioBox id = "index-flow" value = { 'IndexFlow' } >
155+ Start with an Index
156+ </ RadioBox >
157+ < RadioBox id = "query-flow" value = { 'QueryFlow' } >
158+ Start with a Query
159+ </ RadioBox >
160+ </ RadioBoxGroup >
161+ </ div >
162+
163+ { showIndexesGuidanceIndexFlow && (
164+ < IndexFlowSection
165+ createIndexFieldsComponent = {
166+ fields . length > 0 ? (
167+ < CreateIndexFields
168+ schemaFields = { schemaFieldNames }
169+ fields = { fields }
170+ serverVersion = { serverVersion }
171+ isRemovable = { ! ( fields . length > 1 ) }
172+ onSelectFieldNameClick = { onSelectFieldNameClick }
173+ onSelectFieldTypeClick = { onSelectFieldTypeClick }
174+ onAddFieldClick = { onAddFieldClick }
175+ onRemoveFieldClick = { onRemoveFieldClick }
176+ />
177+ ) : null
178+ }
179+ />
180+ ) }
157181
182+ { /* TODO in CLOUDP-314036: update the accordion design */ }
158183 < Accordion data-testid = "create-index-modal-toggle-options" text = "Options" >
159184 < div
160185 data-testid = "create-index-modal-options"
0 commit comments