import LogStreams from '../components/LogStreams' ; import * as actions from '../actions/' ; import { StoreState } from '../types' ; import { currentDate , connectCloudWatchLogs , getCloudWatchLogsEvents } from '../side-effect-functions' ; import { Settings , LogStream } from '../common-interfaces' ; import { connect , Dispatch } from 'react-redux' ; export function mapStateToProps ( { logStreams , settings , logGroups } ) { return { logStreams : logStreams . logStreams , selectedName : logStreams . selectedName , lastModified : logStreams . lastModified , settings : settings . settings , logGroupName : logGroups . selectedName , } ; } export function mapDispatchToProps ( dispatch ) { return { SelectLogStream : ( selectedName ) => dispatch ( actions . selectLogStream ( selectedName ) ) , FetchLogText : ( settings , logGroupName , logStream ) => { const margin = 5 * 60 * 1000 ; const endDate = new Date ( logStream . lastEventTimestamp + margin ) ; const startDate = new Date ( logStream . firstEventTimestamp - margin ) ; const limit = 20 ; dispatch ( actions . fetchLogText ( settings , ( callbackData , callbackError , callbackEnd ) => getCloudWatchLogsEvents ( connectCloudWatchLogs ( settings ) , logGroupName , logStream . logStreamName , startDate , endDate , callbackData , callbackError , callbackEnd , false , limit ) ) ) ; } , Now : currentDate , } ; } export default connect ( mapStateToProps , mapDispatchToProps ) ( LogStreams as any ) ;