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/machine/DeleteMachine.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/machine/DeleteMachine.js')
| -rw-r--r-- | opendc-web/opendc-web-ui/src/components/app/sidebars/topology/machine/DeleteMachine.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/opendc-web/opendc-web-ui/src/components/app/sidebars/topology/machine/DeleteMachine.js b/opendc-web/opendc-web-ui/src/components/app/sidebars/topology/machine/DeleteMachine.js index a7bf3719..75d458b6 100644 --- a/opendc-web/opendc-web-ui/src/components/app/sidebars/topology/machine/DeleteMachine.js +++ b/opendc-web/opendc-web-ui/src/components/app/sidebars/topology/machine/DeleteMachine.js @@ -21,18 +21,20 @@ */ import React, { useState } from 'react' -import { useDispatch } from 'react-redux' +import { useDispatch, useSelector } from 'react-redux' import { deleteMachine } from '../../../../../redux/actions/topology/machine' import { Button } from '@patternfly/react-core' import TrashIcon from '@patternfly/react-icons/dist/js/icons/trash-icon' import ConfirmationModal from '../../../../modals/ConfirmationModal' -const DeleteMachine = () => { +function DeleteMachine() { const dispatch = useDispatch() const [isVisible, setVisible] = useState(false) + const rackId = useSelector((state) => state.objects.tile[state.interactionLevel.tileId].rack) + const position = useSelector((state) => state.interactionLevel.position) const callback = (isConfirmed) => { if (isConfirmed) { - dispatch(deleteMachine()) + dispatch(deleteMachine(rackId, position)) } setVisible(false) } |
