From cd0b45627f0d8da8c8dc4edde223f3c36e9bcfbf Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Sun, 25 Apr 2021 16:01:14 +0200 Subject: build: Migrate to flat project structure This change updates the project structure to become flattened. Previously, the simulator, frontend and API each lived into their own directory. With this change, all modules of the project live in the top-level directory of the repository. This should improve discoverability of modules of the project. --- .../src/containers/modals/DeleteMachineModal.js | 35 +++++++++++++++ .../src/containers/modals/DeleteProfileModal.js | 35 +++++++++++++++ .../src/containers/modals/DeleteRackModal.js | 35 +++++++++++++++ .../src/containers/modals/DeleteRoomModal.js | 35 +++++++++++++++ .../src/containers/modals/EditRackNameModal.js | 40 +++++++++++++++++ .../src/containers/modals/EditRoomNameModal.js | 38 ++++++++++++++++ .../src/containers/modals/NewPortfolioModal.js | 30 +++++++++++++ .../src/containers/modals/NewProjectModal.js | 30 +++++++++++++ .../src/containers/modals/NewScenarioModal.js | 50 ++++++++++++++++++++++ .../src/containers/modals/NewTopologyModal.js | 42 ++++++++++++++++++ 10 files changed, 370 insertions(+) create mode 100644 opendc-web/opendc-web-ui/src/containers/modals/DeleteMachineModal.js create mode 100644 opendc-web/opendc-web-ui/src/containers/modals/DeleteProfileModal.js create mode 100644 opendc-web/opendc-web-ui/src/containers/modals/DeleteRackModal.js create mode 100644 opendc-web/opendc-web-ui/src/containers/modals/DeleteRoomModal.js create mode 100644 opendc-web/opendc-web-ui/src/containers/modals/EditRackNameModal.js create mode 100644 opendc-web/opendc-web-ui/src/containers/modals/EditRoomNameModal.js create mode 100644 opendc-web/opendc-web-ui/src/containers/modals/NewPortfolioModal.js create mode 100644 opendc-web/opendc-web-ui/src/containers/modals/NewProjectModal.js create mode 100644 opendc-web/opendc-web-ui/src/containers/modals/NewScenarioModal.js create mode 100644 opendc-web/opendc-web-ui/src/containers/modals/NewTopologyModal.js (limited to 'opendc-web/opendc-web-ui/src/containers/modals') diff --git a/opendc-web/opendc-web-ui/src/containers/modals/DeleteMachineModal.js b/opendc-web/opendc-web-ui/src/containers/modals/DeleteMachineModal.js new file mode 100644 index 00000000..f30febdb --- /dev/null +++ b/opendc-web/opendc-web-ui/src/containers/modals/DeleteMachineModal.js @@ -0,0 +1,35 @@ +import React from 'react' +import { connect } from 'react-redux' +import { closeDeleteMachineModal } from '../../actions/modals/topology' +import { deleteMachine } from '../../actions/topology/machine' +import ConfirmationModal from '../../components/modals/ConfirmationModal' + +const DeleteMachineModalComponent = ({ visible, callback }) => ( + +) + +const mapStateToProps = (state) => { + return { + visible: state.modals.deleteMachineModalVisible, + } +} + +const mapDispatchToProps = (dispatch) => { + return { + callback: (isConfirmed) => { + if (isConfirmed) { + dispatch(deleteMachine()) + } + dispatch(closeDeleteMachineModal()) + }, + } +} + +const DeleteMachineModal = connect(mapStateToProps, mapDispatchToProps)(DeleteMachineModalComponent) + +export default DeleteMachineModal diff --git a/opendc-web/opendc-web-ui/src/containers/modals/DeleteProfileModal.js b/opendc-web/opendc-web-ui/src/containers/modals/DeleteProfileModal.js new file mode 100644 index 00000000..e7c4014d --- /dev/null +++ b/opendc-web/opendc-web-ui/src/containers/modals/DeleteProfileModal.js @@ -0,0 +1,35 @@ +import React from 'react' +import { connect } from 'react-redux' +import { closeDeleteProfileModal } from '../../actions/modals/profile' +import { deleteCurrentUser } from '../../actions/users' +import ConfirmationModal from '../../components/modals/ConfirmationModal' + +const DeleteProfileModalComponent = ({ visible, callback }) => ( + +) + +const mapStateToProps = (state) => { + return { + visible: state.modals.deleteProfileModalVisible, + } +} + +const mapDispatchToProps = (dispatch) => { + return { + callback: (isConfirmed) => { + if (isConfirmed) { + dispatch(deleteCurrentUser()) + } + dispatch(closeDeleteProfileModal()) + }, + } +} + +const DeleteProfileModal = connect(mapStateToProps, mapDispatchToProps)(DeleteProfileModalComponent) + +export default DeleteProfileModal diff --git a/opendc-web/opendc-web-ui/src/containers/modals/DeleteRackModal.js b/opendc-web/opendc-web-ui/src/containers/modals/DeleteRackModal.js new file mode 100644 index 00000000..0cb22a7e --- /dev/null +++ b/opendc-web/opendc-web-ui/src/containers/modals/DeleteRackModal.js @@ -0,0 +1,35 @@ +import React from 'react' +import { connect } from 'react-redux' +import { closeDeleteRackModal } from '../../actions/modals/topology' +import { deleteRack } from '../../actions/topology/rack' +import ConfirmationModal from '../../components/modals/ConfirmationModal' + +const DeleteRackModalComponent = ({ visible, callback }) => ( + +) + +const mapStateToProps = (state) => { + return { + visible: state.modals.deleteRackModalVisible, + } +} + +const mapDispatchToProps = (dispatch) => { + return { + callback: (isConfirmed) => { + if (isConfirmed) { + dispatch(deleteRack()) + } + dispatch(closeDeleteRackModal()) + }, + } +} + +const DeleteRackModal = connect(mapStateToProps, mapDispatchToProps)(DeleteRackModalComponent) + +export default DeleteRackModal diff --git a/opendc-web/opendc-web-ui/src/containers/modals/DeleteRoomModal.js b/opendc-web/opendc-web-ui/src/containers/modals/DeleteRoomModal.js new file mode 100644 index 00000000..1f6eef92 --- /dev/null +++ b/opendc-web/opendc-web-ui/src/containers/modals/DeleteRoomModal.js @@ -0,0 +1,35 @@ +import React from 'react' +import { connect } from 'react-redux' +import { closeDeleteRoomModal } from '../../actions/modals/topology' +import { deleteRoom } from '../../actions/topology/room' +import ConfirmationModal from '../../components/modals/ConfirmationModal' + +const DeleteRoomModalComponent = ({ visible, callback }) => ( + +) + +const mapStateToProps = (state) => { + return { + visible: state.modals.deleteRoomModalVisible, + } +} + +const mapDispatchToProps = (dispatch) => { + return { + callback: (isConfirmed) => { + if (isConfirmed) { + dispatch(deleteRoom()) + } + dispatch(closeDeleteRoomModal()) + }, + } +} + +const DeleteRoomModal = connect(mapStateToProps, mapDispatchToProps)(DeleteRoomModalComponent) + +export default DeleteRoomModal diff --git a/opendc-web/opendc-web-ui/src/containers/modals/EditRackNameModal.js b/opendc-web/opendc-web-ui/src/containers/modals/EditRackNameModal.js new file mode 100644 index 00000000..9128f449 --- /dev/null +++ b/opendc-web/opendc-web-ui/src/containers/modals/EditRackNameModal.js @@ -0,0 +1,40 @@ +import React from 'react' +import { connect } from 'react-redux' +import { closeEditRackNameModal } from '../../actions/modals/topology' +import { editRackName } from '../../actions/topology/rack' +import TextInputModal from '../../components/modals/TextInputModal' + +const EditRackNameModalComponent = ({ visible, previousName, callback }) => ( + +) + +const mapStateToProps = (state) => { + return { + visible: state.modals.editRackNameModalVisible, + previousName: + state.interactionLevel.mode === 'RACK' + ? state.objects.rack[state.objects.tile[state.interactionLevel.tileId].rackId].name + : '', + } +} + +const mapDispatchToProps = (dispatch) => { + return { + callback: (name) => { + if (name) { + dispatch(editRackName(name)) + } + dispatch(closeEditRackNameModal()) + }, + } +} + +const EditRackNameModal = connect(mapStateToProps, mapDispatchToProps)(EditRackNameModalComponent) + +export default EditRackNameModal diff --git a/opendc-web/opendc-web-ui/src/containers/modals/EditRoomNameModal.js b/opendc-web/opendc-web-ui/src/containers/modals/EditRoomNameModal.js new file mode 100644 index 00000000..8032a5d1 --- /dev/null +++ b/opendc-web/opendc-web-ui/src/containers/modals/EditRoomNameModal.js @@ -0,0 +1,38 @@ +import React from 'react' +import { connect } from 'react-redux' +import { closeEditRoomNameModal } from '../../actions/modals/topology' +import { editRoomName } from '../../actions/topology/room' +import TextInputModal from '../../components/modals/TextInputModal' + +const EditRoomNameModalComponent = ({ visible, previousName, callback }) => ( + +) + +const mapStateToProps = (state) => { + return { + visible: state.modals.editRoomNameModalVisible, + previousName: + state.interactionLevel.mode === 'ROOM' ? state.objects.room[state.interactionLevel.roomId].name : '', + } +} + +const mapDispatchToProps = (dispatch) => { + return { + callback: (name) => { + if (name) { + dispatch(editRoomName(name)) + } + dispatch(closeEditRoomNameModal()) + }, + } +} + +const EditRoomNameModal = connect(mapStateToProps, mapDispatchToProps)(EditRoomNameModalComponent) + +export default EditRoomNameModal diff --git a/opendc-web/opendc-web-ui/src/containers/modals/NewPortfolioModal.js b/opendc-web/opendc-web-ui/src/containers/modals/NewPortfolioModal.js new file mode 100644 index 00000000..6cf12d8e --- /dev/null +++ b/opendc-web/opendc-web-ui/src/containers/modals/NewPortfolioModal.js @@ -0,0 +1,30 @@ +import { connect } from 'react-redux' +import NewPortfolioModalComponent from '../../components/modals/custom-components/NewPortfolioModalComponent' +import { addPortfolio } from '../../actions/portfolios' +import { closeNewPortfolioModal } from '../../actions/modals/portfolios' + +const mapStateToProps = (state) => { + return { + show: state.modals.newPortfolioModalVisible, + } +} + +const mapDispatchToProps = (dispatch) => { + return { + callback: (name, targets) => { + if (name) { + dispatch( + addPortfolio({ + name, + targets, + }) + ) + } + dispatch(closeNewPortfolioModal()) + }, + } +} + +const NewPortfolioModal = connect(mapStateToProps, mapDispatchToProps)(NewPortfolioModalComponent) + +export default NewPortfolioModal diff --git a/opendc-web/opendc-web-ui/src/containers/modals/NewProjectModal.js b/opendc-web/opendc-web-ui/src/containers/modals/NewProjectModal.js new file mode 100644 index 00000000..d306dc45 --- /dev/null +++ b/opendc-web/opendc-web-ui/src/containers/modals/NewProjectModal.js @@ -0,0 +1,30 @@ +import React from 'react' +import { connect } from 'react-redux' +import { closeNewProjectModal } from '../../actions/modals/projects' +import { addProject } from '../../actions/projects' +import TextInputModal from '../../components/modals/TextInputModal' + +const NewProjectModalComponent = ({ visible, callback }) => ( + +) + +const mapStateToProps = (state) => { + return { + visible: state.modals.newProjectModalVisible, + } +} + +const mapDispatchToProps = (dispatch) => { + return { + callback: (text) => { + if (text) { + dispatch(addProject(text)) + } + dispatch(closeNewProjectModal()) + }, + } +} + +const NewProjectModal = connect(mapStateToProps, mapDispatchToProps)(NewProjectModalComponent) + +export default NewProjectModal diff --git a/opendc-web/opendc-web-ui/src/containers/modals/NewScenarioModal.js b/opendc-web/opendc-web-ui/src/containers/modals/NewScenarioModal.js new file mode 100644 index 00000000..7d774fa4 --- /dev/null +++ b/opendc-web/opendc-web-ui/src/containers/modals/NewScenarioModal.js @@ -0,0 +1,50 @@ +import { connect } from 'react-redux' +import NewScenarioModalComponent from '../../components/modals/custom-components/NewScenarioModalComponent' +import { addScenario } from '../../actions/scenarios' +import { closeNewScenarioModal } from '../../actions/modals/scenarios' + +const mapStateToProps = (state) => { + let topologies = + state.currentProjectId !== '-1' + ? state.objects.project[state.currentProjectId].topologyIds.map((t) => state.objects.topology[t]) + : [] + if (topologies.filter((t) => !t).length > 0) { + topologies = [] + } + + return { + show: state.modals.newScenarioModalVisible, + currentPortfolioId: state.currentPortfolioId, + currentPortfolioScenarioIds: + state.currentPortfolioId !== '-1' && state.objects.portfolio[state.currentPortfolioId] + ? state.objects.portfolio[state.currentPortfolioId].scenarioIds + : [], + traces: Object.values(state.objects.trace), + topologies, + schedulers: Object.values(state.objects.scheduler), + } +} + +const mapDispatchToProps = (dispatch) => { + return { + callback: (name, portfolioId, trace, topology, operational) => { + if (name) { + dispatch( + addScenario({ + portfolioId, + name, + trace, + topology, + operational, + }) + ) + } + + dispatch(closeNewScenarioModal()) + }, + } +} + +const NewScenarioModal = connect(mapStateToProps, mapDispatchToProps)(NewScenarioModalComponent) + +export default NewScenarioModal diff --git a/opendc-web/opendc-web-ui/src/containers/modals/NewTopologyModal.js b/opendc-web/opendc-web-ui/src/containers/modals/NewTopologyModal.js new file mode 100644 index 00000000..0acf6cf2 --- /dev/null +++ b/opendc-web/opendc-web-ui/src/containers/modals/NewTopologyModal.js @@ -0,0 +1,42 @@ +import { connect } from 'react-redux' +import NewTopologyModalComponent from '../../components/modals/custom-components/NewTopologyModalComponent' +import { closeNewTopologyModal } from '../../actions/modals/topology' +import { addTopology } from '../../actions/topologies' + +const mapStateToProps = (state) => { + let topologies = state.objects.project[state.currentProjectId] + ? state.objects.project[state.currentProjectId].topologyIds.map((t) => state.objects.topology[t]) + : [] + if (topologies.filter((t) => !t).length > 0) { + topologies = [] + } + + return { + show: state.modals.changeTopologyModalVisible, + topologies, + } +} + +const mapDispatchToProps = (dispatch) => { + return { + onCreateTopology: (name) => { + if (name) { + dispatch(addTopology(name, undefined)) + } + dispatch(closeNewTopologyModal()) + }, + onDuplicateTopology: (name, id) => { + if (name) { + dispatch(addTopology(name, id)) + } + dispatch(closeNewTopologyModal()) + }, + onCancel: () => { + dispatch(closeNewTopologyModal()) + }, + } +} + +const NewTopologyModal = connect(mapStateToProps, mapDispatchToProps)(NewTopologyModalComponent) + +export default NewTopologyModal -- cgit v1.2.3