import React, { ChangeEvent, FormEvent, FunctionComponent, useCallback } from 'react'; import { selectors } from '@grafana/e2e-selectors'; import { InlineFieldRow, VerticalGroup } from '@grafana/ui'; import { KeyedVariableIdentifier } from '../state/types'; import { VariableWithMultiSupport } from '../types'; import { toKeyedVariableIdentifier } from '../utils'; import { VariableSectionHeader } from './VariableSectionHeader'; import { VariableSwitchField } from './VariableSwitchField'; import { VariableTextField } from './VariableTextField'; import { VariableEditorProps } from './types'; export interface SelectionOptionsEditorProps extends VariableEditorProps { onMultiChanged: (identifier: KeyedVariableIdentifier, value: boolean) => void; } export const SelectionOptionsEditor: FunctionComponent = ({ onMultiChanged: onMultiChangedProps, onPropChange, variable, }) => { const onMultiChanged = useCallback( (event: ChangeEvent) => { onMultiChangedProps(toKeyedVariableIdentifier(variable), event.target.checked); }, [onMultiChangedProps, variable] ); const onIncludeAllChanged = useCallback( (event: ChangeEvent) => { onPropChange({ propName: 'includeAll', propValue: event.target.checked }); }, [onPropChange] ); const onAllValueChanged = useCallback( (event: FormEvent) => { onPropChange({ propName: 'allValue', propValue: event.currentTarget.value }); }, [onPropChange] ); return ( {variable.includeAll && ( )} ); }; SelectionOptionsEditor.displayName = 'SelectionOptionsEditor';