diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-07-20 14:09:39 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-07-20 14:09:39 +0200 |
| commit | 6e3ad713111f35fc58bd2b7f1be5aeeb57eb94a8 (patch) | |
| tree | bcd0466cae9792be5d594ca821d54e843b006423 /opendc-web/opendc-web-ui/src/redux/sagas/objects.js | |
| parent | 51c759e74b088d405b63fdb3e374822308d21366 (diff) | |
refactor(ui): Perform Saga mutations through React Query
This change updates the OpenDC frontend to perform mutations of the
topology done in Sagas through the React Query cache, so that non-Saga
parts of the application also have their topology queries updated.
Diffstat (limited to 'opendc-web/opendc-web-ui/src/redux/sagas/objects.js')
| -rw-r--r-- | opendc-web/opendc-web-ui/src/redux/sagas/objects.js | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/opendc-web/opendc-web-ui/src/redux/sagas/objects.js b/opendc-web/opendc-web-ui/src/redux/sagas/objects.js deleted file mode 100644 index 9b4f8094..00000000 --- a/opendc-web/opendc-web-ui/src/redux/sagas/objects.js +++ /dev/null @@ -1,36 +0,0 @@ -import { call, put, select, getContext } from 'redux-saga/effects' -import { fetchTopology, updateTopology } from '../../api/topologies' -import { Topology } from '../../util/topology-schema' -import { denormalize, normalize } from 'normalizr' -import { storeTopology } from '../actions/topologies' - -/** - * Fetches and normalizes the topology with the specified identifier. - */ -export const fetchAndStoreTopology = function* (id) { - const auth = yield getContext('auth') - - let topology = yield select((state) => state.objects.topology[id]) - if (!topology) { - const newTopology = yield call(fetchTopology, auth, id) - const { entities } = normalize(newTopology, Topology) - yield put(storeTopology(entities)) - } - - return topology -} - -export const updateTopologyOnServer = function* (id) { - const topology = yield denormalizeTopology(id) - const auth = yield getContext('auth') - yield call(updateTopology, auth, topology) -} - -/** - * Denormalizes the topology representation in order to be stored on the server. - */ -export const denormalizeTopology = function* (id) { - const objects = yield select((state) => state.objects) - const topology = objects.topology[id] - return denormalize(topology, Topology, objects) -} |
