Skip to content

Commit

Permalink
feat: convert to insight (#19909)
Browse files Browse the repository at this point in the history
  • Loading branch information
daibhin authored Jan 25, 2024
1 parent 51bae9d commit f2a81b7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions frontend/src/scenes/notebooks/Nodes/NotebookNodeQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useActions, useMountedLogic, useValues } from 'kea'
import { useEffect, useMemo } from 'react'
import { notebookNodeLogic } from './notebookNodeLogic'
import { NotebookNodeProps, NotebookNodeAttributeProperties } from '../Notebook/utils'
import { containsHogQLQuery, isHogQLQuery, isNodeWithSource } from '~/queries/utils'
import { containsHogQLQuery, isHogQLQuery, isInsightVizNode, isNodeWithSource } from '~/queries/utils'
import { LemonButton } from '@posthog/lemon-ui'
import clsx from 'clsx'
import { urls } from 'scenes/urls'
Expand Down Expand Up @@ -226,7 +226,11 @@ export const NotebookNodeQuery = createPostHogWidgetNode<NotebookNodeQueryAttrib
},
},
href: (attrs) =>
attrs.query.kind === NodeKind.SavedInsightNode ? urls.insightView(attrs.query.shortId) : undefined,
attrs.query.kind === NodeKind.SavedInsightNode
? urls.insightView(attrs.query.shortId)
: isInsightVizNode(attrs.query)
? urls.insightNew(undefined, undefined, attrs.query)
: undefined,
Settings,
pasteOptions: {
find: urls.insightView('(.+)' as InsightShortId),
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/scenes/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,14 @@ export const urls = {
batchExportEdit: (id: string): string => `/batch_exports/${id}/edit`,
ingestionWarnings: (): string => '/data-management/ingestion-warnings',
insights: (): string => '/insights',
insightNew: (filters?: AnyPartialFilterType, dashboardId?: DashboardType['id'] | null, query?: string): string =>
insightNew: (
filters?: AnyPartialFilterType,
dashboardId?: DashboardType['id'] | null,
query?: string | Record<string, any>
): string =>
combineUrl('/insights/new', dashboardId ? { dashboard: dashboardId } : {}, {
...(filters ? { filters } : {}),
...(query ? { q: query } : {}),
...(query ? { q: typeof query === 'string' ? query : JSON.stringify(query) } : {}),
}).url,
insightNewHogQL: (query: string): string =>
urls.insightNew(
Expand Down

0 comments on commit f2a81b7

Please sign in to comment.