Skip to content

Commit

Permalink
fix(insights): Fix set active view when changing insight (#21034)
Browse files Browse the repository at this point in the history
  • Loading branch information
webjunkie authored Mar 20, 2024
1 parent f5ec54d commit 0c5b8cb
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion frontend/src/scenes/insights/InsightNav/insightNavLogic.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { actions, afterMount, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'
import { urlToAction } from 'kea-router'
import { FEATURE_FLAGS } from 'lib/constants'
import { LemonTag } from 'lib/lemon-ui/LemonTag/LemonTag'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
Expand Down Expand Up @@ -41,7 +42,7 @@ import {
isStickinessQuery,
isTrendsQuery,
} from '~/queries/utils'
import { BaseMathType, InsightLogicProps, InsightType } from '~/types'
import { BaseMathType, FilterType, InsightLogicProps, InsightType } from '~/types'

import { MathAvailability } from '../filters/ActionFilter/ActionFilterRow/ActionFilterRow'
import type { insightNavLogicType } from './insightNavLogicType'
Expand Down Expand Up @@ -278,6 +279,23 @@ export const insightNavLogic = kea<insightNavLogicType>([
}
},
})),
urlToAction(({ actions }) => ({
'/insights/:shortId(/:mode)(/:subscriptionId)': (
_, // url params
{ dashboard, ...searchParams }, // search params
{ filters: _filters } // hash params
) => {
// capture any filters from the URL, either #filters={} or ?insight=X&bla=foo&bar=baz
const filters: Partial<FilterType> | null =
Object.keys(_filters || {}).length > 0 ? _filters : searchParams.insight ? searchParams : null

if (!filters?.insight) {
return
}

actions.setActiveView(filters?.insight)
},
})),
afterMount(({ values, actions }) => {
if (values.query && isInsightVizNode(values.query)) {
actions.updateQueryPropertyCache(cachePropertiesFromQuery(values.query.source, values.queryPropertyCache))
Expand Down

0 comments on commit 0c5b8cb

Please sign in to comment.