From 20c34d5f16b836bca2514901f71309838f5c4a05 Mon Sep 17 00:00:00 2001 From: Peter Pisljar Date: Wed, 6 Mar 2019 13:03:30 +0100 Subject: [PATCH] fixing pipeline_data_loader (#32478) --- .../public/renderers/visualization.js | 2 +- .../__snapshots__/build_pipeline.test.js.snap | 12 ++++---- .../loader/pipeline_helpers/build_pipeline.ts | 30 +++++++++++++++---- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/legacy/core_plugins/interpreter/public/renderers/visualization.js b/src/legacy/core_plugins/interpreter/public/renderers/visualization.js index df789ae0affd..a04431c8c446 100644 --- a/src/legacy/core_plugins/interpreter/public/renderers/visualization.js +++ b/src/legacy/core_plugins/interpreter/public/renderers/visualization.js @@ -49,7 +49,7 @@ export const visualization = () => ({ handlers.onDestroy(() => visualizationLoader.destroy()); - await visualizationLoader.render(domNode, handlers.vis, visData, uiState, params).then(() => { + await visualizationLoader.render(domNode, handlers.vis, visData, visConfig || handlers.vis.params, uiState, params).then(() => { if (handlers.done) handlers.done(); }); }, diff --git a/src/legacy/ui/public/visualize/loader/pipeline_helpers/__snapshots__/build_pipeline.test.js.snap b/src/legacy/ui/public/visualize/loader/pipeline_helpers/__snapshots__/build_pipeline.test.js.snap index fc854b9c329c..7f257290aaf6 100644 --- a/src/legacy/ui/public/visualize/loader/pipeline_helpers/__snapshots__/build_pipeline.test.js.snap +++ b/src/legacy/ui/public/visualize/loader/pipeline_helpers/__snapshots__/build_pipeline.test.js.snap @@ -4,9 +4,9 @@ exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunct exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles markdown function 1`] = `"kibana_markdown expression='## hello _markdown_' visConfig='{\\"markdown\\":\\"## hello _markdown_\\",\\"foo\\":\\"bar\\"}' "`; -exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles metric function with buckets 1`] = `"kibana_metric visConfig='{\\"dimensions\\":{\\"metrics\\":[0,1],\\"bucket\\":2}}' "`; +exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles metric function with buckets 1`] = `"kibana_metric visConfig='{\\"metric\\":{},\\"dimensions\\":{\\"metrics\\":[0,1],\\"bucket\\":2}}' "`; -exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles metric function without buckets 1`] = `"kibana_metric visConfig='{\\"dimensions\\":{\\"metrics\\":[0,1]}}' "`; +exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles metric function without buckets 1`] = `"kibana_metric visConfig='{\\"metric\\":{},\\"dimensions\\":{\\"metrics\\":[0,1]}}' "`; exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles metrics/tsvb function 1`] = `"tsvb params='{\\"foo\\":\\"bar\\"}' "`; @@ -16,17 +16,17 @@ exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunct exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles region_map function without buckets 1`] = `"regionmap visConfig='{\\"metric\\":0}' "`; -exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles table function with splits 1`] = `"kibana_table visConfig='{\\"dimensions\\":{\\"metrics\\":[0],\\"buckets\\":[],\\"splitRow\\":[1,2]}}' "`; +exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles table function with splits 1`] = `"kibana_table visConfig='{\\"foo\\":\\"bar\\",\\"dimensions\\":{\\"metrics\\":[0],\\"buckets\\":[],\\"splitRow\\":[1,2]}}' "`; -exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles table function with splits and buckets 1`] = `"kibana_table visConfig='{\\"dimensions\\":{\\"metrics\\":[0,1],\\"buckets\\":[3],\\"splitRow\\":[2,4]}}' "`; +exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles table function with splits and buckets 1`] = `"kibana_table visConfig='{\\"foo\\":\\"bar\\",\\"dimensions\\":{\\"metrics\\":[0,1],\\"buckets\\":[3],\\"splitRow\\":[2,4]}}' "`; -exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles table function without splits or buckets 1`] = `"kibana_table visConfig='{\\"dimensions\\":{\\"metrics\\":[0,1],\\"buckets\\":[]}}' "`; +exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles table function without splits or buckets 1`] = `"kibana_table visConfig='{\\"foo\\":\\"bar\\",\\"dimensions\\":{\\"metrics\\":[0,1],\\"buckets\\":[]}}' "`; exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles tagcloud function with buckets 1`] = `"tagcloud visConfig='{\\"metric\\":0,\\"bucket\\":1}' "`; exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles tagcloud function without buckets 1`] = `"tagcloud visConfig='{\\"metric\\":0}' "`; -exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles tile_map function 1`] = `"tilemap visConfig='{\\"dimensions\\":{\\"metric\\":0,\\"geohash\\":1,\\"geocentroid\\":3}}' "`; +exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles tile_map function 1`] = `"tilemap visConfig='{\\"metric\\":{},\\"dimensions\\":{\\"metric\\":0,\\"geohash\\":1,\\"geocentroid\\":3}}' "`; exports[`visualize loader pipeline helpers: build pipeline buildPipelineVisFunction handles timelion function 1`] = `"timelion_vis expression='foo' interval='bar' "`; diff --git a/src/legacy/ui/public/visualize/loader/pipeline_helpers/build_pipeline.ts b/src/legacy/ui/public/visualize/loader/pipeline_helpers/build_pipeline.ts index f1b6eaf4b8bc..c85b5d369fab 100644 --- a/src/legacy/ui/public/visualize/loader/pipeline_helpers/build_pipeline.ts +++ b/src/legacy/ui/public/visualize/loader/pipeline_helpers/build_pipeline.ts @@ -221,27 +221,45 @@ export const buildPipelineVisFunction: BuildPipelineVisFunction = { return `kibana_markdown ${expression}${visConfig}`; }, table: (visState, schemas) => { - const visConfig = buildVisConfig.table(schemas); + const visConfig = { + ...visState.params, + ...buildVisConfig.table(schemas), + }; return `kibana_table ${prepareJson('visConfig', visConfig)}`; }, metric: (visState, schemas) => { - const visConfig = buildVisConfig.metric(schemas); + const visConfig = { + ...visState.params, + ...buildVisConfig.metric(schemas), + }; return `kibana_metric ${prepareJson('visConfig', visConfig)}`; }, tagcloud: (visState, schemas) => { - const visConfig = buildVisConfig.tagcloud(schemas); + const visConfig = { + ...visState.params, + ...buildVisConfig.tagcloud(schemas), + }; return `tagcloud ${prepareJson('visConfig', visConfig)}`; }, region_map: (visState, schemas) => { - const visConfig = buildVisConfig.region_map(schemas); + const visConfig = { + ...visState.params, + ...buildVisConfig.region_map(schemas), + }; return `regionmap ${prepareJson('visConfig', visConfig)}`; }, tile_map: (visState, schemas) => { - const visConfig = buildVisConfig.tile_map(schemas); + const visConfig = { + ...visState.params, + ...buildVisConfig.tile_map(schemas), + }; return `tilemap ${prepareJson('visConfig', visConfig)}`; }, pie: (visState, schemas) => { - const visConfig = buildVisConfig.pie(schemas); + const visConfig = { + ...visState.params, + ...buildVisConfig.pie(schemas), + }; return `kibana_pie ${prepareJson('visConfig', visConfig)}`; }, };