import { AnyAction } from 'redux' ; import { ThunkDispatch } from 'redux-thunk' ; import { connect } from 'react-redux' ; import { EditLayerPanel } from './edit_layer_panel' ; import { getSelectedLayer } from '../../selectors/map_selectors' ; import { setJoinsForLayer , updateSourceProps } from '../../actions' ; import { MapStoreState } from '../../reducers/store' ; import { ILayer } from '../../classes/layers/layer' ; import { isVectorLayer , IVectorLayer } from '../../classes/layers/vector_layer' ; import { OnSourceChangeArgs } from '../../classes/sources/source' ; function mapStateToProps ( state ) { const selectedLayer = getSelectedLayer ( state ) ; let key = 'none' ; if ( selectedLayer ) { key = isVectorLayer ( selectedLayer ) ? `${ selectedLayer . getId ( ) }${ ( selectedLayer as IVectorLayer ) . showJoinEditor ( ) }` : selectedLayer . getId ( ) ; } return { key , selectedLayer , } ; } function mapDispatchToProps ( dispatch ) { return { clearJoins : ( layer ) => { dispatch ( setJoinsForLayer ( layer , [ ] ) ) ; } , updateSourceProps : async ( id , sourcePropChanges ) => await dispatch ( updateSourceProps ( id , sourcePropChanges ) ) , } ; } const connected = connect ( mapStateToProps , mapDispatchToProps ) ( EditLayerPanel ) ; export { connected as EditLayerPanel } ;