diff --git a/src/plugins/unified_histogram/public/chart/histogram.tsx b/src/plugins/unified_histogram/public/chart/histogram.tsx index 8e3aa78da8d9d..19f92d8b4495a 100644 --- a/src/plugins/unified_histogram/public/chart/histogram.tsx +++ b/src/plugins/unified_histogram/public/chart/histogram.tsx @@ -212,6 +212,9 @@ export function Histogram({ > + toExpression: ( + state, + layerId, + indexPatterns, + dateRange, + nowInstant, + searchSessionId, + forceDSL + ) => toExpression( state, layerId, @@ -458,7 +466,8 @@ export function getFormBasedDatasource({ uiSettings, dateRange, nowInstant, - searchSessionId + searchSessionId, + forceDSL ), LayerSettingsComponent(props) { diff --git a/x-pack/plugins/lens/public/datasources/form_based/to_expression.ts b/x-pack/plugins/lens/public/datasources/form_based/to_expression.ts index 743efc9cb8db7..31478cab6bfc8 100644 --- a/x-pack/plugins/lens/public/datasources/form_based/to_expression.ts +++ b/x-pack/plugins/lens/public/datasources/form_based/to_expression.ts @@ -71,7 +71,8 @@ function getExpressionForLayer( uiSettings: IUiSettingsClient, dateRange: DateRange, nowInstant: Date, - searchSessionId?: string + searchSessionId?: string, + forceDSL?: boolean ): ExpressionAstExpression | null { const { columnOrder } = layer; if (columnOrder.length === 0 || !indexPattern) { @@ -523,7 +524,8 @@ export function toExpression( uiSettings: IUiSettingsClient, dateRange: DateRange, nowInstant: Date, - searchSessionId?: string + searchSessionId?: string, + forceDSL?: boolean ) { if (state.layers[layerId]) { return getExpressionForLayer( @@ -532,7 +534,8 @@ export function toExpression( uiSettings, dateRange, nowInstant, - searchSessionId + searchSessionId, + forceDSL ); } diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/expression_helpers.ts b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/expression_helpers.ts index 424e91d1a007d..012fc5c208fe4 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/expression_helpers.ts +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/expression_helpers.ts @@ -15,7 +15,8 @@ export function getDatasourceExpressionsByLayers( indexPatterns: IndexPatternMap, dateRange: DateRange, nowInstant: Date, - searchSessionId?: string + searchSessionId?: string, + forceDSL?: boolean ): null | Record { const datasourceExpressions: Array<[string, Ast | string]> = []; @@ -34,7 +35,8 @@ export function getDatasourceExpressionsByLayers( indexPatterns, dateRange, nowInstant, - searchSessionId + searchSessionId, + forceDSL ); if (result) { datasourceExpressions.push([layerId, result]); @@ -67,6 +69,7 @@ export function buildExpression({ dateRange, nowInstant, searchSessionId, + forceDSL, }: { title?: string; description?: string; @@ -79,6 +82,7 @@ export function buildExpression({ searchSessionId?: string; dateRange: DateRange; nowInstant: Date; + forceDSL?: boolean; }): Ast | null { // if an unregistered visualization is passed in the SO // then this will be set as "undefined". Relax the check to catch both @@ -92,7 +96,8 @@ export function buildExpression({ indexPatterns, dateRange, nowInstant, - searchSessionId + searchSessionId, + forceDSL ); const visualizationExpression = visualization.toExpression( diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/state_helpers.ts b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/state_helpers.ts index efe3ccc84f560..c70d43d4d843b 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/state_helpers.ts +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/state_helpers.ts @@ -367,6 +367,7 @@ export async function persistedStateToExpression( timefilter: TimefilterContract; nowProvider: DataPublicPluginStart['nowProvider']; eventAnnotationService: EventAnnotationServiceType; + forceDSL?: boolean; } ): Promise { const { @@ -459,6 +460,7 @@ export async function persistedStateToExpression( datasourceLayers, indexPatterns, dateRange: { fromDate: currentTimeRange.from, toDate: currentTimeRange.to }, + forceDSL: services.forceDSL, nowInstant: services.nowProvider.get(), }), activeVisualizationState, diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx index 5775748da8cee..31228d8bb1da8 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.tsx @@ -328,6 +328,7 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({ dateRange: framePublicAPI.dateRange, nowInstant: plugins.data.nowProvider.get(), searchSessionId, + forceDSL: framePublicAPI.forceDSL, }); if (ast) { @@ -373,6 +374,7 @@ export const InnerWorkspacePanel = React.memo(function InnerWorkspacePanel({ datasourceLayers, dataViews.indexPatterns, framePublicAPI.dateRange, + framePublicAPI.forceDSL, plugins.data.nowProvider, searchSessionId, addUserMessages, diff --git a/x-pack/plugins/lens/public/editor_frame_service/service.tsx b/x-pack/plugins/lens/public/editor_frame_service/service.tsx index a677e0c6105b8..30a3a3be805f1 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/service.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/service.tsx @@ -93,7 +93,10 @@ export class EditorFrameService { * This is an asynchronous process. * @param doc parsed Lens saved object */ - public documentToExpression = async (doc: LensDocument, services: EditorFramePlugins) => { + public documentToExpression = async ( + doc: LensDocument, + services: EditorFramePlugins & { forceDSL?: boolean } + ) => { const [resolvedDatasources, resolvedVisualizations] = await Promise.all([ this.loadDatasources(), this.loadVisualizations(), diff --git a/x-pack/plugins/lens/public/plugin.ts b/x-pack/plugins/lens/public/plugin.ts index 538e14518bf6e..d02f0a0685cff 100644 --- a/x-pack/plugins/lens/public/plugin.ts +++ b/x-pack/plugins/lens/public/plugin.ts @@ -367,13 +367,14 @@ export class LensPlugin { coreStart, timefilter: plugins.data.query.timefilter.timefilter, expressionRenderer: plugins.expressions.ReactExpressionRenderer, - documentToExpression: (doc: LensDocument) => + documentToExpression: (doc: LensDocument, forceDSL?: boolean) => this.editorFrameService!.documentToExpression(doc, { dataViews: plugins.dataViews, storage: new Storage(localStorage), uiSettings: core.uiSettings, timefilter: plugins.data.query.timefilter.timefilter, nowProvider: plugins.data.nowProvider, + forceDSL, eventAnnotationService, }), injectFilterReferences: data.query.filterManager.inject.bind(data.query.filterManager), diff --git a/x-pack/plugins/lens/public/react_embeddable/data_loader.ts b/x-pack/plugins/lens/public/react_embeddable/data_loader.ts index a1d2e713d3f81..fe11a7fe66a16 100644 --- a/x-pack/plugins/lens/public/react_embeddable/data_loader.ts +++ b/x-pack/plugins/lens/public/react_embeddable/data_loader.ts @@ -224,6 +224,7 @@ export function loadEmbeddableData( handleEvent, disableTriggers, updateBlockingErrors, + forceDSL: (parentApi as { forceDSL?: boolean }).forceDSL, getDisplayOptions: internalApi.getDisplayOptions, }), getUsedDataViews( diff --git a/x-pack/plugins/lens/public/react_embeddable/expressions/expression_params.ts b/x-pack/plugins/lens/public/react_embeddable/expressions/expression_params.ts index ff6206f3f70e4..f3d4a359ca949 100644 --- a/x-pack/plugins/lens/public/react_embeddable/expressions/expression_params.ts +++ b/x-pack/plugins/lens/public/react_embeddable/expressions/expression_params.ts @@ -62,15 +62,20 @@ interface GetExpressionRendererPropsParams { api: LensApi; addUserMessages: (messages: UserMessage[]) => void; updateBlockingErrors: (error: Error) => void; + forceDSL?: boolean; getDisplayOptions: () => VisualizationDisplayOptions; } async function getExpressionFromDocument( document: LensDocument, - documentToExpression: (doc: LensDocument) => Promise + documentToExpression: ( + doc: LensDocument, + forceDSL?: boolean + ) => Promise, + forceDSL?: boolean ) { const { ast, indexPatterns, indexPatternRefs, activeVisualizationState, activeDatasourceState } = - await documentToExpression(document); + await documentToExpression(document, forceDSL); return { expression: ast ? toExpression(ast) : null, indexPatterns, @@ -147,6 +152,7 @@ export async function getExpressionRendererParams( addUserMessages, updateBlockingErrors, searchContext, + forceDSL, getDisplayOptions, }: GetExpressionRendererPropsParams ): Promise<{ @@ -165,7 +171,7 @@ export async function getExpressionRendererParams( indexPatternRefs, activeVisualizationState, activeDatasourceState, - } = await getExpressionFromDocument(state.attributes, documentToExpression); + } = await getExpressionFromDocument(state.attributes, documentToExpression, forceDSL); // Apparently this change produces had lots of issues with solutions not using // the Embeddable incorrectly. Will comment for now and later on will restore it when diff --git a/x-pack/plugins/lens/public/react_embeddable/initializers/initialize_dashboard_services.ts b/x-pack/plugins/lens/public/react_embeddable/initializers/initialize_dashboard_services.ts index 67a5d3a89a1c2..06e72def12c62 100644 --- a/x-pack/plugins/lens/public/react_embeddable/initializers/initialize_dashboard_services.ts +++ b/x-pack/plugins/lens/public/react_embeddable/initializers/initialize_dashboard_services.ts @@ -182,6 +182,7 @@ export function initializeDashboardServices( className: getUnchangingComparator(), overrides: overridesComparator, disableTriggers: disabledTriggersComparator, + forceDSL: getUnchangingComparator(), isNewPanel: getUnchangingComparator<{ isNewPanel?: boolean }, 'isNewPanel'>(), parentApi: getUnchangingComparator, 'parentApi'>(), }, diff --git a/x-pack/plugins/lens/public/react_embeddable/renderer/lens_custom_renderer_component.tsx b/x-pack/plugins/lens/public/react_embeddable/renderer/lens_custom_renderer_component.tsx index 3caada55b81db..1f60c93679952 100644 --- a/x-pack/plugins/lens/public/react_embeddable/renderer/lens_custom_renderer_component.tsx +++ b/x-pack/plugins/lens/public/react_embeddable/renderer/lens_custom_renderer_component.tsx @@ -60,6 +60,7 @@ export function LensRenderer({ timeRange, disabledActions, searchSessionId, + forceDSL, hidePanelTitles, lastReloadRequestTime, ...props @@ -157,6 +158,7 @@ export function LensRenderer({ ...initialStateRef.current, attributes: props.attributes, }), + forceDSL, hidePanelTitle: hidePanelTitles$, reload$, // trigger a reload (replacement for deprepcated searchSessionId) })} diff --git a/x-pack/plugins/lens/public/react_embeddable/types.ts b/x-pack/plugins/lens/public/react_embeddable/types.ts index 98b85860f414f..32cdb6728f041 100644 --- a/x-pack/plugins/lens/public/react_embeddable/types.ts +++ b/x-pack/plugins/lens/public/react_embeddable/types.ts @@ -135,7 +135,10 @@ export type LensEmbeddableStartServices = Simplify< coreStart: CoreStart; capabilities: RecursiveReadonly; expressionRenderer: ReactExpressionRendererType; - documentToExpression: (doc: LensDocument) => Promise; + documentToExpression: ( + doc: LensDocument, + forceDSL?: boolean + ) => Promise; injectFilterReferences: FilterManager['inject']; visualizationMap: VisualizationMap; datasourceMap: DatasourceMap; @@ -261,6 +264,7 @@ export interface LensSharedProps { className?: string; noPadding?: boolean; viewMode?: ViewMode; + forceDSL?: boolean; } interface LensRequestHandlersProps { @@ -323,7 +327,13 @@ export type LensComponentProps = Simplify< */ export type LensComponentForwardedProps = Pick< LensComponentProps, - 'style' | 'className' | 'noPadding' | 'abortController' | 'executionContext' | 'viewMode' + | 'style' + | 'className' + | 'noPadding' + | 'abortController' + | 'executionContext' + | 'viewMode' + | 'forceDSL' >; /** @@ -347,7 +357,10 @@ export type LensRendererProps = Simplify; export type LensRuntimeState = Simplify< Omit & { attributes: NonNullable; - } & Pick & + } & Pick< + LensComponentForwardedProps, + 'viewMode' | 'abortController' | 'executionContext' | 'forceDSL' + > & ContentManagementProps >; diff --git a/x-pack/plugins/lens/public/types.ts b/x-pack/plugins/lens/public/types.ts index f6d4edc02e16d..9b44a951cfcd6 100644 --- a/x-pack/plugins/lens/public/types.ts +++ b/x-pack/plugins/lens/public/types.ts @@ -432,7 +432,8 @@ export interface Datasource ExpressionAstExpression | string | null; getDatasourceSuggestionsForField: ( @@ -962,6 +963,7 @@ export interface FramePublicAPI { */ activeData?: Record; dataViews: DataViewsState; + forceDSL?: boolean; } /**