import { AnyAction } from 'redux' ; import { ThunkDispatch } from 'redux-thunk' ; import { connect } from 'react-redux' ; import { AddLayerPanel } from './view' ; import { FLYOUT_STATE } from '../../reducers/ui' ; import { addPreviewLayers , promotePreviewLayers , removePreviewLayers , setDrawMode , setFirstPreviewLayerToSelectedLayer , setEditLayerToSelectedLayer , updateFlyout , } from '../../actions' ; import { MapStoreState } from '../../reducers/store' ; import { LayerDescriptor } from '../../../common/descriptor_types' ; import { hasPreviewLayers , isLoadingPreviewLayers } from '../../selectors/map_selectors' ; import { DRAW_MODE } from '../../../common/constants' ; function mapStateToProps ( state ) { return { hasPreviewLayers : hasPreviewLayers ( state ) , isLoadingPreviewLayers : isLoadingPreviewLayers ( state ) , } ; } function mapDispatchToProps ( dispatch ) { return { addPreviewLayers : ( layerDescriptors ) => { dispatch ( addPreviewLayers ( layerDescriptors ) ) ; } , promotePreviewLayers : ( ) => { dispatch ( setFirstPreviewLayerToSelectedLayer ( ) ) ; dispatch ( updateFlyout ( FLYOUT_STATE . LAYER_PANEL ) ) ; dispatch ( promotePreviewLayers ( ) ) ; } , closeFlyout : ( ) => { dispatch ( updateFlyout ( FLYOUT_STATE . NONE ) ) ; dispatch ( removePreviewLayers ( ) ) ; } , enableEditMode : ( ) => { dispatch ( setEditLayerToSelectedLayer ( ) ) ; dispatch ( setDrawMode ( DRAW_MODE . DRAW_SHAPES ) ) ; } , } ; } const connected = connect ( mapStateToProps , mapDispatchToProps , null , { forwardRef : true } ) ( AddLayerPanel ) ; export { connected as AddLayerPanel } ;