mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* 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
47 lines
1.3 KiB
TypeScript
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>
|
|
);
|
|
}
|
|
}
|