VariableEditorForm checks to display preview with multiple props
This commit is contained in:
@@ -68,7 +68,9 @@ export function VariableEditorForm({ variable, onTypeChange, onGoBack, onDelete
|
||||
const onHideChange = (hide: VariableHide) => variable.setState({ hide });
|
||||
|
||||
const isHasVariableOptions = hasVariableOptions(variable);
|
||||
const hasMultiProps = 'valuesFormat' in variable.state && variable.state.valuesFormat === 'json';
|
||||
const optionsForSelect = isHasVariableOptions ? variable.getOptionsForSelect(false) : [];
|
||||
const hasJsonValuesFormat = 'valuesFormat' in variable.state && variable.state.valuesFormat === 'json';
|
||||
const hasMultiProps = hasJsonValuesFormat || optionsForSelect.every((o) => Boolean(o.properties));
|
||||
|
||||
const onDeleteVariable = (hideModal: () => void) => () => {
|
||||
reportInteraction('Delete variable');
|
||||
@@ -124,9 +126,7 @@ export function VariableEditorForm({ variable, onTypeChange, onGoBack, onDelete
|
||||
|
||||
{EditorToRender && <EditorToRender variable={variable} onRunQuery={onRunQuery} />}
|
||||
|
||||
{isHasVariableOptions && (
|
||||
<VariableValuesPreview options={variable.getOptionsForSelect(false)} hasMultiProps={hasMultiProps} />
|
||||
)}
|
||||
{isHasVariableOptions && <VariableValuesPreview options={optionsForSelect} hasMultiProps={hasMultiProps} />}
|
||||
|
||||
<div className={styles.buttonContainer}>
|
||||
<Stack gap={2}>
|
||||
|
||||
+2
-2
@@ -127,11 +127,11 @@ export function QueryVariableEditorForm({
|
||||
VariableQueryEditor={VariableQueryEditor}
|
||||
timeRange={timeRange}
|
||||
/>
|
||||
{/* TODO: remove me after finished testing - each DS can/should implement their own UI */}
|
||||
<Field
|
||||
// TODO: add translation
|
||||
// eslint-disable-next-line @grafana/i18n/no-untranslated-strings
|
||||
label="Enable access to all the fields of the query results"
|
||||
description={
|
||||
// TODO: add translation
|
||||
<Trans i18nKey="">
|
||||
Check{' '}
|
||||
<TextLink href="https://grafana.com/docs/grafana/latest/variables/xxx" external>
|
||||
|
||||
Reference in New Issue
Block a user