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

fix: ensure app version is returned for bundled apps [DHIS2-19138] #3236

Merged
merged 6 commits into from
Mar 5, 2025

Conversation

edoardo
Copy link
Member

@edoardo edoardo commented Mar 4, 2025

Implements DHIS2-19138


Key features

  1. lookup app version in the bundled apps list if nothing is returned from api/apps

Description

For apps that are bundled and don't have a manually installed version, api/apps returns nothing.
This causes dashboard to think there isn't an installed version of the app/plugin and shows a warning in the dashboard item. The app version should be looked up in the bundled apps list before returning "no version" (0.0.0).


TODO

  • Tests added (Cypress and/or Jest)

Screenshots

Before.
For bundled apps with no manually installed version, api/apps returns nothing.
A warning is shown in the dashboard item:
Screenshot 2025-03-04 at 17 04 33

After.
The app version is looked up first in api/apps and then in dhis-web-apps/apps-bundle.json:
Screenshot 2025-03-04 at 17 04 51

For apps that are bundled and don't have a manually installed version,
api/apps doesn't return anything.
This causes dashboard to think there isn't an installed version of the
app/plugin and shows a warning in the dashboard item.
The app version should be also looked up in the bundled apps list.
@dhis2-bot
Copy link
Contributor

dhis2-bot commented Mar 4, 2025

🚀 Deployed on https://pr-3236.dashboard.netlify.dhis2.org

@dhis2-bot dhis2-bot temporarily deployed to netlify March 4, 2025 16:36 Inactive
Copy link
Collaborator

@jenniferarnesen jenniferarnesen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, except for the lint error that should be addressed.

Copy link
Contributor

@HendrikThePendric HendrikThePendric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some general suggestions for refactoring this for readability and getting rid of the ESLint warning, but I have also spotted a "real" problem with the current implementation:

  • The appVersions state is being initialised as an empty array
  • The final appVersions state is computed with the results of a GET request
  • The children are being rendered immediately, which means that while the GET request is pending, the descending components are not able to read the app-versions
  • So ideally, I guess this component requires a loading state (and perhaps also an error state). But at the very least, it should render the children conditionally, i.e. {appVersions.length > 0 ? children : null}

Some more general suggestions:

  • Consider consolidating the "all the app fetching logic" into one place. So this would mean removing the get for apps from the CachedDataProvider and moving it to the InstalledAppVersionsProvider*. You could use useDataQuery for this.
  • Consider moving the fetch for bundled apps to dedicated hook: useFetchBundledApps, which mimics the useDataQuery behaviour (i.e. it should return { data, error, loading }
  • After implementing the suggestions above, it should be easy to clean up the provider component

[*] I realise that after doing this, we'll have to scan the full codebase and identify places where we read apps from the useCachedDataQuery hook, and then change it. But I don't think that would be too disruptive.

edoardo added 2 commits March 5, 2025 14:33
The handling for apps (both bundled and installed) will likely change
and hopefully get simplified when/if api/apps will return all apps data.
@dhis2-bot dhis2-bot temporarily deployed to netlify March 5, 2025 14:17 Inactive
Should silence some sonarqube complaint.
@dhis2-bot dhis2-bot temporarily deployed to netlify March 5, 2025 14:32 Inactive
Copy link
Contributor

@HendrikThePendric HendrikThePendric left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

@dhis2-bot dhis2-bot temporarily deployed to netlify March 5, 2025 14:47 Inactive
@jenniferarnesen jenniferarnesen added the e2e record Apply this label to a pull request to trigger recording of E2E tests on Cypress Cloud label Mar 5, 2025
Copy link

sonarqubecloud bot commented Mar 5, 2025

@dhis2-bot dhis2-bot temporarily deployed to netlify March 5, 2025 15:13 Inactive
@jenniferarnesen jenniferarnesen changed the title fix: ensure app version is returned for bundled apps fix: ensure app version is returned for bundled apps [DHIS2-19138] Mar 5, 2025
Copy link

cypress bot commented Mar 5, 2025

dashboards-app    Run #5155

Run Properties:  status check passed Passed #5155  •  git commit 1d886af946 ℹ️: Merge dd09524f84a1765a8436be665ea54088debc5685 into 637c104b1091c502c196076bb34b...
Project dashboards-app
Branch Review fix/bundled-app-versions
Run status status check passed Passed #5155
Run duration 01m 29s
Commit git commit 1d886af946 ℹ️: Merge dd09524f84a1765a8436be665ea54088debc5685 into 637c104b1091c502c196076bb34b...
Committer Edoardo Sabadelli
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 4
View all changes introduced in this branch ↗︎

@edoardo edoardo merged commit 4082158 into master Mar 5, 2025
62 checks passed
@edoardo edoardo deleted the fix/bundled-app-versions branch March 5, 2025 16:09
dhis2-bot added a commit that referenced this pull request Mar 5, 2025
## [101.0.4](v101.0.3...v101.0.4) (2025-03-05)

### Bug Fixes

* retrieve the correct plugin versions for installed and bundled apps [DHIS2-19138] ([#3236](#3236)) ([4082158](4082158))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 101.0.4 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e record Apply this label to a pull request to trigger recording of E2E tests on Cypress Cloud released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants