Commit 0f97925c by Darryl Committed by GitHub

Templating: Custom variable edit UI, change text input into textarea (#28312) (#28322)

parent 3abd9957
...@@ -4,6 +4,7 @@ import { SelectionOptionsEditor } from '../editor/SelectionOptionsEditor'; ...@@ -4,6 +4,7 @@ import { SelectionOptionsEditor } from '../editor/SelectionOptionsEditor';
import { OnPropChangeArguments, VariableEditorProps } from '../editor/types'; import { OnPropChangeArguments, VariableEditorProps } from '../editor/types';
import { connectWithStore } from 'app/core/utils/connectWithReduxStore'; import { connectWithStore } from 'app/core/utils/connectWithReduxStore';
import { MapDispatchToProps, MapStateToProps } from 'react-redux'; import { MapDispatchToProps, MapStateToProps } from 'react-redux';
import { Field, TextArea } from '@grafana/ui';
import { StoreState } from 'app/types'; import { StoreState } from 'app/types';
import { changeVariableMultiValue } from '../state/actions'; import { changeVariableMultiValue } from '../state/actions';
...@@ -18,7 +19,7 @@ interface DispatchProps { ...@@ -18,7 +19,7 @@ interface DispatchProps {
export type Props = OwnProps & ConnectedProps & DispatchProps; export type Props = OwnProps & ConnectedProps & DispatchProps;
class CustomVariableEditorUnconnected extends PureComponent<Props> { class CustomVariableEditorUnconnected extends PureComponent<Props> {
onChange = (event: ChangeEvent<HTMLInputElement>) => { onChange = (event: ChangeEvent<HTMLTextAreaElement>) => {
this.props.onPropChange({ this.props.onPropChange({
propName: 'query', propName: 'query',
propValue: event.target.value, propValue: event.target.value,
...@@ -29,7 +30,7 @@ class CustomVariableEditorUnconnected extends PureComponent<Props> { ...@@ -29,7 +30,7 @@ class CustomVariableEditorUnconnected extends PureComponent<Props> {
this.props.onPropChange({ propName, propValue, updateOptions: true }); this.props.onPropChange({ propName, propValue, updateOptions: true });
}; };
onBlur = (event: FocusEvent<HTMLInputElement>) => { onBlur = (event: FocusEvent<HTMLTextAreaElement>) => {
this.props.onPropChange({ this.props.onPropChange({
propName: 'query', propName: 'query',
propValue: event.target.value, propValue: event.target.value,
...@@ -43,17 +44,19 @@ class CustomVariableEditorUnconnected extends PureComponent<Props> { ...@@ -43,17 +44,19 @@ class CustomVariableEditorUnconnected extends PureComponent<Props> {
<div className="gf-form-group"> <div className="gf-form-group">
<h5 className="section-heading">Custom Options</h5> <h5 className="section-heading">Custom Options</h5>
<div className="gf-form"> <div className="gf-form">
<span className="gf-form-label width-14">Values separated by comma</span> <Field label="Values separated by comma">
<input <TextArea
type="text"
className="gf-form-input" className="gf-form-input"
value={this.props.variable.query} value={this.props.variable.query}
onChange={this.onChange} onChange={this.onChange}
onBlur={this.onBlur} onBlur={this.onBlur}
rows={5}
cols={81}
placeholder="1, 10, mykey : myvalue, myvalue, escaped\,value" placeholder="1, 10, mykey : myvalue, myvalue, escaped\,value"
required required
aria-label="Variable editor Form Custom Query field" aria-label="Variable editor Form Custom Query field"
/> />
</Field>
</div> </div>
</div> </div>
<SelectionOptionsEditor <SelectionOptionsEditor
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment