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 --- .../sidebars/project/ProjectSidebarComponent.js | 12 ++ .../app/sidebars/project/TopologyListComponent.js | 63 ++++++++++ .../ChangeTopologyModalComponent.js | 131 --------------------- .../custom-components/NewTopologyModalComponent.js | 92 +++++++++++++++ frontend/src/components/navigation/AppNavbar.js | 54 --------- .../components/navigation/AppNavbarComponent.js | 27 +++++ 6 files changed, 194 insertions(+), 185 deletions(-) create mode 100644 frontend/src/components/app/sidebars/project/ProjectSidebarComponent.js create mode 100644 frontend/src/components/app/sidebars/project/TopologyListComponent.js delete mode 100644 frontend/src/components/modals/custom-components/ChangeTopologyModalComponent.js create mode 100644 frontend/src/components/modals/custom-components/NewTopologyModalComponent.js delete mode 100644 frontend/src/components/navigation/AppNavbar.js create mode 100644 frontend/src/components/navigation/AppNavbarComponent.js (limited to 'frontend/src/components') diff --git a/frontend/src/components/app/sidebars/project/ProjectSidebarComponent.js b/frontend/src/components/app/sidebars/project/ProjectSidebarComponent.js new file mode 100644 index 00000000..d6e39ff6 --- /dev/null +++ b/frontend/src/components/app/sidebars/project/ProjectSidebarComponent.js @@ -0,0 +1,12 @@ +import React from 'react' +import Sidebar from '../Sidebar' +import TopologyListContainer from '../../../../containers/app/sidebars/project/TopologyListContainer' + +const ProjectSidebarComponent = () => ( + + +

Portfolios

+
+ ) + +export default ProjectSidebarComponent diff --git a/frontend/src/components/app/sidebars/project/TopologyListComponent.js b/frontend/src/components/app/sidebars/project/TopologyListComponent.js new file mode 100644 index 00000000..98615711 --- /dev/null +++ b/frontend/src/components/app/sidebars/project/TopologyListComponent.js @@ -0,0 +1,63 @@ +import PropTypes from 'prop-types' +import React from 'react' +import Shapes from '../../../../shapes' +import FontAwesome from 'react-fontawesome' + +class TopologyListComponent extends React.Component { + static propTypes = { + show: PropTypes.bool.isRequired, + topologies: PropTypes.arrayOf(Shapes.Topology), + currentTopologyId: PropTypes.string, + onChooseTopology: PropTypes.func.isRequired, + onNewTopology: PropTypes.func.isRequired, + onDeleteTopology: PropTypes.func.isRequired, + } + + onChoose(id) { + this.props.onChooseTopology(id) + } + + onDuplicate() { + this.props.onNewTopology( + this.textInput.value, + this.originTopology.value, + ) + } + + onDelete(id) { + this.props.onDeleteTopology(id) + } + + render() { + return ( +
+

+ Topologies + +

+ + {this.props.topologies.map((topology, idx) => ( +
+
+ {topology.name} +
+
+ this.onChoose(topology._id)} + /> + idx !== 0 ? this.onDelete(topology._id) : undefined} + /> +
+
+ ))} +
+ ) + } +} + +export default TopologyListComponent 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 diff --git a/frontend/src/components/navigation/AppNavbar.js b/frontend/src/components/navigation/AppNavbar.js deleted file mode 100644 index 876d4abd..00000000 --- a/frontend/src/components/navigation/AppNavbar.js +++ /dev/null @@ -1,54 +0,0 @@ -import React from 'react' -import FontAwesome from 'react-fontawesome' -import { Link } from 'react-router-dom' -import Navbar, { NavItem } from './Navbar' -import './Navbar.css' - -const AppNavbar = ({ projectId, inProject, fullWidth, onViewTopologies }) => ( - - - - - My Projects - - - {inProject ? ( - <> - - - - Construction - - - - - - Topologies - - - - - - Experiments - - - - ) : ( - undefined - )} - -) - -export default AppNavbar diff --git a/frontend/src/components/navigation/AppNavbarComponent.js b/frontend/src/components/navigation/AppNavbarComponent.js new file mode 100644 index 00000000..10a2b92c --- /dev/null +++ b/frontend/src/components/navigation/AppNavbarComponent.js @@ -0,0 +1,27 @@ +import React from 'react' +import FontAwesome from 'react-fontawesome' +import { Link } from 'react-router-dom' +import Navbar, { NavItem } from './Navbar' +import './Navbar.css' + +const AppNavbarComponent = ({ project, fullWidth }) => ( + + + + + My Projects + + + {project ? ( + + + {project.name} + + + ) : ( + undefined + )} + +) + +export default AppNavbarComponent -- cgit v1.2.3