Skip to content

Commit

Permalink
Merge branch 'master' into debug_events
Browse files Browse the repository at this point in the history
  • Loading branch information
fuziontech authored Jul 2, 2024
2 parents 7e39d8f + 5c11390 commit 41af274
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions frontend/src/layout/navigation/ProjectSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { upgradeModalLogic } from 'lib/components/UpgradeModal/upgradeModalLogic
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonDivider } from 'lib/lemon-ui/LemonDivider'
import { LemonSnack } from 'lib/lemon-ui/LemonSnack/LemonSnack'
import { removeProjectIdIfPresent } from 'lib/utils/router-utils'
import { removeFlagIdIfPresent, removeProjectIdIfPresent } from 'lib/utils/router-utils'
import { useMemo } from 'react'
import { organizationLogic } from 'scenes/organizationLogic'
import { isAuthenticatedTeam, teamLogic } from 'scenes/teamLogic'
Expand Down Expand Up @@ -91,7 +91,8 @@ function OtherProjectButton({ team }: { team: TeamBasicType; onClickInside?: ()
// project switch lands on something like insight/abc that won't exist.
// On the other hand, if we remove the ID, it could be that someone opens a page, realizes they're in the wrong project
// and after switching is on a different page than before.
const route = removeProjectIdIfPresent(location.pathname)
let route = removeProjectIdIfPresent(location.pathname)
route = removeFlagIdIfPresent(route)
return urls.project(team.id, route)
}, [location.pathname])

Expand Down
7 changes: 7 additions & 0 deletions frontend/src/lib/utils/router-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ export function removeProjectIdIfPresent(path: string): string {
return path
}

export function removeFlagIdIfPresent(path: string): string {
if (path.match(/^\/feature_flags\/\d+/)) {
return path.replace(/(feature_flags).*$/, '$1/')
}
return path
}

export function addProjectIdIfMissing(path: string, teamId?: TeamType['id']): string {
return isPathWithoutProjectId(removeProjectIdIfPresent(path))
? removeProjectIdIfPresent(path)
Expand Down

0 comments on commit 41af274

Please sign in to comment.