From 34398b4c71fff26ad04867873d0f667ba6f49706 Mon Sep 17 00:00:00 2001 From: Marta Bondyra Date: Wed, 16 Mar 2022 09:54:27 +0100 Subject: [PATCH 1/2] [Lens] fix loosing the datatables in activeData --- .../editor_frame/workspace_panel/workspace_panel.tsx | 1 + 1 file changed, 1 insertion(+) 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 5ca1084d7f507..0ad237109d08b 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 @@ -504,6 +504,7 @@ export const VisualizationWrapper = ({ onActiveDataChange( Object.entries(adapters.tables?.tables).reduce>( (acc, [key, value], index, tables) => ({ + ...acc, [tables.length === 1 ? defaultLayerId : key]: value, }), {} From 8ed99d8d4fd4cdba938e3d8e442f8196bcc6e36c Mon Sep 17 00:00:00 2001 From: Marta Bondyra Date: Wed, 16 Mar 2022 10:03:56 +0100 Subject: [PATCH 2/2] added test for two tables --- .../workspace_panel/workspace_panel.test.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx index c3854f1a67809..b41df97480b86 100644 --- a/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx +++ b/x-pack/plugins/lens/public/editor_frame_service/editor_frame/workspace_panel/workspace_panel.test.tsx @@ -430,12 +430,15 @@ describe('workspace_panel', () => { const onData = expressionRendererMock.mock.calls[0][0].onData$!; - const tableData = { table1: { columns: [], rows: [] } }; - onData(undefined, { tables: { tables: tableData } }); + const tablesData = { + table1: { columns: [], rows: [] }, + table2: { columns: [], rows: [] }, + }; + onData(undefined, { tables: { tables: tablesData } }); expect(mounted.lensStore.dispatch).toHaveBeenCalledWith({ type: 'lens/onActiveDataChange', - payload: tableData, + payload: tablesData, }); });