From 54d07120191eb81de91a49cdebf619cfecce2666 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Mon, 19 Jul 2021 14:45:25 +0200 Subject: 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. --- .../sidebars/topology/machine/UnitTabsComponent.js | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'opendc-web/opendc-web-ui/src/components/app/sidebars/topology/machine/UnitTabsComponent.js') diff --git a/opendc-web/opendc-web-ui/src/components/app/sidebars/topology/machine/UnitTabsComponent.js b/opendc-web/opendc-web-ui/src/components/app/sidebars/topology/machine/UnitTabsComponent.js index 723ed2e2..6d10d2df 100644 --- a/opendc-web/opendc-web-ui/src/components/app/sidebars/topology/machine/UnitTabsComponent.js +++ b/opendc-web/opendc-web-ui/src/components/app/sidebars/topology/machine/UnitTabsComponent.js @@ -1,31 +1,36 @@ +import PropTypes from 'prop-types' import React, { useState } from 'react' import { Tab, Tabs, TabTitleText } from '@patternfly/react-core' import UnitAddContainer from './UnitAddContainer' import UnitListContainer from './UnitListContainer' -const UnitTabsComponent = () => { +function UnitTabsComponent({ machineId }) { const [activeTab, setActiveTab] = useState('cpu-units') return ( setActiveTab(tab)}> CPU}> - - + + GPU}> - - + + Memory}> - - + + Storage}> - - + + ) } +UnitTabsComponent.propTypes = { + machineId: PropTypes.string.isRequired, +} + export default UnitTabsComponent -- cgit v1.2.3