Skip to content

Commit

Permalink
fix: check whether the dashboard id has been set after the check for …
Browse files Browse the repository at this point in the history
…existing dashboards [DHIS2-9738] [patch/2.35.0] (#1167)

* 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.

* fix: adjust test to replicate empty dashboards state
  • Loading branch information
jenniferarnesen authored Oct 12, 2020
1 parent a968488 commit 9354228
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/components/Dashboard/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const Dashboard = ({
}
}, [])

if (!dashboardsLoaded || id === null) {
if (!dashboardsLoaded) {
return (
<Layer translucent>
<CenteredContent>
Expand Down Expand Up @@ -121,6 +121,16 @@ export const Dashboard = ({
)
}

if (id === null) {
return (
<Layer translucent>
<CenteredContent>
<CircularLoader />
</CenteredContent>
</Layer>
)
}

return dashboardMap[mode]
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/Dashboard/__tests__/Dashboard.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
Expand Down

0 comments on commit 9354228

Please sign in to comment.