From 54720452b10b499ef79017f026d9244a04502aa5 Mon Sep 17 00:00:00 2001 From: ek-hystax <33006768+ek-hystax@users.noreply.github.com> Date: Mon, 13 Jan 2025 14:51:18 +0400 Subject: [PATCH] OSN-549. Refactor PoolLink component to fix navigation - Simplified the getUrl function by removing the organizationId parameter. - Updated the onClick handler in PoolLink to navigate directly if organizationId is not provided, or update the scope with organizationId and redirect URL if it is. --- .../ui/src/components/PoolLabel/PoolLabel.tsx | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ngui/ui/src/components/PoolLabel/PoolLabel.tsx b/ngui/ui/src/components/PoolLabel/PoolLabel.tsx index 71262b36..1771edf4 100644 --- a/ngui/ui/src/components/PoolLabel/PoolLabel.tsx +++ b/ngui/ui/src/components/PoolLabel/PoolLabel.tsx @@ -1,34 +1,40 @@ import Link from "@mui/material/Link"; import { FormattedMessage } from "react-intl"; +import { useNavigate } from "react-router-dom"; import IconLabel from "components/IconLabel"; import PoolTypeIcon from "components/PoolTypeIcon"; import SlicedText from "components/SlicedText"; import { useUpdateScope } from "hooks/useUpdateScope"; import { getPoolUrl, isPoolIdWithSubPools } from "urls"; -import { formQueryString } from "utils/network"; const SLICED_POOL_NAME_LENGTH = 35; -const getUrl = (poolId: string, organizationId: string) => { +const getUrl = (poolId: string) => { // TODO: remove this after https://datatrendstech.atlassian.net/browse/OS-4157 const poolIdWithoutSubPoolMark = isPoolIdWithSubPools(poolId) ? poolId.slice(0, poolId.length - 1) : poolId; - const baseUrl = getPoolUrl(poolIdWithoutSubPoolMark); - return organizationId ? `${baseUrl}&${formQueryString({ organizationId })}` : baseUrl; + + return getPoolUrl(poolIdWithoutSubPoolMark); }; const SlicedPoolName = ({ name }) => ; const PoolLink = ({ id, name, dataTestId, organizationId }) => { const updateScope = useUpdateScope(); + const navigate = useNavigate(); return ( { - updateScope({ - newScopeId: organizationId, - redirectTo: getUrl(id, organizationId) - }); + const url = getUrl(id); + if (organizationId) { + updateScope({ + newScopeId: organizationId, + redirectTo: url + }); + } else { + navigate(url); + } }} data-test-id={dataTestId} >