From 63a97997496089ac00db210fd1cc6834e7a82e31 Mon Sep 17 00:00:00 2001 From: TackAdam Date: Wed, 5 Jul 2023 13:14:22 -0700 Subject: [PATCH 1/4] Fix availability not being displayed in panel Signed-off-by: TackAdam --- public/components/custom_panels/helpers/utils.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/components/custom_panels/helpers/utils.tsx b/public/components/custom_panels/helpers/utils.tsx index 266939d09..1b5cccf26 100644 --- a/public/components/custom_panels/helpers/utils.tsx +++ b/public/components/custom_panels/helpers/utils.tsx @@ -492,7 +492,7 @@ export const displayVisualization = (metaData: any, data: any, type: string) => const mixedUserConfigs = { availabilityConfig: { - ...(metaData.user_configs?.availabilityConfig || {}), + ...(JSON.parse(metaData.user_configs).availabilityConfig || {}), }, dataConfig: { ...finalDataConfig, From cb7955ccd55e7535aeed098315c8d154db62e453 Mon Sep 17 00:00:00 2001 From: TackAdam Date: Wed, 5 Jul 2023 16:48:56 -0700 Subject: [PATCH 2/4] Fixed config data and layout Signed-off-by: TackAdam --- public/components/custom_panels/helpers/utils.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/components/custom_panels/helpers/utils.tsx b/public/components/custom_panels/helpers/utils.tsx index 1b5cccf26..8460101ff 100644 --- a/public/components/custom_panels/helpers/utils.tsx +++ b/public/components/custom_panels/helpers/utils.tsx @@ -468,7 +468,7 @@ export const displayVisualization = (metaData: any, data: any, type: string) => if (metaData === undefined || isEmpty(metaData)) { return <>; } - const dataConfig = { ...(metaData.user_configs?.dataConfig || {}) }; + const dataConfig = { ...(JSON.parse(metaData.user_configs).dataConfig || {}) }; const hasBreakdowns = !_.isEmpty(dataConfig.breakdowns); const realTimeParsedStats = { ...getDefaultVisConfig(new QueryManager().queryParser().parse(metaData.query).getStats()), @@ -498,7 +498,7 @@ export const displayVisualization = (metaData: any, data: any, type: string) => ...finalDataConfig, }, layoutConfig: { - ...(metaData.user_configs?.layoutConfig || {}), + ...(JSON.parse(metaData.user_configs).layoutConfig || {}), }, }; From 665c84786c7727cdabdf23d0ae2f59deb6877a8f Mon Sep 17 00:00:00 2001 From: TackAdam Date: Thu, 6 Jul 2023 10:28:17 -0700 Subject: [PATCH 3/4] changed fix implementation to not break unit test Signed-off-by: TackAdam --- public/components/custom_panels/helpers/utils.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/public/components/custom_panels/helpers/utils.tsx b/public/components/custom_panels/helpers/utils.tsx index 8460101ff..315874ed4 100644 --- a/public/components/custom_panels/helpers/utils.tsx +++ b/public/components/custom_panels/helpers/utils.tsx @@ -468,7 +468,12 @@ export const displayVisualization = (metaData: any, data: any, type: string) => if (metaData === undefined || isEmpty(metaData)) { return <>; } - const dataConfig = { ...(JSON.parse(metaData.user_configs).dataConfig || {}) }; + + if (metaData.user_configs !== undefined) { + metaData.user_configs = JSON.parse(metaData.user_configs); + } + + const dataConfig = { ...(metaData.user_configs?.dataConfig || {}) }; const hasBreakdowns = !_.isEmpty(dataConfig.breakdowns); const realTimeParsedStats = { ...getDefaultVisConfig(new QueryManager().queryParser().parse(metaData.query).getStats()), @@ -492,13 +497,13 @@ export const displayVisualization = (metaData: any, data: any, type: string) => const mixedUserConfigs = { availabilityConfig: { - ...(JSON.parse(metaData.user_configs).availabilityConfig || {}), + ...(metaData.user_configs?.availabilityConfig || {}), }, dataConfig: { ...finalDataConfig, }, layoutConfig: { - ...(JSON.parse(metaData.user_configs).layoutConfig || {}), + ...(metaData.user_configs?.layoutConfig || {}), }, }; From 7c80ce139135e1a02a4018cc569d1b3de70fbabc Mon Sep 17 00:00:00 2001 From: TackAdam Date: Mon, 10 Jul 2023 09:55:52 -0700 Subject: [PATCH 4/4] Prevent empty string being parsed Signed-off-by: TackAdam --- public/components/custom_panels/helpers/utils.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/components/custom_panels/helpers/utils.tsx b/public/components/custom_panels/helpers/utils.tsx index 315874ed4..a03b84c62 100644 --- a/public/components/custom_panels/helpers/utils.tsx +++ b/public/components/custom_panels/helpers/utils.tsx @@ -469,7 +469,7 @@ export const displayVisualization = (metaData: any, data: any, type: string) => return <>; } - if (metaData.user_configs !== undefined) { + if (metaData.user_configs !== undefined && metaData.user_configs !== '') { metaData.user_configs = JSON.parse(metaData.user_configs); }