summaryrefslogtreecommitdiff
path: root/frontend/src/containers/modals/ChangeTopologyModal.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/containers/modals/ChangeTopologyModal.js')
-rw-r--r--frontend/src/containers/modals/ChangeTopologyModal.js56
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