summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/containers/modals
diff options
context:
space:
mode:
Diffstat (limited to 'opendc-web/opendc-web-ui/src/containers/modals')
-rw-r--r--opendc-web/opendc-web-ui/src/containers/modals/DeleteMachineModal.js35
-rw-r--r--opendc-web/opendc-web-ui/src/containers/modals/DeleteProfileModal.js35
-rw-r--r--opendc-web/opendc-web-ui/src/containers/modals/DeleteRackModal.js35
-rw-r--r--opendc-web/opendc-web-ui/src/containers/modals/DeleteRoomModal.js35
-rw-r--r--opendc-web/opendc-web-ui/src/containers/modals/EditRackNameModal.js40
-rw-r--r--opendc-web/opendc-web-ui/src/containers/modals/EditRoomNameModal.js38
-rw-r--r--opendc-web/opendc-web-ui/src/containers/modals/NewPortfolioModal.js30
-rw-r--r--opendc-web/opendc-web-ui/src/containers/modals/NewProjectModal.js30
-rw-r--r--opendc-web/opendc-web-ui/src/containers/modals/NewScenarioModal.js50
-rw-r--r--opendc-web/opendc-web-ui/src/containers/modals/NewTopologyModal.js42
10 files changed, 370 insertions, 0 deletions
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 }) => (
+ <ConfirmationModal
+ title="Delete this machine"
+ message="Are you sure you want to delete this machine?"
+ show={visible}
+ callback={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 }) => (
+ <ConfirmationModal
+ title="Delete my account"
+ message="Are you sure you want to delete your OpenDC account?"
+ show={visible}
+ callback={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 }) => (
+ <ConfirmationModal
+ title="Delete this rack"
+ message="Are you sure you want to delete this rack?"
+ show={visible}
+ callback={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 }) => (
+ <ConfirmationModal
+ title="Delete this room"
+ message="Are you sure you want to delete this room?"
+ show={visible}
+ callback={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 }) => (
+ <TextInputModal
+ title="Edit rack name"
+ label="Rack name"
+ show={visible}
+ initialValue={previousName}
+ callback={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 }) => (
+ <TextInputModal
+ title="Edit room name"
+ label="Room name"
+ show={visible}
+ initialValue={previousName}
+ callback={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 }) => (
+ <TextInputModal title="New Project" label="Project title" show={visible} callback={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