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 From 5e5ab63b280eb446db4090733cd3ad2e97d02018 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Mon, 19 Jul 2021 15:47:23 +0200 Subject: refactor(ui): Restructure components per page This change updates the source structure of the OpenDC frontend to follow the page structure. --- .../sidebars/topology/machine/UnitTabsComponent.js | 36 ---------------------- 1 file changed, 36 deletions(-) delete mode 100644 opendc-web/opendc-web-ui/src/components/app/sidebars/topology/machine/UnitTabsComponent.js (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 deleted file mode 100644 index 6d10d2df..00000000 --- a/opendc-web/opendc-web-ui/src/components/app/sidebars/topology/machine/UnitTabsComponent.js +++ /dev/null @@ -1,36 +0,0 @@ -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' - -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