diff options
| author | Georgios Andreadis <info@gandreadis.com> | 2020-07-03 11:46:29 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-08-24 19:47:22 +0200 |
| commit | 52865c97f820b883977179930ce4961abdb39c12 (patch) | |
| tree | 6b429d80694d7e5729fb1f41ff8f9ba4b2d07d4b /frontend | |
| parent | 39277c91281dbc7bd40bdffabc5b5675e9ede483 (diff) | |
Fix integer IDs and topology deletion
Diffstat (limited to 'frontend')
30 files changed, 41 insertions, 42 deletions
diff --git a/frontend/src/components/app/sidebars/topology/building/NewRoomConstructionComponent.js b/frontend/src/components/app/sidebars/topology/building/NewRoomConstructionComponent.js index 362483bf..75b00c54 100644 --- a/frontend/src/components/app/sidebars/topology/building/NewRoomConstructionComponent.js +++ b/frontend/src/components/app/sidebars/topology/building/NewRoomConstructionComponent.js @@ -6,7 +6,7 @@ const NewRoomConstructionComponent = ({ onCancel, currentRoomInConstruction, }) => { - if (currentRoomInConstruction === -1) { + if (currentRoomInConstruction === '-1') { return ( <div className="btn btn-outline-primary btn-block" onClick={onStart}> <span className="fa fa-plus mr-2"/> diff --git a/frontend/src/components/modals/Modal.js b/frontend/src/components/modals/Modal.js index ec6080f2..dd8cea8e 100644 --- a/frontend/src/components/modals/Modal.js +++ b/frontend/src/components/modals/Modal.js @@ -50,8 +50,10 @@ class Modal extends React.Component { } componentDidUpdate() { - this.visible = this.props.show - this.openOrCloseModal() + if (this.visible !== this.props.show) { + this.visible = this.props.show + this.openOrCloseModal() + } } onSubmit() { diff --git a/frontend/src/components/modals/custom-components/ChangeTopologyModalComponent.js b/frontend/src/components/modals/custom-components/ChangeTopologyModalComponent.js index f1645dcf..c7c81706 100644 --- a/frontend/src/components/modals/custom-components/ChangeTopologyModalComponent.js +++ b/frontend/src/components/modals/custom-components/ChangeTopologyModalComponent.js @@ -7,7 +7,7 @@ class ChangeTopologyModalComponent extends React.Component { static propTypes = { show: PropTypes.bool.isRequired, topologies: PropTypes.arrayOf(Shapes.Topology), - currentTopologyId: PropTypes.number, + currentTopologyId: PropTypes.string, onChooseTopology: PropTypes.func.isRequired, onCreateTopology: PropTypes.func.isRequired, onDuplicateTopology: PropTypes.func.isRequired, diff --git a/frontend/src/components/navigation/AppNavbar.js b/frontend/src/components/navigation/AppNavbar.js index c3ab3c47..15f08b5f 100644 --- a/frontend/src/components/navigation/AppNavbar.js +++ b/frontend/src/components/navigation/AppNavbar.js @@ -26,7 +26,7 @@ const AppNavbar = ({ simulationId, inSimulation, fullWidth, onViewTopologies }) </NavItem> <NavItem route="topologies"> <span - className="nav-link clickable" + className="nav-link" title="Topologies" onClick={onViewTopologies} > diff --git a/frontend/src/components/navigation/Navbar.js b/frontend/src/components/navigation/Navbar.js index d22f637e..b47f1f94 100644 --- a/frontend/src/components/navigation/Navbar.js +++ b/frontend/src/components/navigation/Navbar.js @@ -27,7 +27,7 @@ const GitHubLink = () => ( const NavItemWithoutRoute = ({ route, location, children }) => ( <li className={classNames( - 'nav-item', + 'nav-item clickable', location.pathname === route ? 'active' : undefined, )} > diff --git a/frontend/src/containers/app/map/RackContainer.js b/frontend/src/containers/app/map/RackContainer.js index 362ba2e2..34e7bbab 100644 --- a/frontend/src/containers/app/map/RackContainer.js +++ b/frontend/src/containers/app/map/RackContainer.js @@ -3,7 +3,7 @@ import RackGroup from '../../../components/app/map/groups/RackGroup' import { getStateLoad } from '../../../util/simulation-load' const mapStateToProps = (state, ownProps) => { - const inSimulation = state.currentExperimentId !== -1 + const inSimulation = state.currentExperimentId !== '-1' let rackLoad = undefined if (inSimulation) { diff --git a/frontend/src/containers/app/map/TileContainer.js b/frontend/src/containers/app/map/TileContainer.js index 7d9f7754..28289206 100644 --- a/frontend/src/containers/app/map/TileContainer.js +++ b/frontend/src/containers/app/map/TileContainer.js @@ -5,7 +5,7 @@ import { getStateLoad } from '../../../util/simulation-load' const mapStateToProps = (state, ownProps) => { const tile = state.objects.tile[ownProps.tileId] - const inSimulation = state.currentExperimentId !== -1 + const inSimulation = state.currentExperimentId !== '-1' let roomLoad = undefined if (inSimulation) { diff --git a/frontend/src/containers/app/map/TopologyContainer.js b/frontend/src/containers/app/map/TopologyContainer.js index 37cc5a06..6f14d6cd 100644 --- a/frontend/src/containers/app/map/TopologyContainer.js +++ b/frontend/src/containers/app/map/TopologyContainer.js @@ -2,7 +2,7 @@ import { connect } from 'react-redux' import TopologyGroup from '../../../components/app/map/groups/TopologyGroup' const mapStateToProps = state => { - if (state.currentTopologyId === -1) { + if (state.currentTopologyId === '-1') { return {} } diff --git a/frontend/src/containers/app/map/layers/RoomHoverLayer.js b/frontend/src/containers/app/map/layers/RoomHoverLayer.js index c05627ea..2c886c2f 100644 --- a/frontend/src/containers/app/map/layers/RoomHoverLayer.js +++ b/frontend/src/containers/app/map/layers/RoomHoverLayer.js @@ -11,7 +11,7 @@ const mapStateToProps = state => { return { mapPosition: state.map.position, mapScale: state.map.scale, - isEnabled: () => state.construction.currentRoomInConstruction !== -1, + isEnabled: () => state.construction.currentRoomInConstruction !== '-1', isValid: (x, y) => { const newRoom = Object.assign( {}, diff --git a/frontend/src/containers/app/sidebars/topology/building/BuildingSidebarContainer.js b/frontend/src/containers/app/sidebars/topology/building/BuildingSidebarContainer.js index 1869705a..8c8cb79b 100644 --- a/frontend/src/containers/app/sidebars/topology/building/BuildingSidebarContainer.js +++ b/frontend/src/containers/app/sidebars/topology/building/BuildingSidebarContainer.js @@ -3,7 +3,7 @@ import BuildingSidebarComponent from '../../../../../components/app/sidebars/top const mapStateToProps = state => { return { - inSimulation: state.currentExperimentId !== -1, + inSimulation: state.currentExperimentId !== '-1', } } diff --git a/frontend/src/containers/app/sidebars/topology/machine/MachineSidebarContainer.js b/frontend/src/containers/app/sidebars/topology/machine/MachineSidebarContainer.js index a39bd2d6..3cff7cd1 100644 --- a/frontend/src/containers/app/sidebars/topology/machine/MachineSidebarContainer.js +++ b/frontend/src/containers/app/sidebars/topology/machine/MachineSidebarContainer.js @@ -3,7 +3,7 @@ import MachineSidebarComponent from '../../../../../components/app/sidebars/topo const mapStateToProps = state => { return { - inSimulation: state.currentExperimentId !== -1, + inSimulation: state.currentExperimentId !== '-1', machineId: state.objects.rack[ state.objects.tile[state.interactionLevel.tileId].rackId diff --git a/frontend/src/containers/app/sidebars/topology/machine/UnitContainer.js b/frontend/src/containers/app/sidebars/topology/machine/UnitContainer.js index d8e549a7..7c26b47f 100644 --- a/frontend/src/containers/app/sidebars/topology/machine/UnitContainer.js +++ b/frontend/src/containers/app/sidebars/topology/machine/UnitContainer.js @@ -4,7 +4,7 @@ import UnitComponent from '../../../../../components/app/sidebars/topology/machi const mapStateToProps = (state, ownProps) => { return { - inSimulation: state.currentExperimentId !== -1, + inSimulation: state.currentExperimentId !== '-1', unit: state.objects[ownProps.unitType][ownProps.unitId], } } diff --git a/frontend/src/containers/app/sidebars/topology/machine/UnitListContainer.js b/frontend/src/containers/app/sidebars/topology/machine/UnitListContainer.js index 2f11a22f..2596c2bd 100644 --- a/frontend/src/containers/app/sidebars/topology/machine/UnitListContainer.js +++ b/frontend/src/containers/app/sidebars/topology/machine/UnitListContainer.js @@ -3,7 +3,7 @@ import UnitListComponent from '../../../../../components/app/sidebars/topology/m const mapStateToProps = (state, ownProps) => { return { - inSimulation: state.currentExperimentId !== -1, + inSimulation: state.currentExperimentId !== '-1', unitIds: state.objects.machine[ state.objects.rack[ diff --git a/frontend/src/containers/app/sidebars/topology/machine/UnitTabsContainer.js b/frontend/src/containers/app/sidebars/topology/machine/UnitTabsContainer.js index 3490cce6..5c606de4 100644 --- a/frontend/src/containers/app/sidebars/topology/machine/UnitTabsContainer.js +++ b/frontend/src/containers/app/sidebars/topology/machine/UnitTabsContainer.js @@ -3,7 +3,7 @@ import UnitTabsComponent from '../../../../../components/app/sidebars/topology/m const mapStateToProps = state => { return { - inSimulation: state.currentExperimentId !== -1, + inSimulation: state.currentExperimentId !== '-1', } } diff --git a/frontend/src/containers/app/sidebars/topology/rack/EmptySlotContainer.js b/frontend/src/containers/app/sidebars/topology/rack/EmptySlotContainer.js index 07439dc9..d580a3e0 100644 --- a/frontend/src/containers/app/sidebars/topology/rack/EmptySlotContainer.js +++ b/frontend/src/containers/app/sidebars/topology/rack/EmptySlotContainer.js @@ -4,7 +4,7 @@ import EmptySlotComponent from '../../../../../components/app/sidebars/topology/ const mapStateToProps = state => { return { - inSimulation: state.currentExperimentId !== -1, + inSimulation: state.currentExperimentId !== '-1', } } diff --git a/frontend/src/containers/app/sidebars/topology/rack/MachineContainer.js b/frontend/src/containers/app/sidebars/topology/rack/MachineContainer.js index 89818f1d..43558329 100644 --- a/frontend/src/containers/app/sidebars/topology/rack/MachineContainer.js +++ b/frontend/src/containers/app/sidebars/topology/rack/MachineContainer.js @@ -5,7 +5,7 @@ import { getStateLoad } from '../../../../../util/simulation-load' const mapStateToProps = (state, ownProps) => { const machine = state.objects.machine[ownProps.machineId] - const inSimulation = state.currentExperimentId !== -1 + const inSimulation = state.currentExperimentId !== '-1' let machineLoad = undefined if (inSimulation) { diff --git a/frontend/src/containers/app/sidebars/topology/rack/RackSidebarContainer.js b/frontend/src/containers/app/sidebars/topology/rack/RackSidebarContainer.js index 21745b1d..7f931979 100644 --- a/frontend/src/containers/app/sidebars/topology/rack/RackSidebarContainer.js +++ b/frontend/src/containers/app/sidebars/topology/rack/RackSidebarContainer.js @@ -4,7 +4,7 @@ import RackSidebarComponent from '../../../../../components/app/sidebars/topolog const mapStateToProps = state => { return { rackId: state.objects.tile[state.interactionLevel.tileId].rackId, - inSimulation: state.currentExperimentId !== -1, + inSimulation: state.currentExperimentId !== '-1', } } diff --git a/frontend/src/containers/app/sidebars/topology/room/EditRoomContainer.js b/frontend/src/containers/app/sidebars/topology/room/EditRoomContainer.js index 87470bfe..227938fa 100644 --- a/frontend/src/containers/app/sidebars/topology/room/EditRoomContainer.js +++ b/frontend/src/containers/app/sidebars/topology/room/EditRoomContainer.js @@ -4,7 +4,7 @@ import EditRoomComponent from '../../../../../components/app/sidebars/topology/r const mapStateToProps = state => { return { - isEditing: state.construction.currentRoomInConstruction !== -1, + isEditing: state.construction.currentRoomInConstruction !== '-1', isInRackConstructionMode: state.construction.inRackConstructionMode, } } diff --git a/frontend/src/containers/app/sidebars/topology/room/RackConstructionContainer.js b/frontend/src/containers/app/sidebars/topology/room/RackConstructionContainer.js index 30f7a688..17a30d20 100644 --- a/frontend/src/containers/app/sidebars/topology/room/RackConstructionContainer.js +++ b/frontend/src/containers/app/sidebars/topology/room/RackConstructionContainer.js @@ -5,7 +5,7 @@ import RackConstructionComponent from '../../../../../components/app/sidebars/to const mapStateToProps = state => { return { inRackConstructionMode: state.construction.inRackConstructionMode, - isEditingRoom: state.construction.currentRoomInConstruction !== -1, + isEditingRoom: state.construction.currentRoomInConstruction !== '-1', } } diff --git a/frontend/src/containers/app/sidebars/topology/room/RoomSidebarContainer.js b/frontend/src/containers/app/sidebars/topology/room/RoomSidebarContainer.js index 443495de..413c8f21 100644 --- a/frontend/src/containers/app/sidebars/topology/room/RoomSidebarContainer.js +++ b/frontend/src/containers/app/sidebars/topology/room/RoomSidebarContainer.js @@ -3,7 +3,7 @@ import RoomSidebarComponent from '../../../../../components/app/sidebars/topolog const mapStateToProps = state => { return { - inSimulation: state.currentExperimentId !== -1, + inSimulation: state.currentExperimentId !== '-1', roomId: state.interactionLevel.roomId, } } diff --git a/frontend/src/containers/experiments/ExperimentListContainer.js b/frontend/src/containers/experiments/ExperimentListContainer.js index 44fc8620..fc8f203b 100644 --- a/frontend/src/containers/experiments/ExperimentListContainer.js +++ b/frontend/src/containers/experiments/ExperimentListContainer.js @@ -3,7 +3,7 @@ import ExperimentListComponent from '../../components/experiments/ExperimentList const mapStateToProps = state => { if ( - state.currentSimulationId === -1 || + state.currentSimulationId === '-1' || !('experimentIds' in state.objects.simulation[state.currentSimulationId]) ) { return { diff --git a/frontend/src/index.sass b/frontend/src/index.sass index 3e38a322..b37e200c 100644 --- a/frontend/src/index.sass +++ b/frontend/src/index.sass @@ -29,7 +29,7 @@ html, body, #root flex: 0 1 auto padding: 20px 0 -.btn, .list-group-item-action +.btn, .list-group-item-action, .clickable +clickable .btn-circle diff --git a/frontend/src/pages/App.js b/frontend/src/pages/App.js index 3034f7ff..89d1fa32 100644 --- a/frontend/src/pages/App.js +++ b/frontend/src/pages/App.js @@ -92,12 +92,12 @@ class AppComponent extends React.Component { const mapStateToProps = (state) => { let simulationName = undefined - if (state.currentSimulationId !== -1 && state.objects.simulation[state.currentSimulationId]) { + if (state.currentSimulationId !== '-1' && state.objects.simulation[state.currentSimulationId]) { simulationName = state.objects.simulation[state.currentSimulationId].name } return { - topologyIsLoading: state.currentTopologyId === -1, + topologyIsLoading: state.currentTopologyId === '-1', simulationName, } } diff --git a/frontend/src/pages/Experiments.js b/frontend/src/pages/Experiments.js index 97e63f44..43bd15be 100644 --- a/frontend/src/pages/Experiments.js +++ b/frontend/src/pages/Experiments.js @@ -44,7 +44,7 @@ class ExperimentsComponent extends React.Component { const mapStateToProps = (state) => { let simulationName = undefined - if (state.currentSimulationId !== -1 && state.objects.simulation[state.currentSimulationId]) { + if (state.currentSimulationId !== '-1' && state.objects.simulation[state.currentSimulationId]) { simulationName = state.objects.simulation[state.currentSimulationId].name } diff --git a/frontend/src/reducers/construction-mode.js b/frontend/src/reducers/construction-mode.js index 3b500b59..ac281667 100644 --- a/frontend/src/reducers/construction-mode.js +++ b/frontend/src/reducers/construction-mode.js @@ -10,7 +10,7 @@ import { } from '../actions/topology/building' import { DELETE_ROOM, START_RACK_CONSTRUCTION, STOP_RACK_CONSTRUCTION } from '../actions/topology/room' -export function currentRoomInConstruction(state = -1, action) { +export function currentRoomInConstruction(state = '-1', action) { switch (action.type) { case START_NEW_ROOM_CONSTRUCTION_SUCCEEDED: return action.roomId @@ -21,7 +21,7 @@ export function currentRoomInConstruction(state = -1, action) { case OPEN_EXPERIMENT_SUCCEEDED: case FINISH_ROOM_EDIT: case DELETE_ROOM: - return -1 + return '-1' default: return state } diff --git a/frontend/src/reducers/current-ids.js b/frontend/src/reducers/current-ids.js index 76ae67c7..b80d2ecf 100644 --- a/frontend/src/reducers/current-ids.js +++ b/frontend/src/reducers/current-ids.js @@ -2,18 +2,18 @@ import { OPEN_EXPERIMENT_SUCCEEDED } from '../actions/experiments' import { OPEN_SIMULATION_SUCCEEDED } from '../actions/simulations' import { RESET_CURRENT_TOPOLOGY, SET_CURRENT_TOPOLOGY } from '../actions/topology/building' -export function currentTopologyId(state = -1, action) { +export function currentTopologyId(state = '-1', action) { switch (action.type) { case SET_CURRENT_TOPOLOGY: return action.topologyId case RESET_CURRENT_TOPOLOGY: - return -1 + return '-1' default: return state } } -export function currentSimulationId(state = -1, action) { +export function currentSimulationId(state = '-1', action) { switch (action.type) { case OPEN_SIMULATION_SUCCEEDED: return action.id diff --git a/frontend/src/reducers/simulation-mode.js b/frontend/src/reducers/simulation-mode.js index ea15ffa9..5f938ec8 100644 --- a/frontend/src/reducers/simulation-mode.js +++ b/frontend/src/reducers/simulation-mode.js @@ -4,12 +4,12 @@ import { SET_PLAYING } from '../actions/simulation/playback' import { GO_TO_TICK, SET_LAST_SIMULATED_TICK } from '../actions/simulation/tick' import { OPEN_SIMULATION_SUCCEEDED } from '../actions/simulations' -export function currentExperimentId(state = -1, action) { +export function currentExperimentId(state = '-1', action) { switch (action.type) { case OPEN_EXPERIMENT_SUCCEEDED: return action.experimentId case OPEN_SIMULATION_SUCCEEDED: - return -1 + return '-1' default: return state } diff --git a/frontend/src/sagas/experiments.js b/frontend/src/sagas/experiments.js index b9106fdc..e5aeeb46 100644 --- a/frontend/src/sagas/experiments.js +++ b/frontend/src/sagas/experiments.js @@ -32,7 +32,7 @@ export function* onOpenExperimentSucceeded(action) { function* startStateFetchLoop(experimentId) { try { - while ((yield select((state) => state.currentExperimentId)) !== -1) { + while ((yield select((state) => state.currentExperimentId)) !== '-1') { const lastSimulatedTick = (yield call(getExperiment, experimentId)).lastSimulatedTick if (lastSimulatedTick !== (yield select((state) => state.lastSimulatedTick))) { yield put(setLastSimulatedTick(lastSimulatedTick)) @@ -90,7 +90,7 @@ export function* onAddExperiment(action) { addExperiment, currentSimulationId, Object.assign({}, action.experiment, { - id: -1, + id: '-1', simulationId: currentSimulationId, }) ) diff --git a/frontend/src/store/middlewares/viewport-adjustment.js b/frontend/src/store/middlewares/viewport-adjustment.js index ae8f032a..84f2a3e9 100644 --- a/frontend/src/store/middlewares/viewport-adjustment.js +++ b/frontend/src/store/middlewares/viewport-adjustment.js @@ -12,20 +12,20 @@ import { calculateRoomListBounds } from '../../util/tile-calculations' export const viewportAdjustmentMiddleware = store => next => action => { const state = store.getState() - let topologyId = -1 + let topologyId = '-1' let mapDimensions = {} - if (action.type === SET_CURRENT_TOPOLOGY && action.topologyId !== -1) { + if (action.type === SET_CURRENT_TOPOLOGY && action.topologyId !== '-1') { topologyId = action.topologyId mapDimensions = state.map.dimensions } else if ( action.type === SET_MAP_DIMENSIONS && - state.currentTopologyId !== -1 + state.currentTopologyId !== '-1' ) { topologyId = state.currentTopologyId mapDimensions = { width: action.width, height: action.height } } - if (topologyId !== -1) { + if (topologyId !== '-1') { const roomIds = state.objects.topology[topologyId].roomIds const rooms = roomIds.map(id => Object.assign({}, state.objects.room[id])) rooms.forEach( diff --git a/frontend/src/style-globals/_mixins.sass b/frontend/src/style-globals/_mixins.sass index 03eaec8a..d0a8d1ac 100644 --- a/frontend/src/style-globals/_mixins.sass +++ b/frontend/src/style-globals/_mixins.sass @@ -19,6 +19,3 @@ =clickable cursor: pointer +user-select - -.clickable - +clickable |
