diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2021-07-22 14:57:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-07-22 14:57:21 +0200 |
| commit | b0c5681b28d1c3c87b7d24d8b8d166f5566e7699 (patch) | |
| tree | 4f7269996928ea480499e3cbe912b15ba994e43f /opendc-web/opendc-web-ui/src/pages/projects | |
| parent | 51c759e74b088d405b63fdb3e374822308d21366 (diff) | |
| parent | 7f083b47c2e2333819823fd7835332a0f486b626 (diff) | |
merge: Address technical debt in topology view v2 (#163)
This pull request aims to address some of the technical debt in the topology
view of the OpenDC frontend (v2).
* Perform Saga mutations through React Query
* Add table view for topology view
* Extract topology construction out of Sagas
* Toggle to Floor Plan on room select
Diffstat (limited to 'opendc-web/opendc-web-ui/src/pages/projects')
| -rw-r--r-- | opendc-web/opendc-web-ui/src/pages/projects/[project]/topologies/[topology].js | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/opendc-web/opendc-web-ui/src/pages/projects/[project]/topologies/[topology].js b/opendc-web/opendc-web-ui/src/pages/projects/[project]/topologies/[topology].js index f95b18ed..ae26ae83 100644 --- a/opendc-web/opendc-web-ui/src/pages/projects/[project]/topologies/[topology].js +++ b/opendc-web/opendc-web-ui/src/pages/projects/[project]/topologies/[topology].js @@ -24,9 +24,8 @@ import { useRouter } from 'next/router' import TopologyOverview from '../../../../components/topologies/TopologyOverview' import { useProject } from '../../../../data/project' import { useDispatch } from 'react-redux' -import React, { useEffect, useRef, useState } from 'react' +import React, { useEffect, useState } from 'react' import Head from 'next/head' -import { openProjectSucceeded } from '../../../../redux/actions/projects' import { AppPage } from '../../../../components/AppPage' import { Breadcrumb, @@ -43,6 +42,8 @@ import { } from '@patternfly/react-core' import BreadcrumbLink from '../../../../components/util/BreadcrumbLink' import TopologyMap from '../../../../components/topologies/TopologyMap' +import { goToRoom } from '../../../../redux/actions/interaction-level' +import { openTopology } from '../../../../redux/actions/topologies' /** * Page that displays a datacenter topology. @@ -55,14 +56,12 @@ function Topology() { const dispatch = useDispatch() useEffect(() => { - if (projectId) { - dispatch(openProjectSucceeded(projectId)) + if (topologyId) { + dispatch(openTopology(topologyId)) } - }, [projectId, topologyId, dispatch]) + }, [topologyId, dispatch]) const [activeTab, setActiveTab] = useState('overview') - const overviewRef = useRef(null) - const floorPlanRef = useRef(null) const breadcrumb = ( <Breadcrumb> @@ -95,31 +94,31 @@ function Topology() { onSelect={(_, tabIndex) => setActiveTab(tabIndex)} className="pf-m-page-insets" > - <Tab - eventKey="overview" - title={<TabTitleText>Overview</TabTitleText>} - tabContentId="overview" - tabContentRef={overviewRef} - /> + <Tab eventKey="overview" title={<TabTitleText>Overview</TabTitleText>} tabContentId="overview" /> <Tab eventKey="floor-plan" title={<TabTitleText>Floor Plan</TabTitleText>} tabContentId="floor-plan" - tabContentRef={floorPlanRef} /> </Tabs> </PageSection> <PageSection padding={activeTab === 'floor-plan' && { default: 'noPadding' }} isFilled> - <TabContent eventKey="overview" id="overview" ref={overviewRef} aria-label="Overview tab"> - <TopologyOverview topologyId={topologyId} /> + <TabContent id="overview" aria-label="Overview tab" hidden={activeTab !== 'overview'}> + <TopologyOverview + topologyId={topologyId} + onSelect={(type, obj) => { + if (type === 'room') { + dispatch(goToRoom(obj._id)) + setActiveTab('floor-plan') + } + }} + /> </TabContent> <TabContent - eventKey="floor-plan" id="floor-plan" - ref={floorPlanRef} aria-label="Floor Plan tab" className="pf-u-h-100" - hidden + hidden={activeTab !== 'floor-plan'} > <TopologyMap /> </TabContent> |
