From 0a05fb2b7b08f71cca7ab771fde64244fa6117f3 Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Fri, 23 Apr 2021 14:17:38 +0300 Subject: [PATCH 1/2] [TSVB] Metrics UI crashes when it is opened from Metrics Ui --- .../components/vis_types/timeseries/config.js | 11 ++++++++--- .../application/lib/get_split_by_terms_color.ts | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/plugins/vis_type_timeseries/public/application/components/vis_types/timeseries/config.js b/src/plugins/vis_type_timeseries/public/application/components/vis_types/timeseries/config.js index 1c3a0411998b0..f6863ea4cd4f9 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/vis_types/timeseries/config.js +++ b/src/plugins/vis_type_timeseries/public/application/components/vis_types/timeseries/config.js @@ -331,8 +331,13 @@ export const TimeseriesConfig = injectI18n(function (props) { ? props.model.series_index_pattern : props.indexPatternForQuery; - const initialPalette = { - ...model.palette, + const initialPalette = model.palette ?? { + type: 'palette', + name: 'default', + }; + + const palette = { + ...initialPalette, name: model.split_color_mode === 'kibana' ? 'kibana_palette' @@ -430,7 +435,7 @@ export const TimeseriesConfig = injectI18n(function (props) { > diff --git a/src/plugins/vis_type_timeseries/public/application/lib/get_split_by_terms_color.ts b/src/plugins/vis_type_timeseries/public/application/lib/get_split_by_terms_color.ts index e8f81bd8c6045..13f1fe5a1f79d 100644 --- a/src/plugins/vis_type_timeseries/public/application/lib/get_split_by_terms_color.ts +++ b/src/plugins/vis_type_timeseries/public/application/lib/get_split_by_terms_color.ts @@ -57,7 +57,7 @@ export const getSplitByTermsColor = ({ } : seriesPalette.params; - const outputColor = palettesRegistry?.get(paletteName).getColor( + const outputColor = palettesRegistry?.get(paletteName || 'default').getColor( [ { name: seriesName || emptyLabel, From b2c2d45fe18aec473dc2286dbc3edc9084c28d5a Mon Sep 17 00:00:00 2001 From: Stratoula Kalafateli Date: Fri, 23 Apr 2021 14:30:02 +0300 Subject: [PATCH 2/2] Fix bug on initialization --- .../application/components/vis_types/timeseries/config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/vis_type_timeseries/public/application/components/vis_types/timeseries/config.js b/src/plugins/vis_type_timeseries/public/application/components/vis_types/timeseries/config.js index f6863ea4cd4f9..1551dae23b24b 100644 --- a/src/plugins/vis_type_timeseries/public/application/components/vis_types/timeseries/config.js +++ b/src/plugins/vis_type_timeseries/public/application/components/vis_types/timeseries/config.js @@ -341,7 +341,7 @@ export const TimeseriesConfig = injectI18n(function (props) { name: model.split_color_mode === 'kibana' ? 'kibana_palette' - : model.split_color_mode || model.palette.name, + : model.split_color_mode || initialPalette.name, }; return (