diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-07-19 14:45:25 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-07-19 15:13:21 +0200 |
| commit | 54d07120191eb81de91a49cdebf619cfecce2666 (patch) | |
| tree | e85c5d9eeb638458a6c3abc4de0660ac1a1ff772 /opendc-web/opendc-web-ui/src/components/app/sidebars/topology/TopologySidebar.js | |
| parent | dc65123da856a09fe346ccd851cb4b78ad07ce5c (diff) | |
refactor(ui): Encode state in topology actions
This change updates the OpenDC frontend to reduce its reliance of global
state during the execution of actions. Actions that modify the topology
now require parameters to be passed via the action constructor instead
of relying on the global interactionLevel state.
Diffstat (limited to 'opendc-web/opendc-web-ui/src/components/app/sidebars/topology/TopologySidebar.js')
| -rw-r--r-- | opendc-web/opendc-web-ui/src/components/app/sidebars/topology/TopologySidebar.js | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/opendc-web/opendc-web-ui/src/components/app/sidebars/topology/TopologySidebar.js b/opendc-web/opendc-web-ui/src/components/app/sidebars/topology/TopologySidebar.js index c4a880b1..564f4030 100644 --- a/opendc-web/opendc-web-ui/src/components/app/sidebars/topology/TopologySidebar.js +++ b/opendc-web/opendc-web-ui/src/components/app/sidebars/topology/TopologySidebar.js @@ -1,7 +1,7 @@ import PropTypes from 'prop-types' import React from 'react' import { InteractionLevel } from '../../../../shapes' -import BuildingSidebarComponent from './building/BuildingSidebarComponent' +import BuildingSidebar from './building/BuildingSidebar' import { Button, DrawerActions, @@ -16,9 +16,9 @@ import { AngleLeftIcon } from '@patternfly/react-icons' import { useDispatch } from 'react-redux' import { goDownOneInteractionLevel } from '../../../../redux/actions/interaction-level' import { backButton } from './TopologySidebar.module.scss' -import RoomSidebarContainer from './room/RoomSidebarContainer' -import RackSidebarContainer from './rack/RackSidebarContainer' -import MachineSidebarContainer from './machine/MachineSidebarContainer' +import RoomSidebar from './room/RoomSidebar' +import RackSidebar from './rack/RackSidebar' +import MachineSidebar from './machine/MachineSidebar' const name = { BUILDING: 'Building', @@ -27,21 +27,21 @@ const name = { MACHINE: 'Machine', } -const TopologySidebar = ({ interactionLevel, onClose }) => { +function TopologySidebar({ interactionLevel, onClose }) { let sidebarContent switch (interactionLevel.mode) { case 'BUILDING': - sidebarContent = <BuildingSidebarComponent /> + sidebarContent = <BuildingSidebar /> break case 'ROOM': - sidebarContent = <RoomSidebarContainer /> + sidebarContent = <RoomSidebar roomId={interactionLevel.roomId} /> break case 'RACK': - sidebarContent = <RackSidebarContainer /> + sidebarContent = <RackSidebar tileId={interactionLevel.tileId} /> break case 'MACHINE': - sidebarContent = <MachineSidebarContainer /> + sidebarContent = <MachineSidebar tileId={interactionLevel.tileId} position={interactionLevel.position} /> break default: sidebarContent = 'Missing Content' |
