@@ -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,7 +215,10 @@ export default class QueryEditorUI extends Component<Props, State> {
212
215
: undefined ;
213
216
this . onChange ( newQuery , dateRange ) ;
214
217
this . onSubmit ( newQuery , dateRange ) ;
215
- this . setState ( { isDataSourcesVisible : enhancement ?. searchBar ?. showDataSourceSelector ?? true } ) ;
218
+ this . setState ( { isDataSetsVisible : enhancement ?. searchBar ?. showDataSetsSelector ?? true } ) ;
219
+ this . setState ( {
220
+ isDataSourcesVisible : enhancement ?. searchBar ?. showDataSourcesSelector ?? true ,
221
+ } ) ;
216
222
} ;
217
223
218
224
private initPersistedLog = ( ) => {
@@ -227,10 +233,19 @@ export default class QueryEditorUI extends Component<Props, State> {
227
233
228
234
const isDataSourcesVisible =
229
235
this . props . settings . getQueryEnhancements ( this . props . query . language ) ?. searchBar
230
- ?. showDataSourceSelector ?? true ;
236
+ ?. showDataSourcesSelector ?? true ;
231
237
this . setState ( { isDataSourcesVisible } ) ;
232
238
} ;
233
239
240
+ private initDataSetsVisibility = ( ) => {
241
+ if ( this . componentIsUnmounting ) return ;
242
+
243
+ const isDataSetsVisible =
244
+ this . props . settings . getQueryEnhancements ( this . props . query . language ) ?. searchBar
245
+ ?. showDataSetsSelector ?? true ;
246
+ this . setState ( { isDataSetsVisible } ) ;
247
+ } ;
248
+
234
249
public onMouseEnterSuggestion = ( index : number ) => {
235
250
this . setState ( { index } ) ;
236
251
} ;
@@ -246,6 +261,7 @@ export default class QueryEditorUI extends Component<Props, State> {
246
261
this . initPersistedLog ( ) ;
247
262
// this.fetchIndexPatterns().then(this.updateSuggestions);
248
263
this . initDataSourcesVisibility ( ) ;
264
+ this . initDataSetsVisibility ( ) ;
249
265
}
250
266
251
267
public componentDidUpdate ( prevProps : Props ) {
@@ -280,6 +296,11 @@ export default class QueryEditorUI extends Component<Props, State> {
280
296
< EuiFlexItem grow = { false } >
281
297
< EuiFlexGroup gutterSize = "xs" alignItems = "center" className = { `${ className } __wrapper` } >
282
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
+ ) }
283
304
< EuiFlexItem grow = { false } className = { `${ className } __languageWrapper` } >
284
305
< QueryLanguageSelector
285
306
language = { this . props . query . language }
@@ -288,8 +309,8 @@ export default class QueryEditorUI extends Component<Props, State> {
288
309
appName = { this . services . appName }
289
310
/>
290
311
</ EuiFlexItem >
291
- { this . state . isDataSourcesVisible && (
292
- < EuiFlexItem grow = { false } className = { `${ className } __dataSourceWrapper ` } >
312
+ { this . state . isDataSetsVisible && (
313
+ < EuiFlexItem grow = { false } className = { `${ className } __dataSetWrapper ` } >
293
314
< div ref = { this . props . containerRef } />
294
315
</ EuiFlexItem >
295
316
) }
0 commit comments