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