2024-06-25 19:43:47 +08:00
|
|
|
import { FormEvent } from 'react';
|
2024-01-16 19:38:34 +08:00
|
|
|
|
|
|
|
import { selectors } from '@grafana/e2e-selectors';
|
|
|
|
import { VariableLegend } from 'app/features/dashboard-scene/settings/variables/components/VariableLegend';
|
|
|
|
import { VariableTextField } from 'app/features/dashboard-scene/settings/variables/components/VariableTextField';
|
|
|
|
|
|
|
|
interface TextBoxVariableFormProps {
|
2024-01-18 01:14:01 +08:00
|
|
|
value?: string;
|
|
|
|
defaultValue?: string;
|
|
|
|
onChange?: (event: FormEvent<HTMLInputElement>) => void;
|
|
|
|
onBlur?: (event: FormEvent<HTMLInputElement>) => void;
|
2024-01-16 19:38:34 +08:00
|
|
|
}
|
|
|
|
|
2024-01-18 01:14:01 +08:00
|
|
|
export function TextBoxVariableForm({ defaultValue, value, onChange, onBlur }: TextBoxVariableFormProps) {
|
2024-01-16 19:38:34 +08:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<VariableLegend>Text options</VariableLegend>
|
|
|
|
<VariableTextField
|
|
|
|
value={value}
|
2024-01-18 01:14:01 +08:00
|
|
|
defaultValue={defaultValue}
|
2024-01-16 19:38:34 +08:00
|
|
|
name="Default value"
|
|
|
|
placeholder="default value, if any"
|
|
|
|
onChange={onChange}
|
|
|
|
onBlur={onBlur}
|
|
|
|
width={30}
|
|
|
|
testId={selectors.pages.Dashboard.Settings.Variables.Edit.TextBoxVariable.textBoxOptionsQueryInputV2}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|