From f2a81b793ace678e25a5d8f136d3e5da38a5e918 Mon Sep 17 00:00:00 2001 From: David Newell Date: Thu, 25 Jan 2024 11:52:39 +0000 Subject: [PATCH] feat: convert to insight (#19909) --- frontend/src/scenes/notebooks/Nodes/NotebookNodeQuery.tsx | 8 ++++++-- frontend/src/scenes/urls.ts | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/frontend/src/scenes/notebooks/Nodes/NotebookNodeQuery.tsx b/frontend/src/scenes/notebooks/Nodes/NotebookNodeQuery.tsx index dd9e194634abc..07073be4f5ef8 100644 --- a/frontend/src/scenes/notebooks/Nodes/NotebookNodeQuery.tsx +++ b/frontend/src/scenes/notebooks/Nodes/NotebookNodeQuery.tsx @@ -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' @@ -226,7 +226,11 @@ export const NotebookNodeQuery = createPostHogWidgetNode - 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), diff --git a/frontend/src/scenes/urls.ts b/frontend/src/scenes/urls.ts index 691dfe4717363..49112e30f70cb 100644 --- a/frontend/src/scenes/urls.ts +++ b/frontend/src/scenes/urls.ts @@ -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 => 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(