import React, { PureComponent } from 'react'; // Types import { ExploreQueryFieldProps } from '@grafana/data'; import { FormLabel } from '@grafana/ui'; import { PrometheusDatasource } from '../datasource'; import { PromQuery, PromOptions } from '../types'; import PromQueryField from './PromQueryField'; export type Props = ExploreQueryFieldProps; interface State { interval: string; } export class PromExploreQueryEditor extends PureComponent { // Query target to be modified and used for queries query: PromQuery; constructor(props: Props) { super(props); const { query } = props; this.query = query; // Query target properties that are fully controlled inputs this.state = { // Fully controlled text inputs interval: query.interval, }; } onFieldChange = (query: PromQuery, override?: any) => { this.query.expr = query.expr; }; onIntervalChange = (e: React.SyntheticEvent) => { const interval = e.currentTarget.value; this.query.interval = interval; this.setState({ interval }); }; onRunQuery = () => { const { query } = this; this.props.onChange(query); this.props.onRunQuery(); }; onReturnKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter') { this.onRunQuery(); } }; render() { const { datasource, query, data, history } = this.props; const { interval } = this.state; return (
Step
); } }