import { FormEvent, PureComponent } from 'react'; import { MapDispatchToProps, MapStateToProps } from 'react-redux'; import { CustomVariableModel, VariableWithMultiSupport } from '@grafana/data'; import { connectWithStore } from 'app/core/utils/connectWithReduxStore'; import { CustomVariableForm } from 'app/features/dashboard-scene/settings/variables/components/CustomVariableForm'; import { StoreState } from 'app/types/store'; import { OnPropChangeArguments, VariableEditorProps } from '../editor/types'; import { changeVariableMultiValue } from '../state/actions'; interface OwnProps extends VariableEditorProps {} interface ConnectedProps {} interface DispatchProps { changeVariableMultiValue: typeof changeVariableMultiValue; } export type Props = OwnProps & ConnectedProps & DispatchProps; class CustomVariableEditorUnconnected extends PureComponent { onSelectionOptionsChange = async ({ propName, propValue }: OnPropChangeArguments) => { this.props.onPropChange({ propName, propValue, updateOptions: true }); }; onQueryChange = (event: FormEvent) => { this.props.onPropChange({ propName: 'query', propValue: event.currentTarget.value, updateOptions: true, }); }; render() { return ( this.onSelectionOptionsChange({ propName: 'multi', propValue: event.currentTarget.checked }) } onIncludeAllChange={(event) => this.onSelectionOptionsChange({ propName: 'includeAll', propValue: event.currentTarget.checked }) } onAllValueChange={(event) => this.onSelectionOptionsChange({ propName: 'allValue', propValue: event.currentTarget.value }) } /> ); } } const mapStateToProps: MapStateToProps = (state, ownProps) => ({}); const mapDispatchToProps: MapDispatchToProps = { changeVariableMultiValue, }; export const CustomVariableEditor = connectWithStore( CustomVariableEditorUnconnected, mapStateToProps, mapDispatchToProps );