mirror of
https://github.com/grafana/grafana.git
synced 2025-09-18 08:22:53 +08:00

* add new option for multi variables to lock value list wip * WIP - lock option list * tests * fix * fixes + canary scenes * wip * wip * fix snapshot * bump scenes * Dashboards: Add possibility to lock adhoc variables options list (#96077) * Lock list of options flag for ad hoc * refactor * fix snapshot
64 lines
1.9 KiB
TypeScript
64 lines
1.9 KiB
TypeScript
import { FormEvent } from 'react';
|
|
|
|
import { selectors } from '@grafana/e2e-selectors';
|
|
|
|
import { VariableLegend } from '../components/VariableLegend';
|
|
import { VariableTextAreaField } from '../components/VariableTextAreaField';
|
|
|
|
import { SelectionOptionsForm } from './SelectionOptionsForm';
|
|
|
|
interface CustomVariableFormProps {
|
|
query: string;
|
|
multi: boolean;
|
|
allValue?: string | null;
|
|
includeAll: boolean;
|
|
allowCustomValue?: boolean;
|
|
onQueryChange: (event: FormEvent<HTMLTextAreaElement>) => void;
|
|
onMultiChange: (event: FormEvent<HTMLInputElement>) => void;
|
|
onIncludeAllChange: (event: FormEvent<HTMLInputElement>) => void;
|
|
onAllValueChange: (event: FormEvent<HTMLInputElement>) => void;
|
|
onQueryBlur?: (event: FormEvent<HTMLTextAreaElement>) => void;
|
|
onAllValueBlur?: (event: FormEvent<HTMLInputElement>) => void;
|
|
onAllowCustomValueChange?: (event: FormEvent<HTMLInputElement>) => void;
|
|
}
|
|
|
|
export function CustomVariableForm({
|
|
query,
|
|
multi,
|
|
allValue,
|
|
includeAll,
|
|
allowCustomValue,
|
|
onQueryChange,
|
|
onMultiChange,
|
|
onIncludeAllChange,
|
|
onAllValueChange,
|
|
onAllowCustomValueChange,
|
|
}: CustomVariableFormProps) {
|
|
return (
|
|
<>
|
|
<VariableLegend>Custom options</VariableLegend>
|
|
|
|
<VariableTextAreaField
|
|
name="Values separated by comma"
|
|
defaultValue={query}
|
|
placeholder="1, 10, mykey : myvalue, myvalue, escaped\,value"
|
|
onBlur={onQueryChange}
|
|
required
|
|
width={52}
|
|
testId={selectors.pages.Dashboard.Settings.Variables.Edit.CustomVariable.customValueInput}
|
|
/>
|
|
<VariableLegend>Selection options</VariableLegend>
|
|
<SelectionOptionsForm
|
|
multi={multi}
|
|
includeAll={includeAll}
|
|
allValue={allValue}
|
|
allowCustomValue={allowCustomValue}
|
|
onMultiChange={onMultiChange}
|
|
onIncludeAllChange={onIncludeAllChange}
|
|
onAllValueChange={onAllValueChange}
|
|
onAllowCustomValueChange={onAllowCustomValueChange}
|
|
/>
|
|
</>
|
|
);
|
|
}
|