From 890cd3f7028bfccd77b0d04670f7bc07293ed383 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Tue, 7 Jul 2020 11:20:43 +0200 Subject: Add new left sidebar, move topology controls --- .../ChangeTopologyModalComponent.js | 131 --------------------- .../custom-components/NewTopologyModalComponent.js | 92 +++++++++++++++ 2 files changed, 92 insertions(+), 131 deletions(-) delete mode 100644 frontend/src/components/modals/custom-components/ChangeTopologyModalComponent.js create mode 100644 frontend/src/components/modals/custom-components/NewTopologyModalComponent.js (limited to 'frontend/src/components/modals/custom-components') diff --git a/frontend/src/components/modals/custom-components/ChangeTopologyModalComponent.js b/frontend/src/components/modals/custom-components/ChangeTopologyModalComponent.js deleted file mode 100644 index 22ef4585..00000000 --- a/frontend/src/components/modals/custom-components/ChangeTopologyModalComponent.js +++ /dev/null @@ -1,131 +0,0 @@ -import PropTypes from 'prop-types' -import React from 'react' -import Shapes from '../../../shapes' -import Modal from '../Modal' - -class ChangeTopologyModalComponent extends React.Component { - static propTypes = { - show: PropTypes.bool.isRequired, - topologies: PropTypes.arrayOf(Shapes.Topology), - currentTopologyId: PropTypes.string, - onChooseTopology: PropTypes.func.isRequired, - onCreateTopology: PropTypes.func.isRequired, - onDuplicateTopology: PropTypes.func.isRequired, - onDeleteTopology: PropTypes.func.isRequired, - onCancel: PropTypes.func.isRequired, - } - - reset() { - this.textInput.value = '' - this.originTopology.selectedIndex = 0 - } - - onSubmit() { - if (this.originTopology.selectedIndex === 0) { - this.onCreate() - } else { - this.onDuplicate() - } - } - - onChoose(id) { - this.props.onChooseTopology(id) - this.reset() - } - - onCreate() { - this.props.onCreateTopology(this.textInput.value) - this.reset() - } - - onDuplicate() { - this.props.onCreateTopology( - this.textInput.value, - this.originTopology.value, - ) - this.reset() - } - - onDelete(id) { - this.props.onDeleteTopology(id) - this.reset() - } - - onCancel() { - this.props.onCancel() - this.reset() - } - - render() { - return ( - -
- {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() - this.onSubmit() - }} - > -
- - (this.textInput = textInput)} - /> -
-
- - -
-
-
- ) - } -} - -export default ChangeTopologyModalComponent diff --git a/frontend/src/components/modals/custom-components/NewTopologyModalComponent.js b/frontend/src/components/modals/custom-components/NewTopologyModalComponent.js new file mode 100644 index 00000000..a0d736a1 --- /dev/null +++ b/frontend/src/components/modals/custom-components/NewTopologyModalComponent.js @@ -0,0 +1,92 @@ +import PropTypes from 'prop-types' +import React from 'react' +import Shapes from '../../../shapes' +import Modal from '../Modal' + +class NewTopologyModalComponent extends React.Component { + static propTypes = { + show: PropTypes.bool.isRequired, + topologies: PropTypes.arrayOf(Shapes.Topology), + onCreateTopology: PropTypes.func.isRequired, + onDuplicateTopology: PropTypes.func.isRequired, + onCancel: PropTypes.func.isRequired, + } + + reset() { + this.textInput.value = '' + this.originTopology.selectedIndex = 0 + } + + onSubmit() { + if (this.originTopology.selectedIndex === 0) { + this.onCreate() + } else { + this.onDuplicate() + } + } + + onCreate() { + this.props.onCreateTopology(this.textInput.value) + this.reset() + } + + onDuplicate() { + this.props.onCreateTopology( + this.textInput.value, + this.originTopology.value, + ) + this.reset() + } + + onCancel() { + this.props.onCancel() + this.reset() + } + + render() { + return ( + +
{ + e.preventDefault() + this.onSubmit() + }} + > +
+ + (this.textInput = textInput)} + /> +
+
+ + +
+
+
+ ) + } +} + +export default NewTopologyModalComponent -- cgit v1.2.3