fix: do not try to route to org onboarding when workspace locked or suspended (#6692)

This commit is contained in:
Vikrant Gupta 2024-12-20 22:28:53 +05:30 committed by GitHub
parent 2c2e248c95
commit bef6cc945a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 2 deletions

View File

@ -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);
}
}

View File

@ -443,6 +443,11 @@ export const oldNewRoutesMapping: Record<string, string> = {
'/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'];

View File

@ -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,
});