import * as React from 'react' ; import { State , Action } from '../define' ; export const ApplicationContext = React . createContext < [ State , React . Dispatch < Action > ] > ( null ) ; export const ApplicationReducer = ( state , action ) => { switch ( action . type ) { case 'loadUiPlugins' : if ( action . plugins ) { action . plugins . forEach ( plugin => { if ( plugin . init ) { plugin . init ( ) ; } } ) ; return { ... state , plugins : action . plugins , } ; } return state ; case 'setSelectedTreeKey' : return { ... state , selectedTreeKey : action . selectedTreeKey , } ; case 'freshProjectStatus' : return { ... state , status : action . status , } ; default : return state ; } } ;