Skip to content

Commit

Permalink
fix(onboarding): fix path of ProjectSwitcher when project not onboard…
Browse files Browse the repository at this point in the history
…ed (#25660)

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
patricio-posthog and github-actions[bot] authored Oct 17, 2024
1 parent 683d552 commit 40e69dd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions frontend/src/layout/navigation/ProjectSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ function OtherProjectButton({ team }: { team: TeamBasicType; onClickInside?: ()
// and after switching is on a different page than before.
let route = removeProjectIdIfPresent(location.pathname)
route = removeFlagIdIfPresent(route)

// List of routes that should redirect to project home
// instead of keeping the current path.
const redirectToHomeRoutes = ['/products', '/onboarding']

const shouldRedirectToHome = redirectToHomeRoutes.some((redirectRoute) => route.includes(redirectRoute))

if (shouldRedirectToHome) {
return urls.project(team.id) // Go to project home
}

return urls.project(team.id, route)
}, [location.pathname])

Expand Down

0 comments on commit 40e69dd

Please sign in to comment.