import { Map } from 'immutable' ; import { ActionType , getType } from 'typesafe-actions' ; import * as pipelineActions from '../actions/pipelineActions' ; import { PipelineState } from '../store/factory/Pipeline' ; param { Object } state param { Object } action returns { Object } export function pipelinesReducer ( state , action ) { const id = action . meta ; if ( typeof state === 'undefined' ) { return Map ( ) ; } if ( action . type === getType ( pipelineActions . baseAddPipeline ) ) { return state . set ( String ( id ) , action . payload ) ; } if ( action . type === getType ( pipelineActions . updatePipelineProperty ) ) { const p = action . payload ; return state . setIn ( [ String ( id ) , p . property ] , p . value ) ; } if ( action . type === getType ( pipelineActions . baseAggregatePipeline ) ) { const p = action . payload ; if ( p . dsId === undefined ) { return state . deleteIn ( [ String ( id ) , '_aggregates' , p . key ] ) ; } return state . setIn ( [ String ( id ) , '_aggregates' , p . key ] , p . dsId ) ; } return state ; }