From 8a5403754353d8531decc5cdf73129d38219e322 Mon Sep 17 00:00:00 2001 From: Edoardo Sabadelli Date: Thu, 21 Mar 2024 09:09:00 +0100 Subject: [PATCH] fix: fix period filter and loading spinner when filtering in dashboard (#3002) * fix: ensure only the first period item is used This fixes a problem when a period filter with more than 1 item is applied in dashboard. Passing more than 1 item to the outlier api results in an error. * fix: enable the loading spinner when props change This happens for example when a filter is added in dashboard which causes the visualization object to change and triggers a re-render of the plugin. --- src/api/analytics.js | 6 +++++- .../VisualizationPlugin/VisualizationPluginWrapper.js | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/api/analytics.js b/src/api/analytics.js index 60504ee269..c0c4cf2878 100644 --- a/src/api/analytics.js +++ b/src/api/analytics.js @@ -59,7 +59,11 @@ export const getAnalyticsRequestForOutlierTable = ({ const headers = [] columns.forEach(({ dimension, items }) => { - parameters[dimension] = items.map(({ id }) => id).join(',') + // only use the first period, this accommodates for the dashboard filter scenario + parameters[dimension] = + dimension === DIMENSION_ID_PERIOD + ? items[0].id + : items.map(({ id }) => id).join(',') headers.push(forDownload ? dimension : dimensionIdHeaderMap[dimension]) diff --git a/src/components/VisualizationPlugin/VisualizationPluginWrapper.js b/src/components/VisualizationPlugin/VisualizationPluginWrapper.js index d85fefd75e..7fd8e6edc9 100644 --- a/src/components/VisualizationPlugin/VisualizationPluginWrapper.js +++ b/src/components/VisualizationPlugin/VisualizationPluginWrapper.js @@ -27,7 +27,10 @@ const VisualizationPluginWrapper = (props) => { [pluginProps] ) - useEffect(() => setPluginProps(props), [props]) + useEffect(() => { + setIsLoading(true) + setPluginProps(props) + }, [props]) const onLoadingComplete = () => setIsLoading(false)