import { Module } from 'vuex' ; import store , { RootState } from '@/store' ; import PortPanel from '@/components/port-panel/port-panel' ; import OptionPanel from '@/components/option-panel/option-panel' ; import { showSystemMessage } from '@/common/util' ; interface PanelsState { optionPanelMount : Element ; portPanelMount : Element ; nodePanelVisible : boolean ; quickNodePanelVisible : boolean ; historyPanelVisible : boolean ; logPanelVisible : boolean ; } const initialState = { optionPanelMount : document . createElement ( 'div' ) , portPanelMount : document . createElement ( 'div' ) , nodePanelVisible : true , quickNodePanelVisible : false , historyPanelVisible : false , logPanelVisible : false } ; const mutations = { setOptionPanelMount ( state , mount ) { state . optionPanelMount = mount ; } , setPortPanelMount ( state , mount ) { state . portPanelMount = mount ; } , mountOptionPanel ( state , panel ) { if ( ! panel ) { console . error ( 'attempted to mount undefined option panel' ) ; return ; } state . optionPanelMount . appendChild ( panel . $el ) ; } , unmountOptionPanel ( state , panel ) { if ( panel . $el . parentElement !== state . optionPanelMount ) { console . error ( 'attempt to mount an unmounted option panel' ) ; return ; } state . optionPanelMount . removeChild ( panel . $el ) ; } , mountPortPanel ( state , panel ) { if ( ! panel ) { console . error ( 'attempted to mount undefined port panel' ) ; return ; } state . portPanelMount . appendChild ( panel . $el ) ; } , toggleNodePanel ( state ) { state . nodePanelVisible = ! state . nodePanelVisible ; } , openQuickNodePanel ( state ) { if ( store . state . interaction . isSystemInVisMode ) { showSystemMessage ( store , 'cannot create node in VisMode' , 'warn' ) ; return ; } state . quickNodePanelVisible = true ; } , closeQuickNodePanel ( state ) { state . quickNodePanelVisible = false ; } , toggleHistoryPanel ( state ) { state . historyPanelVisible = ! state . historyPanelVisible ; } , closeHistoryPanel ( state ) { state . historyPanelVisible = false ; } , openLogPanel ( state ) { state . logPanelVisible = true ; } , closeLogPanel ( state ) { state . logPanelVisible = false ; } } ; const panels = { namespaced : true , state : initialState , mutations } ; export default panels ;