diff options
| author | jc0b <j@jc0b.computer> | 2020-07-07 16:55:22 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-08-24 19:47:51 +0200 |
| commit | 223e916997eb641a1662110b6de630a4cdfdf479 (patch) | |
| tree | 90ca4364461f676db45f25e03d8f22fc32f9fdd8 /frontend/src/containers/modals | |
| parent | 9ff1e3c6bae253372a468dbdc9b8369ab8dd2c6f (diff) | |
| parent | b810c4413079bf5aeb5374f1cd20e151a83530d0 (diff) | |
Merge branch 'feature/mongodb-migration' of github.com:atlarge-research/opendc-dev into feature/mongodb-migration
Diffstat (limited to 'frontend/src/containers/modals')
6 files changed, 88 insertions, 103 deletions
diff --git a/frontend/src/containers/modals/ChangeTopologyModal.js b/frontend/src/containers/modals/ChangeTopologyModal.js deleted file mode 100644 index a1db9032..00000000 --- a/frontend/src/containers/modals/ChangeTopologyModal.js +++ /dev/null @@ -1,64 +0,0 @@ -import { connect } from 'react-redux' -import ChangeTopologyModalComponent from '../../components/modals/custom-components/ChangeTopologyModalComponent' -import { closeChangeTopologyModal } from '../../actions/modals/topology' -import { addTopology, deleteTopology } from '../../actions/topologies' -import { setCurrentTopology } from '../../actions/topology/building' - -const mapStateToProps = state => { - let topologies = state.objects.simulation[state.currentSimulationId] ? state.objects.simulation[state.currentSimulationId].topologyIds.map(t => ( - state.objects.topology[t] - )) : [] - if (topologies.filter(t => !t).length > 0) { - topologies = [] - } - - return { - show: state.modals.changeTopologyModalVisible, - currentTopologyId: state.currentTopologyId, - topologies, - } -} - -const mapDispatchToProps = dispatch => { - return { - onChooseTopology: (id) => { - dispatch( - setCurrentTopology(id) - ) - dispatch(closeChangeTopologyModal()) - }, - onCreateTopology: (name) => { - if (name) { - dispatch( - addTopology({name, rooms: []}) - ) - } - dispatch(closeChangeTopologyModal()) - }, - onDuplicateTopology: (name) => { - if (name) { - // TODO different handling here - dispatch( - addTopology({name, rooms: []}) - ) - } - dispatch(closeChangeTopologyModal()) - }, - onDeleteTopology: (id) => { - if (id) { - dispatch( - deleteTopology(id) - ) - } - }, - onCancel: () => { - dispatch(closeChangeTopologyModal()) - }, - } -} - -const ChangeTopologyModal = connect(mapStateToProps, mapDispatchToProps)( - ChangeTopologyModalComponent, -) - -export default ChangeTopologyModal diff --git a/frontend/src/containers/modals/EditRackNameModal.js b/frontend/src/containers/modals/EditRackNameModal.js index 495c107b..fb7727f1 100644 --- a/frontend/src/containers/modals/EditRackNameModal.js +++ b/frontend/src/containers/modals/EditRackNameModal.js @@ -20,7 +20,7 @@ const mapStateToProps = state => { previousName: state.interactionLevel.mode === 'RACK' ? state.objects.rack[ - state.objects.tile[state.interactionLevel.tileId].rackId + state.objects.tile[state.interactionLevel.tileId].rackId ].name : '', } diff --git a/frontend/src/containers/modals/NewExperimentModal.js b/frontend/src/containers/modals/NewExperimentModal.js index 2ac5a4b8..f07b53e6 100644 --- a/frontend/src/containers/modals/NewExperimentModal.js +++ b/frontend/src/containers/modals/NewExperimentModal.js @@ -6,7 +6,7 @@ import NewExperimentModalComponent from '../../components/modals/custom-componen const mapStateToProps = state => { return { show: state.modals.newExperimentModalVisible, - topologies: state.objects.simulation[state.currentSimulationId].topologyIds.map(t => ( + topologies: state.objects.project[state.currentProjectId].topologyIds.map(t => ( state.objects.topology[t] )), traces: Object.values(state.objects.trace), diff --git a/frontend/src/containers/modals/NewProjectModal.js b/frontend/src/containers/modals/NewProjectModal.js new file mode 100644 index 00000000..1d0ebbbc --- /dev/null +++ b/frontend/src/containers/modals/NewProjectModal.js @@ -0,0 +1,37 @@ +import React from 'react' +import { connect } from 'react-redux' +import { closeNewProjectModal } from '../../actions/modals/projects' +import { addProject } from '../../actions/projects' +import TextInputModal from '../../components/modals/TextInputModal' + +const NewProjectModalComponent = ({ visible, callback }) => ( + <TextInputModal + title="New Project" + label="Project title" + show={visible} + callback={callback} + /> +) + +const mapStateToProps = state => { + return { + visible: state.modals.newProjectModalVisible, + } +} + +const mapDispatchToProps = dispatch => { + return { + callback: text => { + if (text) { + dispatch(addProject(text)) + } + dispatch(closeNewProjectModal()) + }, + } +} + +const NewProjectModal = connect(mapStateToProps, mapDispatchToProps)( + NewProjectModalComponent, +) + +export default NewProjectModal diff --git a/frontend/src/containers/modals/NewSimulationModal.js b/frontend/src/containers/modals/NewSimulationModal.js deleted file mode 100644 index e95ac4b0..00000000 --- a/frontend/src/containers/modals/NewSimulationModal.js +++ /dev/null @@ -1,37 +0,0 @@ -import React from 'react' -import { connect } from 'react-redux' -import { closeNewSimulationModal } from '../../actions/modals/simulations' -import { addSimulation } from '../../actions/simulations' -import TextInputModal from '../../components/modals/TextInputModal' - -const NewSimulationModalComponent = ({ visible, callback }) => ( - <TextInputModal - title="New Simulation" - label="Simulation title" - show={visible} - callback={callback} - /> -) - -const mapStateToProps = state => { - return { - visible: state.modals.newSimulationModalVisible, - } -} - -const mapDispatchToProps = dispatch => { - return { - callback: text => { - if (text) { - dispatch(addSimulation(text)) - } - dispatch(closeNewSimulationModal()) - }, - } -} - -const NewSimulationModal = connect(mapStateToProps, mapDispatchToProps)( - NewSimulationModalComponent, -) - -export default NewSimulationModal diff --git a/frontend/src/containers/modals/NewTopologyModal.js b/frontend/src/containers/modals/NewTopologyModal.js new file mode 100644 index 00000000..282f0db9 --- /dev/null +++ b/frontend/src/containers/modals/NewTopologyModal.js @@ -0,0 +1,49 @@ +import { connect } from 'react-redux' +import NewTopologyModalComponent from '../../components/modals/custom-components/NewTopologyModalComponent' +import { closeNewTopologyModal } from '../../actions/modals/topology' +import { addTopology } from '../../actions/topologies' + +const mapStateToProps = 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 { + show: state.modals.changeTopologyModalVisible, + topologies, + } +} + +const mapDispatchToProps = dispatch => { + return { + onCreateTopology: (name) => { + if (name) { + dispatch( + addTopology({ name, rooms: [] }), + ) + } + dispatch(closeNewTopologyModal()) + }, + onDuplicateTopology: (name) => { + if (name) { + // TODO different handling here + dispatch( + addTopology({ name, rooms: [] }), + ) + } + dispatch(closeNewTopologyModal()) + }, + onCancel: () => { + dispatch(closeNewTopologyModal()) + }, + } +} + +const NewTopologyModal = connect(mapStateToProps, mapDispatchToProps)( + NewTopologyModalComponent, +) + +export default NewTopologyModal |
