mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* 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
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import React, { ChangeEvent, FocusEvent, PureComponent } from 'react';
|
|
import { selectors } from '@grafana/e2e-selectors';
|
|
|
|
import { ConstantVariableModel } from '../types';
|
|
import { VariableEditorProps } from '../editor/types';
|
|
|
|
export interface Props extends VariableEditorProps<ConstantVariableModel> {}
|
|
|
|
export class ConstantVariableEditor extends PureComponent<Props> {
|
|
onChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
this.props.onPropChange({
|
|
propName: 'query',
|
|
propValue: event.target.value,
|
|
});
|
|
};
|
|
|
|
onBlur = (event: FocusEvent<HTMLInputElement>) => {
|
|
this.props.onPropChange({
|
|
propName: 'query',
|
|
propValue: event.target.value,
|
|
updateOptions: true,
|
|
});
|
|
};
|
|
|
|
render() {
|
|
return (
|
|
<>
|
|
<div className="gf-form-group">
|
|
<h5 className="section-heading">Constant options</h5>
|
|
<div className="gf-form">
|
|
<span className="gf-form-label">Value</span>
|
|
<input
|
|
type="text"
|
|
className="gf-form-input"
|
|
value={this.props.variable.query}
|
|
onChange={this.onChange}
|
|
onBlur={this.onBlur}
|
|
placeholder="your metric prefix"
|
|
aria-label={selectors.pages.Dashboard.Settings.Variables.Edit.ConstantVariable.constantOptionsQueryInput}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|
|
}
|