From 82a2d37297f39d93ebd33a484669f7fb1c8700c0 Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Fri, 9 Oct 2020 14:02:36 +0200 Subject: [PATCH 1/2] fix: check whether the dashboard id has been set after the check for existing dashboards [DHIS2-9738] (#1164) The state checks need to happen in a certain order, unfortunately. In an empty database, the id never gets set, resulting in an infinite circular loader. So that check needs to happen after the check for existing dashboards. In an empty database, there are no dashboards. --- src/components/Dashboard/Dashboard.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/Dashboard/Dashboard.js b/src/components/Dashboard/Dashboard.js index 0970e0b3e..29516ad19 100644 --- a/src/components/Dashboard/Dashboard.js +++ b/src/components/Dashboard/Dashboard.js @@ -81,7 +81,7 @@ export const Dashboard = ({ } }, []) - if (!dashboardsLoaded || id === null) { + if (!dashboardsLoaded) { return ( @@ -121,6 +121,16 @@ export const Dashboard = ({ ) } + if (id === null) { + return ( + + + + + + ) + } + return dashboardMap[mode] } From 4fc3a58632dbdfbd6f1fa5ed5b616813eb01ec53 Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Mon, 12 Oct 2020 08:04:13 +0200 Subject: [PATCH 2/2] fix: adjust test to replicate empty dashboards state --- src/components/Dashboard/__tests__/Dashboard.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Dashboard/__tests__/Dashboard.spec.js b/src/components/Dashboard/__tests__/Dashboard.spec.js index c5717a5e0..747a1553e 100644 --- a/src/components/Dashboard/__tests__/Dashboard.spec.js +++ b/src/components/Dashboard/__tests__/Dashboard.spec.js @@ -75,7 +75,7 @@ describe('Dashboard', () => { it('renders correctly when no dashboards found', () => { props.dashboardsLoaded = true props.dashboardsIsEmpty = true - props.id = 'rainbowdash' + props.id = null props.mode = VIEW expect(toJson(dashboard())).toMatchSnapshot() })