diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-05-13 17:42:53 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-05-17 17:06:50 +0200 |
| commit | 1edbae1a0224e30bafb98638f419e1f967a9286f (patch) | |
| tree | 2047c5a684379dfd395891e9447199f6001cef9b /opendc-web/opendc-web-ui/src/containers/modals/NewTopologyModal.js | |
| parent | 1891a6f3963d3ddeae0ea093f9a7e3608a97b4d7 (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/containers/modals/NewTopologyModal.js')
| -rw-r--r-- | opendc-web/opendc-web-ui/src/containers/modals/NewTopologyModal.js | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/opendc-web/opendc-web-ui/src/containers/modals/NewTopologyModal.js b/opendc-web/opendc-web-ui/src/containers/modals/NewTopologyModal.js deleted file mode 100644 index 2f81706e..00000000 --- a/opendc-web/opendc-web-ui/src/containers/modals/NewTopologyModal.js +++ /dev/null @@ -1,48 +0,0 @@ -import React from 'react' -import { useDispatch, useSelector } from 'react-redux' -import NewTopologyModalComponent from '../../components/modals/custom-components/NewTopologyModalComponent' -import { closeNewTopologyModal } from '../../actions/modals/topology' -import { addTopology } from '../../actions/topologies' - -const NewTopologyModal = () => { - const show = useSelector((state) => state.modals.changeTopologyModalVisible) - const topologies = useSelector((state) => { - let topologies = state.objects.project[state.currentProjectId] - ? state.objects.project[state.currentProjectId].topologyIds.map((t) => state.objects.topology[t]) - : [] - if (topologies.filter((t) => !t).length > 0) { - topologies = [] - } - - return topologies - }) - - const dispatch = useDispatch() - const onCreateTopology = (name) => { - if (name) { - dispatch(addTopology(name, undefined)) - } - dispatch(closeNewTopologyModal()) - } - const onDuplicateTopology = (name, id) => { - if (name) { - dispatch(addTopology(name, id)) - } - dispatch(closeNewTopologyModal()) - } - const onCancel = () => { - dispatch(closeNewTopologyModal()) - } - - return ( - <NewTopologyModalComponent - show={show} - topologies={topologies} - onCreateTopology={onCreateTopology} - onDuplicateTopology={onDuplicateTopology} - onCancel={onCancel} - /> - ) -} - -export default NewTopologyModal |
