From d1b64016f3019aa1361f9a6dd614df20769d5f95 Mon Sep 17 00:00:00 2001 From: vivek-harness Date: Tue, 28 Jan 2025 13:17:45 +0530 Subject: [PATCH] Breadcrumb api call fix (#848) * Fixed failing api call for repos in MFE * Changed retry limit to 5 instead of the default 3 * Renamed function * Changed variable name * Changed location to location.pathname in dependency array --- apps/gitness/src/AppMFE.tsx | 15 +++++++-------- apps/gitness/src/pages-v2/repo/repo-list.tsx | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/apps/gitness/src/AppMFE.tsx b/apps/gitness/src/AppMFE.tsx index 3fcecfd92b..b72f85e50a 100644 --- a/apps/gitness/src/AppMFE.tsx +++ b/apps/gitness/src/AppMFE.tsx @@ -27,16 +27,16 @@ export interface MFERouteRendererProps { onRouteChange: (updatedLocationPathname: string) => void } -const filteredRoutes = extractRedirectRouteObjects(repoRoutes) -const isRouteMatchingRedirectRoutes = (pathToValidate: string) => { - return filteredRoutes.some(route => matchPath(`/${route.path}` as string, pathToValidate)) +const filteredRedirectRoutes = extractRedirectRouteObjects(repoRoutes) +const isRouteNotMatchingRedirectRoutes = (pathToValidate: string) => { + return filteredRedirectRoutes.every(route => !matchPath(`/${route.path}` as string, pathToValidate)) } function MFERouteRenderer({ renderUrl, parentLocationPath, onRouteChange }: MFERouteRendererProps) { const navigate = useNavigate() const location = useLocation() const parentPath = parentLocationPath.replace(renderUrl, '') - const isNotRedirectPath = isRouteMatchingRedirectRoutes(location.pathname) + const isNotRedirectPath = isRouteNotMatchingRedirectRoutes(location.pathname) /** * renderUrl ==> base URL of parent application @@ -52,17 +52,16 @@ function MFERouteRenderer({ renderUrl, parentLocationPath, onRouteChange }: MFER // Handle location change detected from parent route useEffect(() => { if (canNavigate) { - const pathToNavigate = parentLocationPath.replace(renderUrl, '') - navigate(pathToNavigate, { replace: true }) + navigate(parentPath, { replace: true }) } - }, [parentLocationPath]) + }, [parentPath]) // Notify parent about route change useEffect(() => { if (canNavigate) { onRouteChange?.(`${renderUrl}${location.pathname}`) } - }, [location]) + }, [location.pathname]) return null } diff --git a/apps/gitness/src/pages-v2/repo/repo-list.tsx b/apps/gitness/src/pages-v2/repo/repo-list.tsx index 8927208d19..a94ff3e162 100644 --- a/apps/gitness/src/pages-v2/repo/repo-list.tsx +++ b/apps/gitness/src/pages-v2/repo/repo-list.tsx @@ -39,7 +39,7 @@ export default function ReposListPage() { space_ref: `${spaceURL}/+` }, { - retry: false + retry: 5 } )