MCPcopy Create free account
hub / github.com/sshwsfc/xadmin / cellsReducer

Function cellsReducer

xadmin-dashboard/src/reducers.js:26–65  ·  view source on GitHub ↗
(state={}, action)

Source from the content-addressed store, hash-verified

24}
25
26const cellsReducer = (state={}, action) => {
27 const { type, key, params, Container } = action
28 switch(type) {
29 case '@@x-dashboard/ADD_CELL': {
30 const newState = { ...state, [key]: params }
31
32 if(params.parent) {
33 const parent = (Container && Container.CellReducer) ? Container.CellReducer(newState[params.parent], action) : newState[params.parent]
34 newState[params.parent] = {
35 ...parent, childrenCells: [ ...(parent.childrenCells || []), key ]
36 }
37 }
38 return newState
39 }
40 case '@@x-dashboard/REMOVE_CELL': {
41 const parentKey = state[key].parent
42 const newState = _.omit(state, findRelateCells(state, key))
43
44 if(parentKey) {
45 const parent = (Container && Container.CellReducer) ? Container.CellReducer(newState[parentKey], action) : state[parentKey]
46 newState[parentKey] = {
47 ...parent, childrenCells: parent.childrenCells ? parent.childrenCells.filter(k => k !== key) : []
48 }
49 }
50 return newState
51 }
52 case '@@x-dashboard/UPDATE_CELL':
53 return {
54 ...state,
55 [key]: params
56 }
57 case '@@x-dashboard/MERGE_CELL':
58 return {
59 ...state,
60 [key]: _.merge({}, state[key], params)
61 }
62 default:
63 return state
64 }
65}
66
67const layoutReducer = (state={}, { type, payload }) => {
68 switch(type) {

Callers

nothing calls this directly

Calls 1

findRelateCellsFunction · 0.85

Tested by

no test coverage detected