From 39277c91281dbc7bd40bdffabc5b5675e9ede483 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Fri, 3 Jul 2020 10:34:05 +0200 Subject: Get basic topology change working --- .../ChangeTopologyModalComponent.js | 35 +++++++++++++++++----- frontend/src/components/navigation/AppNavbar.js | 2 +- 2 files changed, 28 insertions(+), 9 deletions(-) (limited to 'frontend/src/components') diff --git a/frontend/src/components/modals/custom-components/ChangeTopologyModalComponent.js b/frontend/src/components/modals/custom-components/ChangeTopologyModalComponent.js index e36bde48..f1645dcf 100644 --- a/frontend/src/components/modals/custom-components/ChangeTopologyModalComponent.js +++ b/frontend/src/components/modals/custom-components/ChangeTopologyModalComponent.js @@ -7,6 +7,8 @@ class ChangeTopologyModalComponent extends React.Component { static propTypes = { show: PropTypes.bool.isRequired, topologies: PropTypes.arrayOf(Shapes.Topology), + currentTopologyId: PropTypes.number, + onChooseTopology: PropTypes.func.isRequired, onCreateTopology: PropTypes.func.isRequired, onDuplicateTopology: PropTypes.func.isRequired, onDeleteTopology: PropTypes.func.isRequired, @@ -26,6 +28,11 @@ class ChangeTopologyModalComponent extends React.Component { } } + onChoose(id) { + this.props.onChooseTopology(id) + this.reset() + } + onCreate() { this.props.onCreateTopology(this.textInput.value) this.reset() @@ -58,19 +65,31 @@ class ChangeTopologyModalComponent extends React.Component { onCancel={this.onCancel.bind(this)} >
- {this.props.topologies.forEach(topology => ( -
- {topology.name} -
this.onDelete(topology._id)} - > - Delete + {this.props.topologies.map((topology, idx) => ( +
+
+ {topology._id === this.props.currentTopologyId ? 'Active: ' : ''} + {topology.name} +
+
+ this.onChoose(topology._id)} + > + Choose + + idx !== 0 ? this.onDelete(topology._id) : undefined} + > + Delete +
))}
+
New Topology
{ e.preventDefault() diff --git a/frontend/src/components/navigation/AppNavbar.js b/frontend/src/components/navigation/AppNavbar.js index 15f08b5f..c3ab3c47 100644 --- a/frontend/src/components/navigation/AppNavbar.js +++ b/frontend/src/components/navigation/AppNavbar.js @@ -26,7 +26,7 @@ const AppNavbar = ({ simulationId, inSimulation, fullWidth, onViewTopologies }) -- cgit v1.2.3