DefaultVariableQueryEditor.tsx 1012 B

1234567891011121314151617181920212223242526272829303132333435
  1. import React, { PureComponent } from 'react';
  2. import { Input } from '@grafana/ui';
  3. import { VariableQueryProps } from 'app/types/plugins';
  4. export default class DefaultVariableQueryEditor extends PureComponent<VariableQueryProps, any> {
  5. constructor(props: VariableQueryProps) {
  6. super(props);
  7. this.state = { value: props.query };
  8. }
  9. onChange = (event: React.FormEvent<HTMLInputElement>) => {
  10. this.setState({ value: event.currentTarget.value });
  11. };
  12. onBlur = (event: React.FormEvent<HTMLInputElement>) => {
  13. this.props.onChange(event.currentTarget.value, event.currentTarget.value);
  14. };
  15. render() {
  16. return (
  17. <div className="gf-form">
  18. <span className="gf-form-label width-10">Query</span>
  19. <Input
  20. type="text"
  21. className="gf-form-input"
  22. value={this.state.value}
  23. onChange={this.onChange}
  24. onBlur={this.onBlur}
  25. placeholder="metric name or tags query"
  26. required
  27. />
  28. </div>
  29. );
  30. }
  31. }