From 3f736cd3db63f106eac02f220477b4a0f3b0eceb Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Thu, 31 Aug 2017 17:59:51 +0200 Subject: Implement room creation --- src/containers/map/DatacenterContainer.js | 5 +---- src/containers/map/RoomContainer.js | 8 +++++--- src/containers/map/TileContainer.js | 13 ++++++------ src/containers/map/WallContainer.js | 14 +++++++++++++ src/containers/map/layers/HoverTileLayer.js | 23 ++++++++++++++++++++++ src/containers/sidebars/TopologySidebar.js | 14 ------------- .../sidebars/topology/TopologySidebar.js | 14 +++++++++++++ .../topology/building/BuildingSidebarContent.js | 14 +++++++++++++ .../building/CancelNewRoomConstructionButton.js | 16 +++++++++++++++ .../building/FinishNewRoomConstructionButton.js | 16 +++++++++++++++ .../building/StartNewRoomConstructionButton.js | 16 +++++++++++++++ src/containers/simulations/SimulationActions.js | 2 +- 12 files changed, 127 insertions(+), 28 deletions(-) create mode 100644 src/containers/map/WallContainer.js create mode 100644 src/containers/map/layers/HoverTileLayer.js delete mode 100644 src/containers/sidebars/TopologySidebar.js create mode 100644 src/containers/sidebars/topology/TopologySidebar.js create mode 100644 src/containers/sidebars/topology/building/BuildingSidebarContent.js create mode 100644 src/containers/sidebars/topology/building/CancelNewRoomConstructionButton.js create mode 100644 src/containers/sidebars/topology/building/FinishNewRoomConstructionButton.js create mode 100644 src/containers/sidebars/topology/building/StartNewRoomConstructionButton.js (limited to 'src/containers') diff --git a/src/containers/map/DatacenterContainer.js b/src/containers/map/DatacenterContainer.js index 00b6e79f..8c80146d 100644 --- a/src/containers/map/DatacenterContainer.js +++ b/src/containers/map/DatacenterContainer.js @@ -1,16 +1,13 @@ import {connect} from "react-redux"; import DatacenterGroup from "../../components/map/groups/DatacenterGroup"; -import {denormalize} from "../../store/denormalizer"; const mapStateToProps = state => { if (state.currentDatacenterId === -1) { return {}; } - const datacenter = denormalize(state, "datacenter", state.currentDatacenterId); - return { - datacenter, + datacenter: state.objects.datacenter[state.currentDatacenterId], interactionLevel: state.interactionLevel }; }; diff --git a/src/containers/map/RoomContainer.js b/src/containers/map/RoomContainer.js index d46324b2..2d078e09 100644 --- a/src/containers/map/RoomContainer.js +++ b/src/containers/map/RoomContainer.js @@ -2,15 +2,17 @@ import {connect} from "react-redux"; import {goFromBuildingToRoom} from "../../actions/interaction-level"; import RoomGroup from "../../components/map/groups/RoomGroup"; -const mapStateToProps = state => { +const mapStateToProps = (state, ownProps) => { return { - interactionLevel: state.interactionLevel + interactionLevel: state.interactionLevel, + currentRoomInConstruction: state.currentRoomInConstruction, + room: state.objects.room[ownProps.roomId], }; }; const mapDispatchToProps = (dispatch, ownProps) => { return { - onClick: () => dispatch(goFromBuildingToRoom(ownProps.room.id)) + onClick: () => dispatch(goFromBuildingToRoom(ownProps.roomId)), }; }; diff --git a/src/containers/map/TileContainer.js b/src/containers/map/TileContainer.js index 0456c423..d00c3611 100644 --- a/src/containers/map/TileContainer.js +++ b/src/containers/map/TileContainer.js @@ -2,17 +2,18 @@ import {connect} from "react-redux"; import {goFromRoomToObject} from "../../actions/interaction-level"; import TileGroup from "../../components/map/groups/TileGroup"; -const mapStateToProps = state => { +const mapStateToProps = (state, ownProps) => { return { - interactionLevel: state.interactionLevel + interactionLevel: state.interactionLevel, + tile: state.objects.tile[ownProps.tileId], }; }; -const mapDispatchToProps = (dispatch, ownProps) => { +const mapDispatchToProps = dispatch => { return { - onClick: () => { - if (ownProps.tile.objectType) { - dispatch(goFromRoomToObject(ownProps.tile.id)) + onClick: tile => { + if (tile.objectType) { + dispatch(goFromRoomToObject(tile.id)) } } }; diff --git a/src/containers/map/WallContainer.js b/src/containers/map/WallContainer.js new file mode 100644 index 00000000..f8ccb2e9 --- /dev/null +++ b/src/containers/map/WallContainer.js @@ -0,0 +1,14 @@ +import {connect} from "react-redux"; +import WallGroup from "../../components/map/groups/WallGroup"; + +const mapStateToProps = (state, ownProps) => { + return { + tiles: state.objects.room[ownProps.roomId].tileIds.map(tileId => state.objects.tile[tileId]), + }; +}; + +const WallContainer = connect( + mapStateToProps +)(WallGroup); + +export default WallContainer; diff --git a/src/containers/map/layers/HoverTileLayer.js b/src/containers/map/layers/HoverTileLayer.js new file mode 100644 index 00000000..b8868233 --- /dev/null +++ b/src/containers/map/layers/HoverTileLayer.js @@ -0,0 +1,23 @@ +import {connect} from "react-redux"; +import {toggleTileAtLocation} from "../../../actions/topology"; +import HoverTileLayerComponent from "../../../components/map/layers/HoverTileLayerComponent"; + +const mapStateToProps = state => { + return { + currentRoomInConstruction: state.currentRoomInConstruction, + isValid: (x, y) => true, // TODO implement proper validation + }; +}; + +const mapDispatchToProps = dispatch => { + return { + onClick: (x, y) => dispatch(toggleTileAtLocation(x, y)), + }; +}; + +const HoverTileLayer = connect( + mapStateToProps, + mapDispatchToProps +)(HoverTileLayerComponent); + +export default HoverTileLayer; diff --git a/src/containers/sidebars/TopologySidebar.js b/src/containers/sidebars/TopologySidebar.js deleted file mode 100644 index 1909443a..00000000 --- a/src/containers/sidebars/TopologySidebar.js +++ /dev/null @@ -1,14 +0,0 @@ -import {connect} from "react-redux"; -import TopologySidebarComponent from "../../components/sidebars/TopologySidebarComponent"; - -const mapStateToProps = state => { - return { - interactionLevel: state.interactionLevel - }; -}; - -const TopologySidebar = connect( - mapStateToProps -)(TopologySidebarComponent); - -export default TopologySidebar; diff --git a/src/containers/sidebars/topology/TopologySidebar.js b/src/containers/sidebars/topology/TopologySidebar.js new file mode 100644 index 00000000..6ed836da --- /dev/null +++ b/src/containers/sidebars/topology/TopologySidebar.js @@ -0,0 +1,14 @@ +import {connect} from "react-redux"; +import TopologySidebarComponent from "../../../components/sidebars/topology/TopologySidebarComponent"; + +const mapStateToProps = state => { + return { + interactionLevel: state.interactionLevel + }; +}; + +const TopologySidebar = connect( + mapStateToProps +)(TopologySidebarComponent); + +export default TopologySidebar; diff --git a/src/containers/sidebars/topology/building/BuildingSidebarContent.js b/src/containers/sidebars/topology/building/BuildingSidebarContent.js new file mode 100644 index 00000000..c70c6982 --- /dev/null +++ b/src/containers/sidebars/topology/building/BuildingSidebarContent.js @@ -0,0 +1,14 @@ +import {connect} from "react-redux"; +import BuildingSidebarContentComponent from "../../../../components/sidebars/topology/building/BuildingSidebarContentComponent"; + +const mapStateToProps = state => { + return { + currentRoomInConstruction: state.currentRoomInConstruction + }; +}; + +const BuildingSidebarContent = connect( + mapStateToProps +)(BuildingSidebarContentComponent); + +export default BuildingSidebarContent; diff --git a/src/containers/sidebars/topology/building/CancelNewRoomConstructionButton.js b/src/containers/sidebars/topology/building/CancelNewRoomConstructionButton.js new file mode 100644 index 00000000..6061da96 --- /dev/null +++ b/src/containers/sidebars/topology/building/CancelNewRoomConstructionButton.js @@ -0,0 +1,16 @@ +import {connect} from "react-redux"; +import {cancelNewRoomConstruction} from "../../../../actions/topology"; +import CancelNewRoomConstructionComponent from "../../../../components/sidebars/topology/building/CancelNewRoomConstructionComponent"; + +const mapDispatchToProps = dispatch => { + return { + onClick: () => dispatch(cancelNewRoomConstruction()), + }; +}; + +const CancelNewRoomConstructionButton = connect( + null, + mapDispatchToProps +)(CancelNewRoomConstructionComponent); + +export default CancelNewRoomConstructionButton; diff --git a/src/containers/sidebars/topology/building/FinishNewRoomConstructionButton.js b/src/containers/sidebars/topology/building/FinishNewRoomConstructionButton.js new file mode 100644 index 00000000..ca34dcc3 --- /dev/null +++ b/src/containers/sidebars/topology/building/FinishNewRoomConstructionButton.js @@ -0,0 +1,16 @@ +import {connect} from "react-redux"; +import {finishNewRoomConstruction} from "../../../../actions/topology"; +import FinishNewRoomConstructionComponent from "../../../../components/sidebars/topology/building/FinishNewRoomConstructionComponent"; + +const mapDispatchToProps = dispatch => { + return { + onClick: () => dispatch(finishNewRoomConstruction()), + }; +}; + +const FinishNewRoomConstructionButton = connect( + null, + mapDispatchToProps +)(FinishNewRoomConstructionComponent); + +export default FinishNewRoomConstructionButton; diff --git a/src/containers/sidebars/topology/building/StartNewRoomConstructionButton.js b/src/containers/sidebars/topology/building/StartNewRoomConstructionButton.js new file mode 100644 index 00000000..f26eb5d4 --- /dev/null +++ b/src/containers/sidebars/topology/building/StartNewRoomConstructionButton.js @@ -0,0 +1,16 @@ +import {connect} from "react-redux"; +import {startNewRoomConstruction} from "../../../../actions/topology"; +import StartNewRoomConstructionComponent from "../../../../components/sidebars/topology/building/StartNewRoomConstructionComponent"; + +const mapDispatchToProps = dispatch => { + return { + onClick: () => dispatch(startNewRoomConstruction()), + }; +}; + +const StartNewRoomConstructionButton = connect( + null, + mapDispatchToProps +)(StartNewRoomConstructionComponent); + +export default StartNewRoomConstructionButton; diff --git a/src/containers/simulations/SimulationActions.js b/src/containers/simulations/SimulationActions.js index 01ccaa91..4dc93c77 100644 --- a/src/containers/simulations/SimulationActions.js +++ b/src/containers/simulations/SimulationActions.js @@ -10,7 +10,7 @@ const mapStateToProps = (state, ownProps) => { const mapDispatchToProps = dispatch => { return { - onViewUsers: (id) => {}, + onViewUsers: (id) => {}, // TODO implement user viewing onDelete: (id) => dispatch(deleteSimulation(id)), }; }; -- cgit v1.2.3