mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki query editor is starting to work, had to make changes to explore query field in order to update query from the outside without unmount between
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
// Libraries
|
||||
import React, { PureComponent } from 'react';
|
||||
|
||||
// Types
|
||||
import { QueryEditorProps } from '@grafana/ui/src/types';
|
||||
import { LokiDatasource } from '../datasource';
|
||||
import { LokiQuery } from '../types';
|
||||
import { LokiQueryField } from './LokiQueryField';
|
||||
|
||||
type Props = QueryEditorProps<LokiDatasource, LokiQuery>;
|
||||
|
||||
interface State {
|
||||
query: LokiQuery;
|
||||
}
|
||||
|
||||
export class LokiQueryEditor extends PureComponent<Props> {
|
||||
|
||||
state: State = {
|
||||
query: this.props.query
|
||||
};
|
||||
|
||||
onRunQuery = () => {
|
||||
const { query } = this.state;
|
||||
|
||||
this.props.onChange(query);
|
||||
this.props.onRunQuery();
|
||||
};
|
||||
|
||||
onFieldChange = (query: LokiQuery, override?) => {
|
||||
this.setState({
|
||||
query: query
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
const { query } = this.state;
|
||||
const { datasource } = this.props;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<LokiQueryField datasource={datasource} initialQuery={query} onQueryChange={this.onFieldChange} onPressEnter={this.onRunQuery} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default LokiQueryEditor;
|
||||
Reference in New Issue
Block a user