grafana/public/app/features/templating/DefaultVariableQueryEditor.tsx
Hugo Häggmark 841cffbe9a
e2e: Migrates query variable CRUD tests to new framework (#21146)
* Refactor: Adds params to visit

* Refactor: Restructures exported Pages somewhat

* Refactor: Moves more into new framework but holdup because of bugs in digest

* Refactor: Finish migrating templating e2e tests to new framework

* Refactor: Changes after merge with master

* Refactor: Removes weird change

* Refactor: Adds duplication test

* Refactor: Adds move down and move up variable asserts

* Refactor: Adds some test to value select dropdown
2019-12-18 06:13:58 +01:00

47 lines
1.3 KiB
TypeScript

import React, { PureComponent } from 'react';
import { VariableQueryProps } from 'app/types/plugins';
import { e2e } from '@grafana/e2e';
export default class DefaultVariableQueryEditor extends PureComponent<VariableQueryProps, any> {
constructor(props: VariableQueryProps) {
super(props);
this.state = { value: props.query };
}
onChange = (event: React.FormEvent<HTMLTextAreaElement>) => {
this.setState({ value: event.currentTarget.value });
};
onBlur = (event: React.FormEvent<HTMLTextAreaElement>) => {
this.props.onChange(event.currentTarget.value, event.currentTarget.value);
};
getLineCount() {
const { value } = this.state;
if (typeof value === 'string') {
return value.split('\n').length;
}
return 1;
}
render() {
return (
<div className="gf-form">
<span className="gf-form-label width-10">Query</span>
<textarea
rows={this.getLineCount()}
className="gf-form-input"
value={this.state.value}
onChange={this.onChange}
onBlur={this.onBlur}
placeholder="metric name or tags query"
required
aria-label={e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.selectors.queryOptionsQueryInput}
/>
</div>
);
}
}