@@ -25,6 +25,7 @@ export interface QueryEditorProps {
25
25
indexPatterns : Array < IIndexPattern | string > ;
26
26
dataSource ?: DataSource ;
27
27
query : Query ;
28
+ dataSourceContainerRef ?: React . RefCallback < HTMLDivElement > ;
28
29
containerRef ?: React . RefCallback < HTMLDivElement > ;
29
30
settings : Settings ;
30
31
disableAutoFocus ?: boolean ;
@@ -54,6 +55,7 @@ interface Props extends QueryEditorProps {
54
55
55
56
interface State {
56
57
isDataSourcesVisible : boolean ;
58
+ isDataSetsVisible : boolean ;
57
59
isSuggestionsVisible : boolean ;
58
60
index : number | null ;
59
61
suggestions : QuerySuggestion [ ] ;
@@ -77,7 +79,8 @@ const KEY_CODES = {
77
79
// eslint-disable-next-line import/no-default-export
78
80
export default class QueryEditorUI extends Component < Props , State > {
79
81
public state : State = {
80
- isDataSourcesVisible : true ,
82
+ isDataSourcesVisible : false ,
83
+ isDataSetsVisible : true ,
81
84
isSuggestionsVisible : false ,
82
85
index : null ,
83
86
suggestions : [ ] ,
@@ -212,9 +215,9 @@ export default class QueryEditorUI extends Component<Props, State> {
212
215
: undefined ;
213
216
this . onChange ( newQuery , dateRange ) ;
214
217
this . onSubmit ( newQuery , dateRange ) ;
218
+ this . setState ( { isDataSetsVisible : enhancement ?. searchBar ?. showDataSetsSelector ?? true } ) ;
215
219
this . setState ( {
216
220
isDataSourcesVisible : enhancement ?. searchBar ?. showDataSourcesSelector ?? true ,
217
- isDataSetsVisible : enhancement ?. searchBar ?. showDataSetsSelector ?? true ,
218
221
} ) ;
219
222
} ;
220
223
@@ -228,15 +231,19 @@ export default class QueryEditorUI extends Component<Props, State> {
228
231
private initDataSourcesVisibility = ( ) => {
229
232
if ( this . componentIsUnmounting ) return ;
230
233
231
- return this . props . settings . getQueryEnhancements ( this . props . query . language ) ?. searchBar
232
- ?. showDataSourcesSelector ;
234
+ const isDataSourcesVisible =
235
+ this . props . settings . getQueryEnhancements ( this . props . query . language ) ?. searchBar
236
+ ?. showDataSourcesSelector ?? true ;
237
+ this . setState ( { isDataSourcesVisible } ) ;
233
238
} ;
234
239
235
240
private initDataSetsVisibility = ( ) => {
236
241
if ( this . componentIsUnmounting ) return ;
237
242
238
- return this . props . settings . getQueryEnhancements ( this . props . query . language ) ?. searchBar
239
- ?. showDataSetsSelector ;
243
+ const isDataSetsVisible =
244
+ this . props . settings . getQueryEnhancements ( this . props . query . language ) ?. searchBar
245
+ ?. showDataSetsSelector ?? true ;
246
+ this . setState ( { isDataSetsVisible } ) ;
240
247
} ;
241
248
242
249
public onMouseEnterSuggestion = ( index : number ) => {
@@ -253,10 +260,8 @@ export default class QueryEditorUI extends Component<Props, State> {
253
260
254
261
this . initPersistedLog ( ) ;
255
262
// this.fetchIndexPatterns().then(this.updateSuggestions);
256
- this . setState ( {
257
- isDataSourcesVisible : this . initDataSourcesVisibility ( ) || true ,
258
- isDataSetsVisible : this . initDataSetsVisibility ( ) || true ,
259
- } ) ;
263
+ this . initDataSourcesVisibility ( ) ;
264
+ this . initDataSetsVisibility ( ) ;
260
265
}
261
266
262
267
public componentDidUpdate ( prevProps : Props ) {
@@ -291,6 +296,11 @@ export default class QueryEditorUI extends Component<Props, State> {
291
296
< EuiFlexItem grow = { false } >
292
297
< EuiFlexGroup gutterSize = "xs" alignItems = "center" className = { `${ className } __wrapper` } >
293
298
< EuiFlexItem grow = { false } > { this . props . prepend } </ EuiFlexItem >
299
+ { this . state . isDataSourcesVisible && (
300
+ < EuiFlexItem grow = { false } className = { `${ className } __dataSourceWrapper` } >
301
+ < div ref = { this . props . dataSourceContainerRef } />
302
+ </ EuiFlexItem >
303
+ ) }
294
304
< EuiFlexItem grow = { false } className = { `${ className } __languageWrapper` } >
295
305
< QueryLanguageSelector
296
306
language = { this . props . query . language }
@@ -299,8 +309,8 @@ export default class QueryEditorUI extends Component<Props, State> {
299
309
appName = { this . services . appName }
300
310
/>
301
311
</ EuiFlexItem >
302
- { this . state . isDataSourcesVisible && (
303
- < EuiFlexItem grow = { false } className = { `${ className } __dataSourceWrapper ` } >
312
+ { this . state . isDataSetsVisible && (
313
+ < EuiFlexItem grow = { false } className = { `${ className } __dataSetWrapper ` } >
304
314
< div ref = { this . props . containerRef } />
305
315
</ EuiFlexItem >
306
316
) }
0 commit comments