Skip to content

Commit

Permalink
copy url change in from #14709 to fix new insight dropdown in this PR
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Mar 13, 2023
1 parent c5ff1de commit 2ec97bd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 4 additions & 3 deletions frontend/src/scenes/insights/insightSceneLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const insightSceneLogic = kea<insightSceneLogicType>([
'/insights/:shortId(/:mode)(/:subscriptionId)': (
{ shortId, mode, subscriptionId }, // url params
{ dashboard, ...searchParams }, // search params
{ filters: _filters }, // hash params
{ filters: _filters, q }, // hash params
{ method, initial } // "location changed" event payload
) => {
const insightMode =
Expand Down Expand Up @@ -147,7 +147,7 @@ export const insightSceneLogic = kea<insightSceneLogicType>([
Object.keys(_filters || {}).length > 0 ? _filters : searchParams.insight ? searchParams : null

// Redirect to a simple URL if we had filters in the URL
if (filters) {
if (filters || q) {
router.actions.replace(
insightId === 'new'
? urls.insightNew(undefined, dashboard)
Expand All @@ -158,7 +158,7 @@ export const insightSceneLogic = kea<insightSceneLogicType>([
}

// reset the insight's state if we have to
if (initial || method === 'PUSH' || filters) {
if (initial || method === 'PUSH' || filters || q) {
if (insightId === 'new') {
values.insightCache?.logic.actions.setInsight(
{
Expand All @@ -168,6 +168,7 @@ export const insightSceneLogic = kea<insightSceneLogicType>([
),
...(filters ? { filters: cleanFilters(filters || {}) } : {}),
...(dashboard ? { dashboards: [dashboard] } : {}),
...(q ? { query: JSON.parse(q) } : {}),
},
{
fromPersistentApi: false,
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/scenes/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@ export const urls = {
propertyDefinition: (id: string | number): string => `/data-management/properties/${id}`,
events: (): string => '/events',
ingestionWarnings: (): string => '/data-management/ingestion-warnings',
insightNew: (filters?: AnyPartialFilterType, dashboardId?: DashboardType['id'] | null): string =>
combineUrl('/insights/new', dashboardId ? { dashboard: dashboardId } : {}, filters ? { filters } : {}).url,
insightNew: (filters?: AnyPartialFilterType, dashboardId?: DashboardType['id'] | null, query?: string): string =>
combineUrl('/insights/new', dashboardId ? { dashboard: dashboardId } : {}, {
...(filters ? { filters } : {}),
...(query ? { q: query } : {}),
}).url,
insightEdit: (id: InsightShortId): string => `/insights/${id}/edit`,
insightView: (id: InsightShortId): string => `/insights/${id}`,
insightSubcriptions: (id: InsightShortId): string => `/insights/${id}/subscriptions`,
Expand Down

0 comments on commit 2ec97bd

Please sign in to comment.