@@ -72,6 +72,8 @@ type ConnectionTabConnectedProps = {
72
72
stats : CollectionState [ 'stats' ] ;
73
73
onTabClick : ( tab : CollectionSubtab ) => void ;
74
74
} ;
75
+
76
+ // TODO(COMPASS-7937): Wrong place for these types and type descriptions
75
77
// Props definition when using the component
76
78
type ConnectionTabExpectedProps = {
77
79
/**
@@ -129,8 +131,6 @@ const CollectionTabWithMetadata: React.FunctionComponent<
129
131
} ) ;
130
132
}
131
133
} , [ currentTab , track ] ) ;
132
-
133
- const QueryBarPlugin = useCollectionQueryBar ( ) ;
134
134
const pluginTabs = useCollectionSubTabs ( ) ;
135
135
const pluginModals = useCollectionScopedModals ( ) ;
136
136
@@ -157,77 +157,75 @@ const CollectionTabWithMetadata: React.FunctionComponent<
157
157
const activeTabIndex = tabs . findIndex ( ( tab ) => tab . name === currentTab ) ;
158
158
159
159
return (
160
- < QueryBarPlugin { ...pluginProps } >
161
- < div className = { collectionStyles } data-testid = "collection" >
162
- < div className = { collectionContainerStyles } >
163
- < CollectionHeader
164
- editViewName = { editViewName }
165
- { ...collectionMetadata }
166
- > </ CollectionHeader >
167
- < TabNavBar
168
- data-testid = "collection-tabs"
169
- aria-label = "Collection Tabs"
170
- tabNames = { tabs . map ( ( tab ) => tab . name ) }
171
- tabLabels = { tabs . map ( ( tab ) => {
172
- // We don't show stats, when the collection is a timeseries or a view
173
- // or when the view is being edited
174
- const hideStats =
175
- collectionMetadata . isTimeSeries ||
176
- collectionMetadata . sourceName ||
177
- editViewName ;
178
- if ( hideStats ) {
179
- return tab . name ;
180
- }
181
- if ( tab . name === 'Documents' ) {
182
- return (
183
- < TabTitleWithStats
184
- data-testid = "documents-tab-with-stats"
185
- title = { tab . name }
186
- statsComponent = { < CollectionDocumentsStats stats = { stats } /> }
187
- />
188
- ) ;
189
- }
190
- if ( tab . name === 'Indexes' ) {
191
- return (
192
- < TabTitleWithStats
193
- data-testid = "indexes-tab-with-stats"
194
- title = { tab . name }
195
- statsComponent = { < CollectionIndexesStats stats = { stats } /> }
196
- />
197
- ) ;
198
- }
160
+ < div className = { collectionStyles } data-testid = "collection" >
161
+ < div className = { collectionContainerStyles } >
162
+ < CollectionHeader
163
+ editViewName = { editViewName }
164
+ { ...collectionMetadata }
165
+ > </ CollectionHeader >
166
+ < TabNavBar
167
+ data-testid = "collection-tabs"
168
+ aria-label = "Collection Tabs"
169
+ tabNames = { tabs . map ( ( tab ) => tab . name ) }
170
+ tabLabels = { tabs . map ( ( tab ) => {
171
+ // We don't show stats, when the collection is a timeseries or a view
172
+ // or when the view is being edited
173
+ const hideStats =
174
+ collectionMetadata . isTimeSeries ||
175
+ collectionMetadata . sourceName ||
176
+ editViewName ;
177
+ if ( hideStats ) {
199
178
return tab . name ;
200
- } ) }
201
- views = { tabs . map ( ( tab ) => {
179
+ }
180
+ if ( tab . name === 'Documents' ) {
202
181
return (
203
- < ErrorBoundary
204
- key = { tab . name }
205
- onError = { ( error : Error , errorInfo : unknown ) => {
206
- log . error (
207
- mongoLogId ( 1001000107 ) ,
208
- 'Collection Workspace' ,
209
- 'Rendering collection tab failed' ,
210
- { name : tab . name , error : error . stack , errorInfo }
211
- ) ;
212
- } }
213
- >
214
- { tab . component }
215
- </ ErrorBoundary >
182
+ < TabTitleWithStats
183
+ data-testid = "documents-tab-with-stats"
184
+ title = { tab . name }
185
+ statsComponent = { < CollectionDocumentsStats stats = { stats } /> }
186
+ />
216
187
) ;
217
- } ) }
218
- activeTabIndex = { activeTabIndex }
219
- onTabClicked = { ( id ) => {
220
- onTabClick ( tabs [ id ] . name ) ;
221
- } }
222
- />
223
- </ div >
224
- < div className = { collectionModalContainerStyles } >
225
- { pluginModals . map ( ( ModalPlugin , idx ) => {
226
- return < ModalPlugin key = { idx } { ...pluginProps } > </ ModalPlugin > ;
188
+ }
189
+ if ( tab . name === 'Indexes' ) {
190
+ return (
191
+ < TabTitleWithStats
192
+ data-testid = "indexes-tab-with-stats"
193
+ title = { tab . name }
194
+ statsComponent = { < CollectionIndexesStats stats = { stats } /> }
195
+ />
196
+ ) ;
197
+ }
198
+ return tab . name ;
199
+ } ) }
200
+ views = { tabs . map ( ( tab ) => {
201
+ return (
202
+ < ErrorBoundary
203
+ key = { tab . name }
204
+ onError = { ( error : Error , errorInfo : unknown ) => {
205
+ log . error (
206
+ mongoLogId ( 1001000107 ) ,
207
+ 'Collection Workspace' ,
208
+ 'Rendering collection tab failed' ,
209
+ { name : tab . name , error : error . stack , errorInfo }
210
+ ) ;
211
+ } }
212
+ >
213
+ { tab . component }
214
+ </ ErrorBoundary >
215
+ ) ;
227
216
} ) }
228
- </ div >
217
+ activeTabIndex = { activeTabIndex }
218
+ onTabClicked = { ( id ) => {
219
+ onTabClick ( tabs [ id ] . name ) ;
220
+ } }
221
+ />
229
222
</ div >
230
- </ QueryBarPlugin >
223
+ < div className = { collectionModalContainerStyles } >
224
+ { pluginModals . map ( ( ModalPlugin , idx ) => {
225
+ return < ModalPlugin key = { idx } { ...pluginProps } > </ ModalPlugin > ;
226
+ } ) }
227
+ </ div >
228
+ </ div >
231
229
) ;
232
230
} ;
233
231
@@ -237,15 +235,29 @@ const CollectionTab = ({
237
235
} : Omit < CollectionTabProps , 'collectionMetadata' > & {
238
236
collectionMetadata : CollectionMetadata | null ;
239
237
} ) => {
238
+ const QueryBarPlugin = useCollectionQueryBar ( ) ;
239
+
240
240
if ( ! collectionMetadata ) {
241
241
return null ;
242
242
}
243
243
244
+ const pluginProps = {
245
+ ...collectionMetadata ,
246
+ namespace : props . namespace ,
247
+ aggregation : props . initialAggregation ,
248
+ pipeline : props . initialPipeline ,
249
+ pipelineText : props . initialPipelineText ,
250
+ query : props . initialQuery ,
251
+ editViewName : props . editViewName ,
252
+ } ;
253
+
244
254
return (
245
- < CollectionTabWithMetadata
246
- collectionMetadata = { collectionMetadata }
247
- { ...props }
248
- > </ CollectionTabWithMetadata >
255
+ < QueryBarPlugin { ...pluginProps } >
256
+ < CollectionTabWithMetadata
257
+ collectionMetadata = { collectionMetadata }
258
+ { ...props }
259
+ > </ CollectionTabWithMetadata >
260
+ </ QueryBarPlugin >
249
261
) ;
250
262
} ;
251
263
0 commit comments