diff --git a/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx b/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx index 14bce116f2d9c..af571d78b8aa7 100644 --- a/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx +++ b/frontend/src/scenes/data-warehouse/editor/OutputPane.tsx @@ -26,7 +26,7 @@ import { variablesLogic } from '~/queries/nodes/DataVisualization/Components/Var import { DataTableVisualizationProps } from '~/queries/nodes/DataVisualization/DataVisualization' import { dataVisualizationLogic } from '~/queries/nodes/DataVisualization/dataVisualizationLogic' import { DataVisualizationNode, HogQLQueryResponse, NodeKind } from '~/queries/schema' -import { ChartDisplayType, ExporterFormat } from '~/types' +import { ChartDisplayType, ExportContext, ExporterFormat } from '~/types' import { dataWarehouseViewsLogic } from '../saved_queries/dataWarehouseViewsLogic' import { multitabEditorLogic } from './multitabEditorLogic' @@ -39,6 +39,7 @@ interface OutputPaneProps { onQueryInputChange: () => void onQueryChange: (query: DataVisualizationNode) => void query: string + exportContext?: ExportContext } export function OutputPane({ @@ -48,6 +49,7 @@ export function OutputPane({ onSaveInsight, saveDisabledReason, query, + exportContext, }: OutputPaneProps): JSX.Element { const { activeTab } = useValues(outputPaneLogic) const { setActiveTab } = useActions(outputPaneLogic) @@ -64,6 +66,7 @@ export function OutputPane({ const { response, responseLoading } = useValues(dataNodeLogic) const { dataWarehouseSavedQueriesLoading } = useValues(dataWarehouseViewsLogic) const { updateDataWarehouseSavedQuery } = useActions(dataWarehouseViewsLogic) + const { visualizationType } = useValues(dataVisualizationLogic) const vizKey = `SQLEditorScene` @@ -126,6 +129,7 @@ export function OutputPane({ setQuery={onQueryChange} context={{}} cachedResults={undefined} + exportContext={exportContext} onSaveInsight={onSaveInsight} /> @@ -160,6 +164,26 @@ export function OutputPane({
+ {exportContext && ( + + )} + {editingView ? ( <> - {props.exportContext && ( - - )} - props.onSaveInsight()}> Create insight diff --git a/frontend/src/scenes/data-warehouse/editor/QueryWindow.tsx b/frontend/src/scenes/data-warehouse/editor/QueryWindow.tsx index a9afba8576b49..a4d79b1300102 100644 --- a/frontend/src/scenes/data-warehouse/editor/QueryWindow.tsx +++ b/frontend/src/scenes/data-warehouse/editor/QueryWindow.tsx @@ -111,8 +111,17 @@ function InternalQueryWindow({ setQuery, query }: InternalQueryWindowProps): JSX }, }) - const { allTabs, activeModelUri, queryInput, activeQuery, hasErrors, error, isValidView, editingView } = - useValues(logic) + const { + allTabs, + activeModelUri, + queryInput, + activeQuery, + hasErrors, + error, + isValidView, + editingView, + exportContext, + } = useValues(logic) const { selectTab, deleteTab, createTab, setQueryInput, runQuery, saveAsView, saveAsInsight } = useActions(logic) return ( @@ -156,6 +165,7 @@ function InternalQueryWindow({ setQuery, query }: InternalQueryWindowProps): JSX onQueryChange={setQuery} onSaveView={saveAsView} onSaveInsight={saveAsInsight} + exportContext={exportContext} saveDisabledReason={ hasErrors ? error ?? 'Query has errors' : !isValidView ? 'Some fields may need an alias' : '' } diff --git a/frontend/src/scenes/data-warehouse/editor/multitabEditorLogic.tsx b/frontend/src/scenes/data-warehouse/editor/multitabEditorLogic.tsx index b0657decbbb7a..14f5f4d23b46d 100644 --- a/frontend/src/scenes/data-warehouse/editor/multitabEditorLogic.tsx +++ b/frontend/src/scenes/data-warehouse/editor/multitabEditorLogic.tsx @@ -11,9 +11,10 @@ import { insightsApi } from 'scenes/insights/utils/api' import { urls } from 'scenes/urls' import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic' +import { queryExportContext } from '~/queries/query' import { HogQLMetadataResponse, HogQLNotice, HogQLQuery, NodeKind } from '~/queries/schema' import { DataVisualizationNode } from '~/queries/schema' -import { DataWarehouseSavedQuery } from '~/types' +import { DataWarehouseSavedQuery, ExportContext } from '~/types' import { dataWarehouseViewsLogic } from '../saved_queries/dataWarehouseViewsLogic' import type { multitabEditorLogicType } from './multitabEditorLogicType' @@ -441,6 +442,18 @@ export const multitabEditorLogic = kea([ : null }, ], + exportContext: [ + () => [(_, props) => props.sourceQuery], + (sourceQuery) => { + // TODO: use active tab at some point + const filename = 'export' + + return { + ...queryExportContext(sourceQuery.source, undefined, undefined), + filename, + } as ExportContext + }, + ], }), afterMount(({ props, values }) => { props.onQueryInputChange?.(values.queryInput)