import { AnyAction } from 'redux' ; import { ThunkDispatch } from 'redux-thunk' ; import { connect } from 'react-redux' ; import { MapStoreState } from '../../../../../../reducers/store' ; import { cloneLayer , fitToLayerExtent , removeLayer , setDrawMode , showThisLayerOnly , toggleLayerVisible , updateEditLayer , } from '../../../../../../actions' ; import { getLayerListRaw } from '../../../../../../selectors/map_selectors' ; import { getIsReadOnly } from '../../../../../../selectors/ui_selectors' ; import { TOCEntryActionsPopover } from './toc_entry_actions_popover' ; import { DRAW_MODE } from '../../../../../../../common/constants' ; function mapStateToProps ( state ) { return { isReadOnly : getIsReadOnly ( state ) , numLayers : getLayerListRaw ( state ) . length , } ; } function mapDispatchToProps ( dispatch ) { return { cloneLayer : ( layerId ) => { dispatch ( cloneLayer ( layerId ) ) ; } , fitToBounds : ( layerId ) => { dispatch ( fitToLayerExtent ( layerId ) ) ; } , removeLayer : ( layerId ) => { dispatch ( removeLayer ( layerId ) ) ; } , toggleVisible : ( layerId ) => { dispatch ( toggleLayerVisible ( layerId ) ) ; } , enableShapeEditing : ( layerId ) => { dispatch ( updateEditLayer ( layerId ) ) ; dispatch ( setDrawMode ( DRAW_MODE . DRAW_SHAPES ) ) ; } , enablePointEditing : ( layerId ) => { dispatch ( updateEditLayer ( layerId ) ) ; dispatch ( setDrawMode ( DRAW_MODE . DRAW_POINTS ) ) ; } , showThisLayerOnly : ( layerId ) => { dispatch ( showThisLayerOnly ( layerId ) ) ; } , } ; } const connected = connect ( mapStateToProps , mapDispatchToProps ) ( TOCEntryActionsPopover ) ; export { connected as TOCEntryActionsPopover } ;