summaryrefslogtreecommitdiff
path: root/opendc-web/opendc-web-ui/src/containers/app/sidebars/project/TopologyListContainer.js
diff options
context:
space:
mode:
authorFabian Mastenbroek <mail.fabianm@gmail.com>2021-07-08 13:36:39 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2021-07-08 13:36:39 +0200
commit2c8d675c2cf140eac05988065a9d20fd2773399a (patch)
tree1bed18bb62d223be954faca87b0736d2a571b443 /opendc-web/opendc-web-ui/src/containers/app/sidebars/project/TopologyListContainer.js
parent29196842447d841d2e21462adcfc8c2ed1d851ad (diff)
ui: Combine fetching of project relations
This change updates the OpenDC frontend to combine the fetching of project relations. This means that for a single project, we make only one additional request to retrieve all its topologies.
Diffstat (limited to 'opendc-web/opendc-web-ui/src/containers/app/sidebars/project/TopologyListContainer.js')
-rw-r--r--opendc-web/opendc-web-ui/src/containers/app/sidebars/project/TopologyListContainer.js10
1 files changed, 4 insertions, 6 deletions
diff --git a/opendc-web/opendc-web-ui/src/containers/app/sidebars/project/TopologyListContainer.js b/opendc-web/opendc-web-ui/src/containers/app/sidebars/project/TopologyListContainer.js
index 55eab23a..a2244a30 100644
--- a/opendc-web/opendc-web-ui/src/containers/app/sidebars/project/TopologyListContainer.js
+++ b/opendc-web/opendc-web-ui/src/containers/app/sidebars/project/TopologyListContainer.js
@@ -5,18 +5,16 @@ import { setCurrentTopology } from '../../../../redux/actions/topology/building'
import { useRouter } from 'next/router'
import { addTopology } from '../../../../redux/actions/topologies'
import NewTopologyModalComponent from '../../../../components/modals/custom-components/NewTopologyModalComponent'
-import { useActiveTopology, useTopologies } from '../../../../data/topology'
-import { useProject } from '../../../../data/project'
+import { useActiveTopology, useProjectTopologies } from '../../../../data/topology'
import { useMutation } from 'react-query'
const TopologyListContainer = () => {
const dispatch = useDispatch()
const router = useRouter()
const { project: currentProjectId } = router.query
- const { data: currentProject } = useProject(currentProjectId)
- const topologies = useTopologies(currentProject?.topologyIds ?? [])
- .filter((res) => res.data)
- .map((res) => ({ _id: res.data._id, name: res.data.name }))
+ const topologies =
+ useProjectTopologies(currentProjectId).data?.map((topology) => ({ _id: topology._id, name: topology.name })) ??
+ []
const currentTopologyId = useActiveTopology()?._id
const [isVisible, setVisible] = useState(false)