From a1e9af83e42373430828aba99928159362767a39 Mon Sep 17 00:00:00 2001 From: Mozafar Haider Date: Wed, 13 Dec 2023 15:22:31 +0000 Subject: [PATCH] fix(DHIS2-15586): update installed state for non-core apps --- .nvmrc | 1 + src/pages/AppHubApp/AppHubApp.js | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..6f7f377 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v16 diff --git a/src/pages/AppHubApp/AppHubApp.js b/src/pages/AppHubApp/AppHubApp.js index d9e5a64..6b8bd44 100644 --- a/src/pages/AppHubApp/AppHubApp.js +++ b/src/pages/AppHubApp/AppHubApp.js @@ -48,11 +48,20 @@ export const AppHubApp = ({ match }) => { ) } - // ToDo: This check here is the cause of the bug https://dhis2.atlassian.net/browse/DHIS2-15586 - // custom apps seem to not have an app_hub_id, when these are surfaced then this should be resolved - // otherwise we need to find a different way to match the app ( || app.name === appHubApp.name would work but not reliable) + // ToDo: This is a workaround to match non-core apps to fix this bug https://dhis2.atlassian.net/browse/DHIS2-15586 + // we don't have an app ID for these apps, so we can't reliably match them. This is the best we can do for now: + // to match with the name + developer email + const matchesNonCoreApp = (installedApp, appHubDetails) => { + return ( + !installedApp.app_hub_id && + installedApp.name === appHubDetails.name && + installedApp.developer?.email === appHubDetails.developer?.email + ) + } + const installedApp = installedApps.find( - (app) => app.app_hub_id === appHubId + (app) => + app.app_hub_id === appHubId || matchesNonCoreApp(app, appHubApp) ) return (