From f119fc78dda4d1e828dde04f378a63a93e3a0a7e Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Thu, 2 Jul 2020 18:39:28 +0200 Subject: Add current progress on frontend port --- .../src/containers/modals/ChangeTopologyModal.js | 56 ++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 frontend/src/containers/modals/ChangeTopologyModal.js (limited to 'frontend/src/containers/modals/ChangeTopologyModal.js') 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 -- cgit v1.2.3