diff options
| author | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-08-25 17:48:12 +0200 |
|---|---|---|
| committer | Georgios Andreadis <g.andreadis@student.tudelft.nl> | 2017-09-23 10:05:44 +0200 |
| commit | c47a27b826f7d76410308a4151611a366f9eaf46 (patch) | |
| tree | c1ca374204714cedabcacb8620848b903a0bf8d6 /src/reducers/objects.js | |
| parent | 1ddbbd3563af77a218020021ea50a8832900b4db (diff) | |
Fetch and display datacenter topology
Diffstat (limited to 'src/reducers/objects.js')
| -rw-r--r-- | src/reducers/objects.js | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/reducers/objects.js b/src/reducers/objects.js index 60cd2711..4fbffea6 100644 --- a/src/reducers/objects.js +++ b/src/reducers/objects.js @@ -1,5 +1,5 @@ import {combineReducers} from "redux"; -import {ADD_TO_STORE} from "../actions/objects"; +import {ADD_PROP_TO_STORE_OBJECT, ADD_TO_STORE} from "../actions/objects"; export const objects = combineReducers({ simulation: object("simulation"), @@ -27,14 +27,22 @@ function object(type) { function objectWithId(type, getId) { return (state = {}, action) => { - if (action.type === ADD_TO_STORE) { - if (action.objectType === type) { - return Object.assign( - state, - {[getId(action.object)]: action.object} - ); - } + if (action.objectType !== type) { return state; } + + if (action.type === ADD_TO_STORE) { + return Object.assign( + state, + {[getId(action.object)]: action.object} + ); + } else if (action.type === ADD_PROP_TO_STORE_OBJECT) { + return Object.assign( + state, + {[action.objectId]: Object.assign(state[action.objectId], action.propObject)} + ); + } + + return state; }; } |
