|
1 | 1 | import React, { ChangeEvent } from 'react';
|
2 |
| -import { InlineFormLabel, Input, Legend } from '@grafana/ui'; |
| 2 | +import { LegacyForms, DataSourceHttpSettings } from '@grafana/ui'; |
| 3 | + |
3 | 4 | import { DataSourcePluginOptionsEditorProps } from '@grafana/data';
|
4 | 5 | import { JsonApiDataSourceOptions } from './types';
|
5 | 6 | import {} from '@emotion/core';
|
6 | 7 |
|
| 8 | +const { Input, FormField } = LegacyForms; |
| 9 | + |
7 | 10 | interface Props extends DataSourcePluginOptionsEditorProps<JsonApiDataSourceOptions> {}
|
8 | 11 |
|
9 | 12 | export const ConfigEditor: React.FC<Props> = ({ options, onOptionsChange }) => {
|
10 |
| - const onUrlChange = (e: ChangeEvent<HTMLInputElement>) => { |
11 |
| - onOptionsChange({ ...options, url: e.currentTarget.value }); |
12 |
| - }; |
13 | 13 | const onParamsChange = (e: ChangeEvent<HTMLInputElement>) => {
|
14 | 14 | onOptionsChange({ ...options, jsonData: { ...options.jsonData, queryParams: e.currentTarget.value } });
|
15 | 15 | };
|
| 16 | + |
16 | 17 | return (
|
17 | 18 | <>
|
18 |
| - <Legend>HTTP</Legend> |
| 19 | + <DataSourceHttpSettings |
| 20 | + defaultUrl="http://localhost:8080" |
| 21 | + dataSourceConfig={options} |
| 22 | + onChange={onOptionsChange} |
| 23 | + /> |
| 24 | + <h3 className="page-heading">Misc</h3> |
19 | 25 | <div className="gf-form-group">
|
20 |
| - <div className="gf-form"> |
21 |
| - <InlineFormLabel tooltip={<p>URL to an endpoint that returns a JSON response.</p>}>URL</InlineFormLabel> |
22 |
| - <Input className="width-25" value={options.url} onChange={onUrlChange} placeholder="page=1&limit=100" /> |
23 |
| - </div> |
24 |
| - <div className="gf-form"> |
25 |
| - <InlineFormLabel tooltip={<p>Add custom query parameters to your query.</p>}> |
26 |
| - Query parameters |
27 |
| - </InlineFormLabel> |
28 |
| - <Input |
29 |
| - className="width-25" |
30 |
| - value={options.jsonData.queryParams} |
31 |
| - onChange={onParamsChange} |
32 |
| - placeholder="page=1&limit=100" |
33 |
| - /> |
| 26 | + <div className="gf-form-inline"> |
| 27 | + <div className="gf-form max-width-30"> |
| 28 | + <FormField |
| 29 | + label="Custom query parameters" |
| 30 | + labelWidth={14} |
| 31 | + tooltip="Add custom parameters to your queries." |
| 32 | + inputEl={ |
| 33 | + <Input |
| 34 | + className="width-25" |
| 35 | + value={options.jsonData.queryParams} |
| 36 | + onChange={onParamsChange} |
| 37 | + spellCheck={false} |
| 38 | + placeholder="page=1&limit=100" |
| 39 | + /> |
| 40 | + } |
| 41 | + /> |
| 42 | + </div> |
34 | 43 | </div>
|
35 | 44 | </div>
|
36 | 45 | </>
|
|
0 commit comments