mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 08:35:43 -06:00
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import React, { FormEvent, PureComponent } from 'react';
|
|
|
|
import { selectors } from '@grafana/e2e-selectors';
|
|
|
|
import { VariableLegend } from '../editor/VariableLegend';
|
|
import { VariableTextField } from '../editor/VariableTextField';
|
|
import { VariableEditorProps } from '../editor/types';
|
|
import { ConstantVariableModel } from '../types';
|
|
|
|
export interface Props extends VariableEditorProps<ConstantVariableModel> {}
|
|
|
|
export class ConstantVariableEditor extends PureComponent<Props> {
|
|
onChange = (event: FormEvent<HTMLInputElement>) => {
|
|
this.props.onPropChange({
|
|
propName: 'query',
|
|
propValue: event.currentTarget.value,
|
|
});
|
|
};
|
|
|
|
onBlur = (event: FormEvent<HTMLInputElement>) => {
|
|
this.props.onPropChange({
|
|
propName: 'query',
|
|
propValue: event.currentTarget.value,
|
|
updateOptions: true,
|
|
});
|
|
};
|
|
|
|
render() {
|
|
return (
|
|
<>
|
|
<VariableLegend>Constant options</VariableLegend>
|
|
<VariableTextField
|
|
value={this.props.variable.query}
|
|
name="Value"
|
|
placeholder="your metric prefix"
|
|
onChange={this.onChange}
|
|
onBlur={this.onBlur}
|
|
testId={selectors.pages.Dashboard.Settings.Variables.Edit.ConstantVariable.constantOptionsQueryInputV2}
|
|
width={30}
|
|
/>
|
|
</>
|
|
);
|
|
}
|
|
}
|