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