summaryrefslogtreecommitdiff
path: root/frontend/src/reducers/objects.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/reducers/objects.js')
-rw-r--r--frontend/src/reducers/objects.js138
1 files changed, 69 insertions, 69 deletions
diff --git a/frontend/src/reducers/objects.js b/frontend/src/reducers/objects.js
index 99d91092..2e9644d0 100644
--- a/frontend/src/reducers/objects.js
+++ b/frontend/src/reducers/objects.js
@@ -1,80 +1,80 @@
-import { combineReducers } from "redux";
+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";
+ 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")
-});
+ 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);
+ return objectWithId(type, object => object.id)
}
function objectWithId(type, getId) {
- return (state = {}, action) => {
- if (action.objectType !== type) {
- return state;
- }
+ 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
- )
- })
- });
- }
+ 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;
- };
+ return state
+ }
}