From 403adbc45f3d0f7983317eae4a6ccd44f970c428 Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Thu, 7 Nov 2024 16:39:10 +0100 Subject: [PATCH 1/2] fix: infinite spinner when opening the interpretations modal while viewing a visualization (#3283) Fixes DHIS2-18369 The InterpretationsModal callback onResponsesReceived was not being called after a recent fix introduced its own onResponsesReceived callback --- cypress/integration/interpretations.cy.js | 41 +++++++++++++++++++ .../VisualizationPluginWrapper.js | 13 ++++-- 2 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 cypress/integration/interpretations.cy.js diff --git a/cypress/integration/interpretations.cy.js b/cypress/integration/interpretations.cy.js new file mode 100644 index 0000000000..c710a3d4a3 --- /dev/null +++ b/cypress/integration/interpretations.cy.js @@ -0,0 +1,41 @@ +import { VIS_TYPE_BAR } from '@dhis2/analytics' +import { + expectAOTitleToBeValue, + expectVisualizationToBeVisible, +} from '../elements/chart.js' +import { openAOByName } from '../elements/fileMenu/index.js' +import { goToStartPage } from '../elements/startScreen.js' + +describe('Interpretations', () => { + it('opens the interpretations modal on a saved AO', () => { + const ao = { + name: 'ANC: 1 and 3 coverage Yearly', + type: VIS_TYPE_BAR, + } + + // Open the saved AO + goToStartPage() + openAOByName(ao.name) + expectAOTitleToBeValue(ao.name) + expectVisualizationToBeVisible(ao.type) + + // Open the interpretations panel + cy.getBySel('dhis2-analytics-interpretationsanddetailstoggler').click() + + cy.getBySel('interpretations-list') + .find('button') + .contains('See interpretation') + .click() + + cy.getBySel('interpretation-modal').should('be.visible') + + cy.get('.highcharts-container').should('be.visible') + + cy.getBySel('interpretation-modal') + .find('button') + .contains('Hide interpretation') + .click() + + cy.getBySel('interpretation-modal').should('not.exist') + }) +}) diff --git a/src/components/VisualizationPlugin/VisualizationPluginWrapper.js b/src/components/VisualizationPlugin/VisualizationPluginWrapper.js index 18a1e4157f..ebf9b269ab 100644 --- a/src/components/VisualizationPlugin/VisualizationPluginWrapper.js +++ b/src/components/VisualizationPlugin/VisualizationPluginWrapper.js @@ -67,23 +67,28 @@ const VisualizationPluginWrapper = (props) => { const onLoadingComplete = () => setIsLoading(false) - const onResponsesReceived = useCallback( + const { visualization, onResponsesReceived } = props + const handleResponsesReceived = useCallback( (responses) => { try { ensureAnalyticsResponsesContainData( responses, - props.visualization.type + visualization.type ) } catch (error) { setError(error) } + + typeof onResponsesReceived === 'function' && + onResponsesReceived(responses) }, - [props.visualization.type] + [visualization.type, onResponsesReceived] ) if (error) { return } + return ( <> {isLoading && ( @@ -97,7 +102,7 @@ const VisualizationPluginWrapper = (props) => { {...pluginProps} onDataSorted={onDataSorted} onLoadingComplete={onLoadingComplete} - onResponsesReceived={onResponsesReceived} + onResponsesReceived={handleResponsesReceived} /> ) From 81c9ec3682f0a8843ea84cf754c119e970c8d622 Mon Sep 17 00:00:00 2001 From: "@dhis2-bot" Date: Thu, 7 Nov 2024 15:42:01 +0000 Subject: [PATCH 2/2] chore(release): cut 100.8.4 [skip release] ## [100.8.4](https://github.com/dhis2/data-visualizer-app/compare/v100.8.3...v100.8.4) (2024-11-07) ### Bug Fixes * infinite spinner when opening the interpretations modal while viewing a visualization ([#3283](https://github.com/dhis2/data-visualizer-app/issues/3283)) ([403adbc](https://github.com/dhis2/data-visualizer-app/commit/403adbc45f3d0f7983317eae4a6ccd44f970c428)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e2bb8f4ac..ae4368bd90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [100.8.4](https://github.com/dhis2/data-visualizer-app/compare/v100.8.3...v100.8.4) (2024-11-07) + + +### Bug Fixes + +* infinite spinner when opening the interpretations modal while viewing a visualization ([#3283](https://github.com/dhis2/data-visualizer-app/issues/3283)) ([403adbc](https://github.com/dhis2/data-visualizer-app/commit/403adbc45f3d0f7983317eae4a6ccd44f970c428)) + ## [100.8.3](https://github.com/dhis2/data-visualizer-app/compare/v100.8.2...v100.8.3) (2024-10-24) diff --git a/package.json b/package.json index 9047241eb0..cfca1efa43 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "data-visualizer-app", - "version": "100.8.3", + "version": "100.8.4", "description": "DHIS2 Data Visualizer", "license": "BSD-3-Clause", "private": true,