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';
|
2025-04-02 17:03:12 +08:00
|
|
|
import { Trans, t } from 'app/core/internationalization';
|
2024-01-16 19:38:34 +08:00
|
|
|
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 (
|
|
|
|
<>
|
2025-04-02 17:03:12 +08:00
|
|
|
<VariableLegend>
|
|
|
|
<Trans i18nKey="dashboard-scene.text-box-variable-form.text-options">Text options</Trans>
|
|
|
|
</VariableLegend>
|
2024-01-16 19:38:34 +08:00
|
|
|
<VariableTextField
|
|
|
|
value={value}
|
2024-01-18 01:14:01 +08:00
|
|
|
defaultValue={defaultValue}
|
2024-01-16 19:38:34 +08:00
|
|
|
name="Default value"
|
2025-04-02 17:03:12 +08:00
|
|
|
placeholder={t('dashboard-scene.text-box-variable-form.placeholder-default-value-if-any', '(optional)')}
|
2024-01-16 19:38:34 +08:00
|
|
|
onChange={onChange}
|
|
|
|
onBlur={onBlur}
|
|
|
|
width={30}
|
|
|
|
testId={selectors.pages.Dashboard.Settings.Variables.Edit.TextBoxVariable.textBoxOptionsQueryInputV2}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|