-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathQueryEditor.tsx
30 lines (23 loc) · 895 Bytes
/
QueryEditor.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import defaults from 'lodash/defaults';
import React, { PureComponent, ChangeEvent } from 'react';
import { FormField, QueryEditorProps } from '@grafana/ui';
import { DataSource } from './DataSource';
import { StreamingQuery, MyDataSourceOptions } from './types';
type Props = QueryEditorProps<DataSource, StreamingQuery, MyDataSourceOptions>;
interface State {}
export class QueryEditor extends PureComponent<Props, State> {
onComponentDidMount() {}
onNameChange = (event: ChangeEvent<HTMLInputElement>) => {
const { onChange, query } = this.props;
onChange({ ...query, name: event.target.value });
};
render() {
const query = defaults(this.props.query, {});
const name = query.name || '';
return (
<div className="gf-form">
<FormField labelWidth={8} value={name} onChange={this.onNameChange} label="Name"></FormField>
</div>
);
}
}