@@ -43,19 +43,31 @@ import {
43
43
} from '@elastic/eui' ;
44
44
import { FormattedMessage } from '@osd/i18n/react' ;
45
45
import React , { useState } from 'react' ;
46
- import { Observable } from 'rxjs' ;
47
46
import { useObservable } from 'react-use' ;
48
47
import { useOpenSearchDashboards } from '../../../../opensearch_dashboards_react/public' ;
48
+ import { IDataPluginServices } from '../../types' ;
49
49
50
50
interface Props {
51
51
language : string ;
52
52
onSelectLanguage : ( newLanguage : string ) => void ;
53
53
anchorPosition ?: PopoverAnchorPosition ;
54
- currentApp$ ?: Observable < string | undefined > ;
55
- useNewQuerySelector ?: boolean ;
56
54
}
57
55
58
56
export function QueryLanguageSwitcher ( props : Props ) {
57
+ const opensearchDashboards = useOpenSearchDashboards < IDataPluginServices > ( ) ;
58
+ const { application } = opensearchDashboards . services ;
59
+ const currentApp$ = application ?. currentAppId$ ;
60
+
61
+ let useNewQuerySelector ;
62
+ application ?. applications$ . subscribe ( ( applications ) => {
63
+ applications . forEach ( ( applicationEntry ) => {
64
+ if ( applicationEntry . id === 'observability-dashboards' ) {
65
+ useNewQuerySelector = true ;
66
+ return ;
67
+ }
68
+ } ) ;
69
+ } ) ;
70
+
59
71
const dataExplorerOptions = [
60
72
{
61
73
label : 'DQL' ,
@@ -102,7 +114,7 @@ export function QueryLanguageSwitcher(props: Props) {
102
114
setSelectedLanguage ( newLanguage ) ;
103
115
} ;
104
116
105
- if ( useObservable ( props . currentApp$ ! , '' ) === 'data-explorer' && props . useNewQuerySelector ) {
117
+ if ( useObservable ( currentApp$ ! , '' ) === 'data-explorer' && useNewQuerySelector ) {
106
118
return (
107
119
< EuiComboBox
108
120
className = "languageSwitcher"
0 commit comments