summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/reducers
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-05-13 17:42:53 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-05-17 17:06:50 +0200
commit1edbae1a0224e30bafb98638f419e1f967a9286f (patch)
tree2047c5a684379dfd395891e9447199f6001cef9b /opendc-web/opendc-web-ui/src/reducers
parent1891a6f3963d3ddeae0ea093f9a7e3608a97b4d7 (diff)
ui: Move modal state outside of Redux
This change updates the frontend so that the modal state is not stored inside Redux but instead is stored using the useState hook. This simplifies the design of the modal components.
Diffstat (limited to 'opendc-web/opendc-web-ui/src/reducers')
-rw-r--r--opendc-web/opendc-web-ui/src/reducers/index.js2
-rw-r--r--opendc-web/opendc-web-ui/src/reducers/modals.js41
2 files changed, 0 insertions, 43 deletions
diff --git a/opendc-web/opendc-web-ui/src/reducers/index.js b/opendc-web/opendc-web-ui/src/reducers/index.js
index 787d5a74..9dff379b 100644
--- a/opendc-web/opendc-web-ui/src/reducers/index.js
+++ b/opendc-web/opendc-web-ui/src/reducers/index.js
@@ -4,13 +4,11 @@ import { construction } from './construction-mode'
import { currentPortfolioId, currentProjectId, currentScenarioId, currentTopologyId } from './current-ids'
import { interactionLevel } from './interaction-level'
import { map } from './map'
-import { modals } from './modals'
import { objects } from './objects'
import { projectList } from './project-list'
const rootReducer = combineReducers({
objects,
- modals,
projectList,
construction,
map,
diff --git a/opendc-web/opendc-web-ui/src/reducers/modals.js b/opendc-web/opendc-web-ui/src/reducers/modals.js
deleted file mode 100644
index a58d8708..00000000
--- a/opendc-web/opendc-web-ui/src/reducers/modals.js
+++ /dev/null
@@ -1,41 +0,0 @@
-import { combineReducers } from 'redux'
-import {
- CLOSE_NEW_TOPOLOGY_MODAL,
- CLOSE_DELETE_MACHINE_MODAL,
- CLOSE_DELETE_RACK_MODAL,
- CLOSE_DELETE_ROOM_MODAL,
- CLOSE_EDIT_RACK_NAME_MODAL,
- CLOSE_EDIT_ROOM_NAME_MODAL,
- OPEN_NEW_TOPOLOGY_MODAL,
- OPEN_DELETE_MACHINE_MODAL,
- OPEN_DELETE_RACK_MODAL,
- OPEN_DELETE_ROOM_MODAL,
- OPEN_EDIT_RACK_NAME_MODAL,
- OPEN_EDIT_ROOM_NAME_MODAL,
-} from '../actions/modals/topology'
-import { CLOSE_NEW_PORTFOLIO_MODAL, OPEN_NEW_PORTFOLIO_MODAL } from '../actions/modals/portfolios'
-import { CLOSE_NEW_SCENARIO_MODAL, OPEN_NEW_SCENARIO_MODAL } from '../actions/modals/scenarios'
-
-function modal(openAction, closeAction) {
- return function (state = false, action) {
- switch (action.type) {
- case openAction:
- return true
- case closeAction:
- return false
- default:
- return state
- }
- }
-}
-
-export const modals = combineReducers({
- changeTopologyModalVisible: modal(OPEN_NEW_TOPOLOGY_MODAL, CLOSE_NEW_TOPOLOGY_MODAL),
- editRoomNameModalVisible: modal(OPEN_EDIT_ROOM_NAME_MODAL, CLOSE_EDIT_ROOM_NAME_MODAL),
- deleteRoomModalVisible: modal(OPEN_DELETE_ROOM_MODAL, CLOSE_DELETE_ROOM_MODAL),
- editRackNameModalVisible: modal(OPEN_EDIT_RACK_NAME_MODAL, CLOSE_EDIT_RACK_NAME_MODAL),
- deleteRackModalVisible: modal(OPEN_DELETE_RACK_MODAL, CLOSE_DELETE_RACK_MODAL),
- deleteMachineModalVisible: modal(OPEN_DELETE_MACHINE_MODAL, CLOSE_DELETE_MACHINE_MODAL),
- newPortfolioModalVisible: modal(OPEN_NEW_PORTFOLIO_MODAL, CLOSE_NEW_PORTFOLIO_MODAL),
- newScenarioModalVisible: modal(OPEN_NEW_SCENARIO_MODAL, CLOSE_NEW_SCENARIO_MODAL),
-})