From 093664757f3ce9d805ec6b5b0e4fbf1c3b8233dc Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Fri, 20 Mar 2026 11:27:09 +0800 Subject: [PATCH] tweaks --- web/app/(commonLayout)/role-route-guard.tsx | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/web/app/(commonLayout)/role-route-guard.tsx b/web/app/(commonLayout)/role-route-guard.tsx index 4b6acb3569..c89611b6b7 100644 --- a/web/app/(commonLayout)/role-route-guard.tsx +++ b/web/app/(commonLayout)/role-route-guard.tsx @@ -1,9 +1,8 @@ 'use client' import type { ReactNode } from 'react' -import { useEffect } from 'react' import { useAppContext } from '@/context/app-context' -import { usePathname, useRouter } from '@/next/navigation' +import { redirect, usePathname } from '@/next/navigation' const datasetOperatorRedirectRoutes = ['/apps', '/app', '/explore', '/tools'] as const @@ -12,20 +11,14 @@ const isPathUnderRoute = (pathname: string, route: string) => pathname === route export default function RoleRouteGuard({ children }: { children: ReactNode }) { const { isCurrentWorkspaceDatasetOperator, isLoadingCurrentWorkspace } = useAppContext() const pathname = usePathname() - const router = useRouter() const shouldGuardRoute = datasetOperatorRedirectRoutes.some(route => isPathUnderRoute(pathname, route)) const shouldRedirect = shouldGuardRoute && !isLoadingCurrentWorkspace && isCurrentWorkspaceDatasetOperator - useEffect(() => { - if (shouldRedirect) - router.replace('/datasets') - }, [shouldRedirect, router]) - if (shouldGuardRoute && isLoadingCurrentWorkspace) return null if (shouldRedirect) - return null + return redirect('/datasets') return <>{children} }