summaryrefslogtreecommitdiff
path: root/src/reducers/objects.js
diff options
context:
space:
mode:
authorGeorgios Andreadis <info@gandreadis.com>2020-06-29 15:47:09 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-08-24 16:08:41 +0200
commit90fae26aa4bd0e0eb3272ff6e6524060e9004fbb (patch)
treebf6943882f5fa5f3114c01fc571503c79ee1056d /src/reducers/objects.js
parent7032a007d4431f5a0c4c5e2d3f3bd20462d49950 (diff)
Prepare frontend repository for monorepo
This change prepares the frontend Git repository for the monorepo residing at https://github.com/atlarge-research.com/opendc. To accomodate for this, we move all files into a frontend subdirectory.
Diffstat (limited to 'src/reducers/objects.js')
-rw-r--r--src/reducers/objects.js80
1 files changed, 0 insertions, 80 deletions
diff --git a/src/reducers/objects.js b/src/reducers/objects.js
deleted file mode 100644
index 99d91092..00000000
--- a/src/reducers/objects.js
+++ /dev/null
@@ -1,80 +0,0 @@
-import { combineReducers } from "redux";
-import {
- ADD_ID_TO_STORE_OBJECT_LIST_PROP,
- ADD_PROP_TO_STORE_OBJECT,
- ADD_TO_STORE,
- REMOVE_ID_FROM_STORE_OBJECT_LIST_PROP
-} from "../actions/objects";
-
-export const objects = combineReducers({
- simulation: object("simulation"),
- user: object("user"),
- authorization: objectWithId("authorization", object => [
- object.userId,
- object.simulationId
- ]),
- failureModel: object("failureModel"),
- cpu: object("cpu"),
- gpu: object("gpu"),
- memory: object("memory"),
- storage: object("storage"),
- machine: object("machine"),
- rack: object("rack"),
- coolingItem: object("coolingItem"),
- psu: object("psu"),
- tile: object("tile"),
- room: object("room"),
- datacenter: object("datacenter"),
- section: object("section"),
- path: object("path"),
- task: object("task"),
- job: object("job"),
- trace: object("trace"),
- scheduler: object("scheduler"),
- experiment: object("experiment")
-});
-
-function object(type) {
- return objectWithId(type, object => object.id);
-}
-
-function objectWithId(type, getId) {
- return (state = {}, action) => {
- 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
- )
- });
- } else if (action.type === ADD_ID_TO_STORE_OBJECT_LIST_PROP) {
- return Object.assign({}, state, {
- [action.objectId]: Object.assign({}, state[action.objectId], {
- [action.propName]: [
- ...state[action.objectId][action.propName],
- action.id
- ]
- })
- });
- } else if (action.type === REMOVE_ID_FROM_STORE_OBJECT_LIST_PROP) {
- return Object.assign({}, state, {
- [action.objectId]: Object.assign({}, state[action.objectId], {
- [action.propName]: state[action.objectId][action.propName].filter(
- id => id !== action.id
- )
- })
- });
- }
-
- return state;
- };
-}