Files
grafana/public/app/features/variables/textbox/TextBoxVariableEditor.tsx
Hugo Häggmark 1db067396a Variables: migrates data source variable type to React/Redux (#22770)
* Refactor: moves all the newVariables part to features/variables directory

* Feature: adds datasource type

* Tests: adds reducer tests

* Tests: covers data source actions with tests

* Chore: reduces strict null errors
2020-03-16 06:32:04 +01:00

35 lines
1.2 KiB
TypeScript

import React, { ChangeEvent, PureComponent } from 'react';
import { TextBoxVariableModel } from '../../templating/variable';
import { VariableEditorProps } from '../editor/types';
export interface Props extends VariableEditorProps<TextBoxVariableModel> {}
export class TextBoxVariableEditor extends PureComponent<Props> {
onQueryChange = (event: ChangeEvent<HTMLInputElement>) => {
event.preventDefault();
this.props.onPropChange({ propName: 'query', propValue: event.target.value, updateOptions: false });
};
onQueryBlur = (event: ChangeEvent<HTMLInputElement>) => {
event.preventDefault();
this.props.onPropChange({ propName: 'query', propValue: event.target.value, updateOptions: true });
};
render() {
const { query } = this.props.variable;
return (
<div className="gf-form-group">
<h5 className="section-heading">Text options</h5>
<div className="gf-form">
<span className="gf-form-label">Default value</span>
<input
type="text"
className="gf-form-input"
value={query}
onChange={this.onQueryChange}
onBlur={this.onQueryBlur}
placeholder="default value, if any"
/>
</div>
</div>
);
}
}