import { HostConfig } from './types' ; export enum types { HOST_CREATE = 'HOST_CREATE' , HOST_EDIT = 'HOST_EDIT' , HOST_DELETE = 'HOST_DELETE' , HOST_STATE_CHANGE = 'HOST_STATE_CHANGE' } export type HostStatus = 'connecting' | 'connected' | 'disconnecting' | 'disconnected' | 'error' ; interface HostCreateAction { type : types . HOST_CREATE ; id : string ; config : HostConfig ; } interface HostEditAction { type : types . HOST_EDIT ; id : string ; config : HostConfig ; } interface HostDeleteAction { type : types . HOST_DELETE ; id : string ; } interface HostStateChangeAction { type : types . HOST_STATE_CHANGE ; id : string ; status : HostStatus ; pid ? : number ; controlPath ? : string ; time ? : Date ; reason ? : string ; } export type Action = HostCreateAction | HostEditAction | HostDeleteAction | HostStateChangeAction ; export const actions = { hostCreate : ( id , config ) : Action => ( { type : types . HOST_CREATE , id , config } ) , hostEdit : ( id , config ) : Action => ( { type : types . HOST_EDIT , id , config } ) , hostDelete : ( id ) : Action => ( { type : types . HOST_DELETE , id } ) , hostStateConnecting : ( id , pid , controlPath , reason ) : Action => ( { type : types . HOST_STATE_CHANGE , id , status : 'connecting' , pid , controlPath , reason } ) , hostStateConnected : ( id , time ) : Action => ( { type : types . HOST_STATE_CHANGE , id , status : 'connected' , time } ) , hostStateDisconnecting : ( id , reason ) : Action => ( { type : types . HOST_STATE_CHANGE , id , status : 'disconnecting' , reason } ) , hostStateDisconnected : ( id ) : Action => ( { type : types . HOST_STATE_CHANGE , id , status : 'disconnected' } ) , hostStateError : ( id ) : Action => ( { type : types . HOST_STATE_CHANGE , id , status : 'error' } ) } ;