mirror of
https://github.com/grafana/grafana.git
synced 2025-09-20 23:16:51 +08:00

* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import React, { FormEvent, PureComponent } from 'react';
|
|
|
|
import { selectors } from '@grafana/e2e-selectors';
|
|
import { VerticalGroup } from '@grafana/ui';
|
|
|
|
import { VariableSectionHeader } from '../editor/VariableSectionHeader';
|
|
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 (
|
|
<VerticalGroup spacing="xs">
|
|
<VariableSectionHeader name="Constant options" />
|
|
<VariableTextField
|
|
value={this.props.variable.query}
|
|
name="Value"
|
|
placeholder="your metric prefix"
|
|
onChange={this.onChange}
|
|
onBlur={this.onBlur}
|
|
labelWidth={20}
|
|
testId={selectors.pages.Dashboard.Settings.Variables.Edit.ConstantVariable.constantOptionsQueryInputV2}
|
|
grow
|
|
/>
|
|
</VerticalGroup>
|
|
);
|
|
}
|
|
}
|