Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: lazy load dashboards into the navigation menu [DHIS2-10624] #3226

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
c6cbf61
feat: show preferred or default dashboard without accessing dashboard…
jenniferarnesen Feb 18, 2025
d1bd466
feat: star and unstar a dashboard moved to selected
jenniferarnesen Feb 18, 2025
2cdaf23
chore: fetch 1 dashboard to make sure that at least one exists
jenniferarnesen Feb 18, 2025
8e2552d
feat: no longer have access to the dashboard name since not fetching …
jenniferarnesen Feb 18, 2025
ca758e0
feat: component NavigationMenu now works with filter
jenniferarnesen Feb 21, 2025
26d67a0
feat: restore no dashboards message
jenniferarnesen Feb 21, 2025
7fcc846
chore: move latest component code to existing file
jenniferarnesen Feb 21, 2025
4eccd94
Merge branch 'master' into feat/limit-dashboard-preloading-DHIS2-10624
jenniferarnesen Feb 21, 2025
d62929e
Merge branch 'feat/limit-dashboard-preloading-DHIS2-10624' of github.…
jenniferarnesen Feb 21, 2025
97c7051
chore: test changes
jenniferarnesen Feb 21, 2025
f403795
chore: test fixes
jenniferarnesen Feb 21, 2025
8aeecc3
fix: handle case where preferred id is invalid
jenniferarnesen Feb 24, 2025
879db0f
chore: reorder
jenniferarnesen Feb 26, 2025
91968df
chore: reorder more
jenniferarnesen Feb 26, 2025
6fc83c6
chore: use hooks instead of connect from react-redux
jenniferarnesen Feb 26, 2025
94c013f
fix: handle when routeId not found
jenniferarnesen Feb 26, 2025
6ccce38
chore: cleanup
jenniferarnesen Feb 26, 2025
45f161f
chore: remove code smells
jenniferarnesen Feb 26, 2025
0f93299
chore: fix code smell
jenniferarnesen Feb 26, 2025
5092eb1
fix: re set hasDashboards when filter text is removed
jenniferarnesen Feb 26, 2025
2ac1c89
Merge branch 'master' into feat/limit-dashboard-preloading-DHIS2-10624
jenniferarnesen Feb 27, 2025
98ec059
chore: remove console.log
jenniferarnesen Feb 27, 2025
1afe262
fix: state to keep track of whether there are any dashboards at all
jenniferarnesen Feb 27, 2025
d5adb45
fix: filtering and paging together now works
jenniferarnesen Feb 28, 2025
db37e29
Merge branch 'feat/limit-dashboard-preloading-DHIS2-10624' of github.…
jenniferarnesen Feb 28, 2025
358d7f2
chore: temporarily change min height of nav menu
jenniferarnesen Feb 28, 2025
8d21685
fix: avoid duplicate requests when filtering
jenniferarnesen Mar 4, 2025
9714f0b
fix: add hasDashboards prop
jenniferarnesen Mar 4, 2025
a96826c
feat: debounce filtering to 300ms
jenniferarnesen Mar 4, 2025
08d7b87
chore: consolidate filterText and page to single state var
jenniferarnesen Mar 4, 2025
898930f
Merge branch 'master' into feat/limit-dashboard-preloading-DHIS2-10624
jenniferarnesen Mar 4, 2025
9500ca4
chore: a little cleanup
jenniferarnesen Mar 4, 2025
60777d7
chore: fix tests
jenniferarnesen Mar 4, 2025
d916157
Merge branch 'feat/limit-dashboard-preloading-DHIS2-10624' of github.…
jenniferarnesen Mar 4, 2025
67b02f4
test: moving and changing cypress tests
jenniferarnesen Mar 5, 2025
a9ae078
fix: prevent temporary flash of the offline message when switching da…
jenniferarnesen Mar 5, 2025
de4e1bc
fix: reset hasDashboards to true if there are dashboards and add more…
jenniferarnesen Mar 5, 2025
50cf754
test: convert more tests related to nav menu
jenniferarnesen Mar 5, 2025
501b702
chore: lint
jenniferarnesen Mar 5, 2025
799001c
fix: restore original nav menu size
jenniferarnesen Mar 5, 2025
576b489
chore: share query object and dont bother removing preferred id
jenniferarnesen Mar 5, 2025
eefbf3f
chore: lint
jenniferarnesen Mar 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 129 additions & 0 deletions cypress/e2e/view_dashboard.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import { dashboards } from '../assets/backends/index.js'
import {
getNavigationMenuDropdown,
getNavigationMenuItem,
closeNavigationMenu,
getNavigationMenuFilter,
} from '../elements/navigationMenu.js'
import { dashboardTitleSel, newButtonSel } from '../elements/viewDashboard.js'

