From aa788a3ad18badfac8beaabdaffc88b9e52f9306 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Wed, 7 Jul 2021 15:07:11 +0200 Subject: ui: Remove current ids state from Redux This change removes the current active identifiers from the Redux state. Instead, we use the router query to track the active project, portfolio and topology. --- opendc-web/opendc-web-ui/src/data/topology.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'opendc-web/opendc-web-ui/src/data/topology.js') diff --git a/opendc-web/opendc-web-ui/src/data/topology.js b/opendc-web/opendc-web-ui/src/data/topology.js index d3ffb3e1..f6ce1672 100644 --- a/opendc-web/opendc-web-ui/src/data/topology.js +++ b/opendc-web/opendc-web-ui/src/data/topology.js @@ -21,6 +21,7 @@ */ import { useSelector } from 'react-redux' +import { useRouter } from 'next/router' /** * Return the current active topology. @@ -33,8 +34,10 @@ export function useActiveTopology() { * Return the topologies for the active project. */ export function useProjectTopologies() { - return useSelector(({ currentProjectId, objects }) => { - if (currentProjectId === '-1' || !objects.project[currentProjectId]) { + const router = useRouter() + const { project: currentProjectId } = router.query + return useSelector(({ objects }) => { + if (!currentProjectId || !objects.project[currentProjectId]) { return [] } -- cgit v1.2.3