Skip to content

Commit

Permalink
fix: do not try to route to org onboarding when workspace locked or s…
Browse files Browse the repository at this point in the history
…uspended (#6692)
  • Loading branch information
vikrantgupta25 authored Dec 20, 2024
1 parent 2c2e248 commit bef6cc9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion frontend/src/AppRoutes/Private.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import routes, {
LIST_LICENSES,
oldNewRoutesMapping,
oldRoutes,
ROUTES_NOT_TO_BE_OVERRIDEN,
SUPPORT_ROUTE,
} from './routes';

Expand Down Expand Up @@ -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);
}
}
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/AppRoutes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/providers/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down

0 comments on commit bef6cc9

Please sign in to comment.