File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 1
1
import { TimeRange } from '@grafana/data' ;
2
2
import { JsonDataSource } from 'datasource' ;
3
+ import defaults from 'lodash/defaults' ;
3
4
import React from 'react' ;
4
- import { JsonApiQuery } from '../types' ;
5
+ import { defaultQuery , JsonApiQuery } from '../types' ;
5
6
import { QueryEditor } from './QueryEditor' ;
6
7
7
8
interface VariableQueryProps {
@@ -15,6 +16,8 @@ interface VariableQueryProps {
15
16
export const VariableQueryEditor : React . FC < VariableQueryProps > = ( props ) => {
16
17
const { query, onChange } = props ;
17
18
19
+ const q = defaults ( query , defaultQuery ) ;
20
+
18
21
const saveQuery = ( newQuery : JsonApiQuery ) => {
19
22
if ( newQuery ) {
20
23
onChange ( newQuery , newQuery . fields [ 0 ] . jsonPath ) ;
@@ -26,7 +29,7 @@ export const VariableQueryEditor: React.FC<VariableQueryProps> = (props) => {
26
29
{ ...props }
27
30
onRunQuery = { ( ) => { } }
28
31
onChange = { saveQuery }
29
- query = { query }
32
+ query = { q }
30
33
limitFields = { 2 }
31
34
editorContext = "variables"
32
35
/>
You can’t perform that action at this time.
0 commit comments