grafana/public/app/features/variables/textbox/TextBoxVariableEditor.tsx
Hugo Häggmark 00a9af00fc
Templating: removes old Angular variable system and featureToggle (#24779)
* Chore: initial commit

* Tests: fixes MetricsQueryEditor.test.tsx

* Tests: fixes cloudwatch/specs/datasource.test.ts

* Tests: fixes stackdriver/specs/datasource.test.ts

* Tests: remove refrences to CustomVariable

* Refactor: moves DefaultVariableQueryEditor

* Refactor: moves utils

* Refactor: moves types

* Refactor: removes variableSrv

* Refactor: removes feature toggle newVariables

* Refactor: removes valueSelectDropDown

* Chore: removes GeneralTabCtrl

* Chore: migrates RowOptions

* Refactor: adds RowOptionsButton

* Refactor: makes the interface more explicit

* Refactor: small changes

* Refactor: changed type as it can be any variable type

* Tests: fixes broken test

* Refactor: changes after PR comments

* Refactor: adds loading state and call to onChange in componentDidMount
2020-06-04 13:44:48 +02:00

35 lines
1.2 KiB
TypeScript

import React, { ChangeEvent, PureComponent } from 'react';
import { TextBoxVariableModel } from '../types';
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>
);
}
}