grafana/public/app/plugins/datasource/influxdb/components/VariableQueryEditor.tsx
Josh Hunt 3c6e0e8ef8
Chore: ESlint import order (#44959)
* Add and configure eslint-plugin-import

* Fix the lint:ts npm command

* Autofix + prettier all the files

* Manually fix remaining files

* Move jquery code in jest-setup to external file to safely reorder imports

* Resolve issue caused by circular dependencies within Prometheus

* Update .betterer.results

* Fix missing // @ts-ignore

* ignore iconBundle.ts

* Fix missing // @ts-ignore
2022-04-22 14:33:13 +01:00

52 lines
1.2 KiB
TypeScript

import React, { PureComponent } from 'react';
import { InlineFormLabel, TextArea } from '@grafana/ui';
import InfluxDatasource from '../datasource';
import { FluxQueryEditor } from './FluxQueryEditor';
interface Props {
query: string; // before flux, it was always a string
onChange: (query?: string) => void;
datasource: InfluxDatasource;
}
export default class VariableQueryEditor extends PureComponent<Props> {
onRefresh = () => {
// noop
};
render() {
let { query, datasource, onChange } = this.props;
if (datasource.isFlux) {
return (
<FluxQueryEditor
datasource={datasource}
query={{
refId: 'A',
query,
}}
onRunQuery={this.onRefresh}
onChange={(v) => onChange(v.query)}
/>
);
}
return (
<div className="gf-form-inline">
<InlineFormLabel width={10}>Query</InlineFormLabel>
<div className="gf-form-inline gf-form--grow">
<TextArea
defaultValue={query || ''}
placeholder="metric name or tags query"
rows={1}
className="gf-form-input"
onBlur={(e) => onChange(e.currentTarget.value)}
/>
</div>
</div>
);
}
}