diff options
| author | Georgios Andreadis <info@gandreadis.com> | 2020-07-02 18:39:28 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-08-24 19:47:21 +0200 |
| commit | f119fc78dda4d1e828dde04f378a63a93e3a0a7e (patch) | |
| tree | bea1eace5d47f21a7ccb835c6a6079bc92e48710 /frontend/src/containers/modals/ChangeTopologyModal.js | |
| parent | 7f27a6370a0af25e1bf6ff8f46360c6c26c21e0b (diff) | |
Add current progress on frontend port
Diffstat (limited to 'frontend/src/containers/modals/ChangeTopologyModal.js')
| -rw-r--r-- | frontend/src/containers/modals/ChangeTopologyModal.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/frontend/src/containers/modals/ChangeTopologyModal.js b/frontend/src/containers/modals/ChangeTopologyModal.js new file mode 100644 index 00000000..bd364194 --- /dev/null +++ b/frontend/src/containers/modals/ChangeTopologyModal.js @@ -0,0 +1,56 @@ +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' + +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.newExperimentModalVisible, + topologies, + } +} + +const mapDispatchToProps = dispatch => { + return { + onCreateTopology: (name) => { + if (name) { + dispatch( + addTopology({name}) + ) + } + dispatch(closeChangeTopologyModal()) + }, + onDuplicateTopology: (name) => { + if (name) { + // TODO different handling here + dispatch( + addTopology({name}) + ) + } + dispatch(closeChangeTopologyModal()) + }, + onDeleteTopology: (id) => { + if (id) { + dispatch( + deleteTopology(id) + ) + } + }, + onCancel: () => { + dispatch(closeChangeTopologyModal()) + }, + } +} + +const ChangeTopologyModal = connect(mapStateToProps, mapDispatchToProps)( + ChangeTopologyModalComponent, +) + +export default ChangeTopologyModal |