const assertDashboardDisplayed = (title) => {
cy.location().should((loc) => {
expect(loc.hash).to.equal(dashboards[title].route)
})
cy.get(dashboardTitleSel).should('be.visible').and('contain', title)
}

describe('view dashboard', () => {
it('there are no dashboards', () => {
cy.intercept('**/dashboards?*', { body: { dashboards: [] } })
cy.visit('/')

// check that main dashboard area shows the no dashboards message
cy.contains('No dashboards found').should('be.visible')
cy.get(newButtonSel).should('be.visible')

// check that NavigationMenu shows the no dashboards message
getNavigationMenuDropdown().click()
cy.getByDataTest('navmenu-no-dashboards-message').should('be.visible')
closeNavigationMenu()
})

it('dashboard not found', () => {
cy.visit('#/invalid')

cy.contains('Requested dashboard not found').should('be.visible')

// Open the Delivery dashboard
const title = 'Delivery'
getNavigationMenuItem(title).click()
assertDashboardDisplayed(title)
})

it('switch between dashboards', () => {
cy.visit('/')

// open the Delivery dashboard
const title = 'Delivery'
getNavigationMenuItem(title).click()
assertDashboardDisplayed(title)

// open the Immunization dashboard
const newTitle = 'Immunization'
getNavigationMenuItem(newTitle).click()
assertDashboardDisplayed(newTitle)
})

it('search for a dashboard', () => {
cy.visit('/')

// open the Antenatal Care dashboard
const title = 'Antenatal Care'
getNavigationMenuItem(title).click()
assertDashboardDisplayed(title)

// search for Immun
getNavigationMenuFilter().type('Immun')
getNavigationMenuItem('Immunization', true).should('be.visible')
getNavigationMenuItem('Immunization data', true).should('be.visible')

// open the Immunization dashboard
getNavigationMenuItem('Immunization', true).click()
assertDashboardDisplayed('Immunization')
})

it('search for a dashboard with nonmatching search text', () => {
cy.visit('/')

// open the Antenatal Care dashboard
const title = 'Antenatal Care'
getNavigationMenuItem(title).click()
assertDashboardDisplayed(title)

// search for Noexist
getNavigationMenuFilter().type('xyzpdq')
cy.getByDataTest('navmenu-no-items-found')
.should('be.visible')
.and('contain', 'No dashboards found for "xyzpdq"')
})

it('user preferred dashboard', () => {
cy.visit('/')

// open the Antenatal Care dashboard
getNavigationMenuItem('Antenatal Care').click()
assertDashboardDisplayed('Antenatal Care')

// open the Delivery dashboard
getNavigationMenuItem('Delivery').click()
assertDashboardDisplayed('Delivery')

// open the root url which should display the Delivery dashboard
cy.visit('/')
cy.get(dashboardTitleSel)
.should('be.visible')
.and('contain', 'Delivery')
})

// Given I open the "Delivery" dashboard with shapes removed
// Then the "Delivery" dashboard displays in view mode
it('display dashboard with items lacking shape', () => {
const title = 'Delivery'
const regex = new RegExp(`dashboards/${dashboards[title].id}`, 'g')
cy.intercept(regex, (req) => {
req.reply((res) => {
res.body.dashboardItems.forEach((item) => {
delete item.x
delete item.y
delete item.w
delete item.h
})

res.send({ body: res.body })
})
})
getNavigationMenuItem(title).click()

assertDashboardDisplayed('Delivery')
})
})
5 changes: 0 additions & 5 deletions cypress/e2e_cucumber/common/type_invalid_id_in_url.js

This file was deleted.

49 changes: 0 additions & 49 deletions cypress/e2e_cucumber/view_dashboard.feature
Original file line number Diff line number Diff line change
@@ -1,25 +1,5 @@
Feature: Viewing dashboards

@nonmutating
Scenario: I switch between dashboards
Given I open the "Delivery" dashboard
When I open the "Immunization" dashboard
Then the "Immunization" dashboard displays in view mode

@nonmutating
Scenario: I search for a dashboard
Given I open the "Antenatal Care" dashboard
When I search for dashboards containing "Immun"
Then Immunization and Immunization data dashboards are choices
When I click on the Immunization dashboard in the search results
Then the "Immunization" dashboard displays in view mode

@nonmutating
Scenario: I search for a dashboard with nonmatching search text
Given I open the "Antenatal Care" dashboard
When I search for dashboards containing "Noexist"
Then no dashboards are choices

