@@ -34,7 +34,7 @@ export const QueryEditor = ({ query, onChange, onRunQuery, datasource, range, ap
3434 query = { query }
3535 range = { range || getDefaultTimeRange ( ) }
3636 >
37- < QueryEditorForm value = { query } />
37+ < QueryEditorForm value = { query } onRunQuery = { onRunQuery } />
3838 </ ElasticsearchProvider >
3939 ) ;
4040} ;
@@ -54,21 +54,33 @@ export const useSearchableFields = getHook(SearchableFieldsContext)
5454
5555interface Props {
5656 value : ElasticsearchQuery ;
57+ onRunQuery : ( query : string ) => void
5758}
5859
59- export const ElasticSearchQueryField = ( { value, onChange } : { value ?: string ; onChange : ( v : string ) => void } ) => {
60+ type ElasticSearchQueryFieldProps = {
61+ value ?: string ;
62+ onChange : ( v : string ) => void
63+ onSubmit : ( v : string ) => void
64+ }
65+ export const ElasticSearchQueryField = ( { value, onChange, onSubmit } : ElasticSearchQueryFieldProps ) => {
6066 const styles = useStyles2 ( getStyles ) ;
6167 const datasource = useDatasource ( )
6268 const { getSuggestions } = useDatasourceFields ( datasource ) ;
6369
6470 return (
6571 < div className = { styles . queryItem } >
66- < LuceneQueryEditor placeholder = "Enter a lucene query" value = { value || '' } autocompleter = { getSuggestions } onChange = { onChange } />
72+ < LuceneQueryEditor
73+ placeholder = "Enter a lucene query - Type Shift-Enter to run query, Ctrl-Space to autocomplete"
74+ value = { value || '' }
75+ autocompleter = { getSuggestions }
76+ onChange = { onChange }
77+ onSubmit = { onSubmit }
78+ />
6779 </ div >
6880 ) ;
6981} ;
7082
71- const QueryEditorForm = ( { value } : Props ) => {
83+ const QueryEditorForm = ( { value, onRunQuery } : Props ) => {
7284 const dispatch = useDispatch ( ) ;
7385 const nextId = useNextId ( ) ;
7486 const styles = useStyles2 ( getStyles ) ;
@@ -87,7 +99,7 @@ const QueryEditorForm = ({ value }: Props) => {
8799 </ div >
88100 < div className = { styles . root } >
89101 < InlineLabel width = { 17 } > Lucene Query</ InlineLabel >
90- < ElasticSearchQueryField onChange = { ( query ) => dispatch ( changeQuery ( query ) ) } value = { value ?. query } />
102+ < ElasticSearchQueryField onChange = { ( query ) => dispatch ( changeQuery ( query ) ) } value = { value ?. query } onSubmit = { onRunQuery } />
91103 </ div >
92104
93105 < MetricAggregationsEditor nextId = { nextId } />
0 commit comments