From bef6cc945a2d0976e5c60643917f25921a1fa75c Mon Sep 17 00:00:00 2001 From: Vikrant Gupta Date: Fri, 20 Dec 2024 22:28:53 +0530 Subject: [PATCH] fix: do not try to route to org onboarding when workspace locked or suspended (#6692) --- frontend/src/AppRoutes/Private.tsx | 8 +++++++- frontend/src/AppRoutes/routes.ts | 5 +++++ frontend/src/providers/App/App.tsx | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/frontend/src/AppRoutes/Private.tsx b/frontend/src/AppRoutes/Private.tsx index c689786fcc..35c4f11e20 100644 --- a/frontend/src/AppRoutes/Private.tsx +++ b/frontend/src/AppRoutes/Private.tsx @@ -18,6 +18,7 @@ import routes, { LIST_LICENSES, oldNewRoutesMapping, oldRoutes, + ROUTES_NOT_TO_BE_OVERRIDEN, SUPPORT_ROUTE, } from './routes'; @@ -90,7 +91,12 @@ function PrivateRoute({ children }: PrivateRouteProps): JSX.Element { )?.value; const isFirstUser = checkFirstTimeUser(); - if (isFirstUser && !isOnboardingComplete) { + if ( + isFirstUser && + !isOnboardingComplete && + // if the current route is allowed to be overriden by org onboarding then only do the same + !ROUTES_NOT_TO_BE_OVERRIDEN.includes(pathname) + ) { history.push(ROUTES.ONBOARDING); } } diff --git a/frontend/src/AppRoutes/routes.ts b/frontend/src/AppRoutes/routes.ts index f1490ec74e..1291e32cb1 100644 --- a/frontend/src/AppRoutes/routes.ts +++ b/frontend/src/AppRoutes/routes.ts @@ -443,6 +443,11 @@ export const oldNewRoutesMapping: Record = { '/settings/access-tokens': '/settings/api-keys', }; +export const ROUTES_NOT_TO_BE_OVERRIDEN: string[] = [ + ROUTES.WORKSPACE_LOCKED, + ROUTES.WORKSPACE_SUSPENDED, +]; + export interface AppRoutes { component: RouteProps['component']; path: RouteProps['path']; diff --git a/frontend/src/providers/App/App.tsx b/frontend/src/providers/App/App.tsx index 36a9817e68..0451ffbb58 100644 --- a/frontend/src/providers/App/App.tsx +++ b/frontend/src/providers/App/App.tsx @@ -144,7 +144,7 @@ export function AppProvider({ children }: PropsWithChildren): JSX.Element { error: orgPreferencesFetchError, } = useQuery({ queryFn: () => getAllOrgPreferences(), - queryKey: ['getOrgPreferences'], + queryKey: ['getOrgPreferences', 'app-context'], enabled: !!isLoggedIn && !!user.email && user.role === USER_ROLES.ADMIN, });