1
1
import defaults from 'lodash/defaults' ;
2
2
import React , { useState } from 'react' ;
3
- import {
4
- InlineFieldRow ,
5
- InlineField ,
6
- Segment ,
7
- Input ,
8
- Select ,
9
- RadioButtonGroup ,
10
- CodeEditor ,
11
- useTheme ,
12
- InfoBox ,
13
- } from '@grafana/ui' ;
3
+ import { InlineFieldRow , InlineField , Segment , RadioButtonGroup , CodeEditor , useTheme , InfoBox } from '@grafana/ui' ;
14
4
import { QueryEditorProps } from '@grafana/data' ;
15
5
import { JsonApiQuery , JsonApiDataSourceOptions , defaultQuery } from '../types' ;
16
6
import { KeyValueEditor } from './KeyValueEditor' ;
@@ -19,6 +9,7 @@ import { css } from 'emotion';
19
9
import { Pair } from '../types' ;
20
10
import { JsonDataSource } from 'datasource' ;
21
11
import { FieldEditor } from './FieldEditor' ;
12
+ import { PathEditor } from './PathEditor' ;
22
13
23
14
// Display a warning message when user adds any of the following headers.
24
15
const sensitiveHeaders = [ 'authorization' , 'proxy-authorization' , 'x-api-key' ] ;
@@ -34,10 +25,10 @@ export const QueryEditor: React.FC<Props> = ({ onRunQuery, onChange, limitFields
34
25
35
26
const query = defaults ( props . query , defaultQuery ) ;
36
27
37
- const onMethodChange = ( method : string ) => {
38
- onChange ( { ...query , method } ) ;
39
- onRunQuery ( ) ;
40
- } ;
28
+ // const onMethodChange = (method: string) => {
29
+ // onChange({ ...query, method });
30
+ // onRunQuery();
31
+ // };
41
32
42
33
const onBodyChange = ( body : string ) => {
43
34
onChange ( { ...query , body } ) ;
@@ -72,25 +63,18 @@ export const QueryEditor: React.FC<Props> = ({ onRunQuery, onChange, limitFields
72
63
{
73
64
title : 'Path' ,
74
65
content : (
75
- < InlineFieldRow >
76
- < InlineField >
77
- < Select
78
- value = { query . method }
79
- options = { [
80
- { label : 'GET' , value : 'GET' } ,
81
- { label : 'POST' , value : 'POST' } ,
82
- ] }
83
- onChange = { ( v ) => onMethodChange ( v . value ?? 'GET' ) }
84
- />
85
- </ InlineField >
86
- < InlineField grow >
87
- < Input
88
- placeholder = "/orders/${orderId}"
89
- value = { query . urlPath }
90
- onChange = { ( e ) => onChange ( { ...query , urlPath : e . currentTarget . value } ) }
91
- />
92
- </ InlineField >
93
- </ InlineFieldRow >
66
+ < PathEditor
67
+ method = { query . method ?? 'GET' }
68
+ onMethodChange = { ( method ) => {
69
+ onChange ( { ...query , method } ) ;
70
+ onRunQuery ( ) ;
71
+ } }
72
+ path = { query . urlPath ?? '' }
73
+ onPathChange = { ( path ) => {
74
+ onChange ( { ...query , urlPath : path } ) ;
75
+ onRunQuery ( ) ;
76
+ } }
77
+ />
94
78
) ,
95
79
} ,
96
80
{
@@ -153,9 +137,6 @@ export const QueryEditor: React.FC<Props> = ({ onRunQuery, onChange, limitFields
153
137
/>
154
138
) }
155
139
</ AutoSizer >
156
- { /* <InlineField label="Body" tooltip="foo" grow>
157
- <JsonQueryField value={body || ''} onChange={} />
158
- </InlineField> */ }
159
140
</ InlineFieldRow >
160
141
</ >
161
142
) ,
0 commit comments