diff --git a/src/plugins/chart_expressions/expression_partition_vis/public/expression_renderers/partition_vis_renderer.tsx b/src/plugins/chart_expressions/expression_partition_vis/public/expression_renderers/partition_vis_renderer.tsx index c69efc1f56bbe..50198f556f919 100644 --- a/src/plugins/chart_expressions/expression_partition_vis/public/expression_renderers/partition_vis_renderer.tsx +++ b/src/plugins/chart_expressions/expression_partition_vis/public/expression_renderers/partition_vis_renderer.tsx @@ -11,7 +11,11 @@ import { render, unmountComponentAtNode } from 'react-dom'; import { I18nProvider } from '@kbn/i18n-react'; import { css } from '@emotion/react'; import { i18n } from '@kbn/i18n'; -import { Datatable, ExpressionRenderDefinition } from '@kbn/expressions-plugin/public'; +import type { + Datatable, + ExpressionRenderDefinition, + IInterpreterRenderHandlers, +} from '@kbn/expressions-plugin/public'; import type { PersistedState } from '@kbn/visualizations-plugin/public'; import { withSuspense } from '@kbn/presentation-util-plugin/public'; import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; @@ -50,16 +54,18 @@ const partitionVisRenderer = css({ export const getColumnCellValueActions = async ( visConfig: PartitionVisParams, visData: Datatable, - getCompatibleCellValueActions: GetCompatibleCellValueActions | undefined + getCompatibleCellValueActions?: IInterpreterRenderHandlers['getCompatibleCellValueActions'] ) => { if (!Array.isArray(visConfig.dimensions.buckets) || !getCompatibleCellValueActions) { return []; } return Promise.all( visConfig.dimensions.buckets.reduce>>((acc, accessor) => { - const column = getColumnByAccessor(accessor, visData.columns); - if (column) { - acc.push(getCompatibleCellValueActions([{ columnMeta: column.meta }])); + const columnMeta = getColumnByAccessor(accessor, visData.columns)?.meta; + if (columnMeta) { + acc.push( + (getCompatibleCellValueActions as GetCompatibleCellValueActions)([{ columnMeta }]) + ); } return acc; }, []) @@ -84,12 +90,6 @@ export const getPartitionVisRenderer: ( unmountComponentAtNode(domNode); }); - const columnCellValueActions = await getColumnCellValueActions( - visConfig, - visData, - handlers.getCompatibleCellValueActions as GetCompatibleCellValueActions - ); - const renderComplete = () => { const executionContext = handlers.getExecutionContext(); const containerType = extractContainerType(executionContext); @@ -106,7 +106,10 @@ export const getPartitionVisRenderer: ( handlers.done(); }; - const palettesRegistry = await plugins.charts.palettes.getPalettes(); + const [columnCellValueActions, palettesRegistry] = await Promise.all([ + getColumnCellValueActions(visConfig, visData, handlers.getCompatibleCellValueActions), + plugins.charts.palettes.getPalettes(), + ]); render( diff --git a/src/plugins/chart_expressions/expression_xy/public/components/xy_chart.test.tsx b/src/plugins/chart_expressions/expression_xy/public/components/xy_chart.test.tsx index cc2c90c606d58..f8e41ca535828 100644 --- a/src/plugins/chart_expressions/expression_xy/public/components/xy_chart.test.tsx +++ b/src/plugins/chart_expressions/expression_xy/public/components/xy_chart.test.tsx @@ -58,7 +58,7 @@ import { ExtendedDataLayerConfig, XYProps, AnnotationLayerConfigResult } from '. import { DataLayers } from './data_layers'; import { SplitChart } from './split_chart'; import { LegendSize } from '@kbn/visualizations-plugin/common'; -import { LayerCellValueActions } from '../types'; +import type { LayerCellValueActions } from '../types'; const onClickValue = jest.fn(); const layerCellValueActions: LayerCellValueActions = []; diff --git a/src/plugins/chart_expressions/expression_xy/public/expression_renderers/xy_chart_renderer.tsx b/src/plugins/chart_expressions/expression_xy/public/expression_renderers/xy_chart_renderer.tsx index f6cc253adb4e5..fef4b57671b65 100644 --- a/src/plugins/chart_expressions/expression_xy/public/expression_renderers/xy_chart_renderer.tsx +++ b/src/plugins/chart_expressions/expression_xy/public/expression_renderers/xy_chart_renderer.tsx @@ -18,7 +18,10 @@ import { PersistedState } from '@kbn/visualizations-plugin/public'; import type { ChartsPluginStart } from '@kbn/charts-plugin/public'; import type { DataPublicPluginStart } from '@kbn/data-plugin/public'; import { EventAnnotationServiceType } from '@kbn/event-annotation-plugin/public'; -import { ExpressionRenderDefinition } from '@kbn/expressions-plugin/common'; +import type { + ExpressionRenderDefinition, + IInterpreterRenderHandlers, +} from '@kbn/expressions-plugin/common'; import { FormatFactory } from '@kbn/field-formats-plugin/common'; import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; import { UsageCollectionStart } from '@kbn/usage-collection-plugin/public'; @@ -162,7 +165,7 @@ const extractCounterEvents = ( **/ const getLayerCellValueActions = async ( layers: CommonXYDataLayerConfig[], - getCompatibleCellValueActions?: GetCompatibleCellValueActions + getCompatibleCellValueActions?: IInterpreterRenderHandlers['getCompatibleCellValueActions'] ) => { if (!layers || !getCompatibleCellValueActions) { return []; @@ -174,7 +177,7 @@ const getLayerCellValueActions = async ( const column = layer.table.columns.find(({ id }) => id === accessor); return { columnMeta: column?.meta }; }) ?? []; - return getCompatibleCellValueActions(data); + return (getCompatibleCellValueActions as GetCompatibleCellValueActions)(data); }) ); }; diff --git a/x-pack/plugins/lens/public/visualizations/datatable/expression.tsx b/x-pack/plugins/lens/public/visualizations/datatable/expression.tsx index ef6c08aea4a47..c8cd7da4c0bc3 100644 --- a/x-pack/plugins/lens/public/visualizations/datatable/expression.tsx +++ b/x-pack/plugins/lens/public/visualizations/datatable/expression.tsx @@ -29,7 +29,7 @@ import type { import type { FormatFactory } from '../../../common'; import type { DatatableProps } from '../../../common/expressions'; -async function columnsFilterable(table: Datatable, handlers: IInterpreterRenderHandlers) { +async function getColumnsFilterable(table: Datatable, handlers: IInterpreterRenderHandlers) { if (!table.rows.length) { return; } @@ -58,7 +58,7 @@ async function columnsFilterable(table: Datatable, handlers: IInterpreterRenderH **/ export async function getColumnCellValueActions( config: DatatableProps, - getCompatibleCellValueActions: GetCompatibleCellValueActions | undefined + getCompatibleCellValueActions?: ILensInterpreterRenderHandlers['getCompatibleCellValueActions'] ): Promise { if (!config.data || !getCompatibleCellValueActions) { return []; @@ -66,7 +66,7 @@ export async function getColumnCellValueActions( return Promise.all( config.data.columns.map(({ meta: columnMeta }) => { try { - return getCompatibleCellValueActions([{ columnMeta }]); + return (getCompatibleCellValueActions as GetCompatibleCellValueActions)([{ columnMeta }]); } catch { return []; } @@ -129,10 +129,10 @@ export const getDatatableRenderer = (dependencies: { } } - const columnCellValueActions = await getColumnCellValueActions( - config, - getCompatibleCellValueActions as GetCompatibleCellValueActions | undefined - ); + const [columnCellValueActions, columnsFilterable] = await Promise.all([ + getColumnCellValueActions(config, getCompatibleCellValueActions), + getColumnsFilterable(config.data, handlers), + ]); ReactDOM.render( @@ -146,7 +146,7 @@ export const getDatatableRenderer = (dependencies: { getType={resolvedGetType} rowHasRowClickTriggerActions={rowHasRowClickTriggerActions} columnCellValueActions={columnCellValueActions} - columnFilterable={await columnsFilterable(config.data, handlers)} + columnFilterable={columnsFilterable} interactive={isInteractive()} uiSettings={dependencies.uiSettings} renderComplete={renderComplete}