@nonmutating
Scenario: I view the print layout preview and then print one-item-per-page preview
Given I open the "Delivery" dashboard
Expand All @@ -32,38 +12,9 @@ Feature: Viewing dashboards
When I click to exit print preview
Then the "Delivery" dashboard displays in view mode

@nonmutating
Scenario: I view a dashboard with items lacking shape
Given I open the "Delivery" dashboard with shapes removed
Then the "Delivery" dashboard displays in view mode

# @nonmutating
# FIXME
# Scenario: Maps with tracked entities show layer names in legend
# Given I open the Cases Malaria dashboard
# When I hover over the map legend button
# Then the legend title shows the tracked entity name

@nonmutating
Scenario: User's preferred dashboard is opened
Given I open the "Antenatal Care" dashboard
When I open the dashboard app with the root url
And I open the "Delivery" dashboard
And I open the dashboard app with the root url
Then the "Delivery" dashboard displays


# TODO: flaky test
# @mutating
# Scenario: I change the height of the control bar
# Given I open the "Delivery" dashboard
# When I drag to increase the height of the control bar
# Then the control bar height should be updated

# TODO: flaky test
# @mutating
# Scenario: I change the height of an expanded control bar
# Given I open the "Delivery" dashboard
# When I toggle show more dashboards
# And I drag to decrease the height of the control bar
# Then the control bar height should be updated

This file was deleted.

12 changes: 0 additions & 12 deletions cypress/e2e_cucumber/view_errors.feature
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
Feature: Errors while in view mode

@nonmutating
Scenario: There are no dashboards
Given I open an app with no dashboards
Then a message displays informing that there are no dashboards

@nonmutating
Scenario: I navigate to a dashboard that doesn't exist or I don't have access to
Given I type an invalid dashboard id in the browser url
Then a message displays informing that the dashboard is not found
When I open the "Delivery" dashboard
Then the "Delivery" dashboard displays in view mode

@nonmutating
Scenario: I navigate to edit dashboard that doesn't exist
Given I type an invalid edit dashboard id in the browser url
Expand Down
13 changes: 0 additions & 13 deletions cypress/e2e_cucumber/view_errors/no_dashboards.js

This file was deleted.

2 changes: 1 addition & 1 deletion cypress/support/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const EXTENDED_TIMEOUT = { timeout: 45000 }
export const EXTENDED_TIMEOUT = { timeout: 15000 }

export const getApiBaseUrl = () => {
const baseUrl = Cypress.env('dhis2BaseUrl') || ''
Expand Down
13 changes: 5 additions & 8 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2025-02-07T10:20:57.831Z\n"
"PO-Revision-Date: 2025-02-07T10:20:57.833Z\n"
"POT-Creation-Date: 2025-02-26T12:30:51.331Z\n"
"PO-Revision-Date: 2025-02-26T12:30:51.331Z\n"

msgid "Untitled dashboard"
msgstr "Untitled dashboard"
Expand Down Expand Up @@ -560,12 +560,12 @@ msgstr "Create a new dashboard with the + button."
msgid "Your most viewed dashboards"
msgstr "Your most viewed dashboards"

msgid "No dashboards found. Use the + button to create a new dashboard."
msgstr "No dashboards found. Use the + button to create a new dashboard."

msgid "Requested dashboard not found"
msgstr "Requested dashboard not found"

msgid "No dashboards found. Use the + button to create a new dashboard."
msgstr "No dashboards found. Use the + button to create a new dashboard."

msgid "No description"
msgstr "No description"

Expand Down Expand Up @@ -610,9 +610,6 @@ msgid_plural "{{count}} filters active"
msgstr[0] "{{count}} filter active"
msgstr[1] "{{count}} filters active"

msgid "Loading dashboard – {{name}}"
msgstr "Loading dashboard – {{name}}"

msgid "Loading dashboard"
msgstr "Loading dashboard"

Expand Down
33 changes: 0 additions & 33 deletions src/actions/dashboards.js

This file was deleted.

15 changes: 0 additions & 15 deletions src/actions/dashboardsFilter.js

This file was deleted.

4 changes: 0 additions & 4 deletions src/actions/editDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
sGetItemConfigInsertPosition,
RECEIVED_CODE,
} from '../reducers/editDashboard.js'
import { tFetchDashboards } from './dashboards.js'

// actions

Expand Down Expand Up @@ -183,8 +182,5 @@ export const tSaveDashboard = () => async (dispatch, getState, dataEngine) => {
? await updateDashboard(dataEngine, dashboardToSave)
: await postDashboard(dataEngine, dashboardToSave)

// update the dashboard list
await dispatch(tFetchDashboards())

return Promise.resolve(dashboardId)
}
Loading
Loading