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: use url-safe key and valid base path when rendering apps as web modules #20074

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

amcgee
Copy link
Member

@amcgee amcgee commented Feb 25, 2025

Prior to this change, custom apps were rendered as WebModules in the /api/apps/menu API (introduced with the removal or struts) with unsanitized name fields. This causes issues when app names have special characters or spaces. Additionally, the "namespace" property renders the relative base path for bundled apps but incorrectly was set to the name for installed apps.

I added also a basePath property to the App class which exposes the relative base path also under the /api/apps endpoint.

Before this change (including also a bundled app for reference):

{
  "name": "dhis-web-event-reports",
  "namespace": "/dhis-web-event-reports",
  "defaultAction": "../dhis-web-event-reports/index.html",
  "displayName": "Event Reports",
  "icon": "../icons/dhis-web-event-reports.png"
},
{
  "name": "android-settings-app",
  "namespace": "android-settings-app",
  "defaultAction": "http://localhost:8080/api/apps/android-settings-app/index.html",
  "displayName": "Android Settings",
  "icon": "http://localhost:8080/api/apps/android-settings-app/dhis2-app-icon.png",
  "description": "Configure synchronization parameters for the DHIS2 Android App, customize appear"
},
{
  "name": "Custom Js Css",
  "namespace": "Custom Js Css",
  "defaultAction": "http://localhost:8080/api/apps/Custom-Js-Css/index.html",
  "displayName": "Custom Js Css",
  "icon": "http://localhost:8080/api/apps/Custom-Js-Css/img/Logo_48.png",
  "description": "Custom Js Css"
}

After this change:

{
  "name": "dhis-web-event-reports",
  "namespace": "/dhis-web-event-reports",
  "defaultAction": "../dhis-web-event-reports/index.html",
  "displayName": "Event Reports",
  "icon": "../icons/dhis-web-event-reports.png"
},
{
  "name": "android-settings-app",
  "namespace": "/api/apps/android-settings-app",
  "defaultAction": "http://localhost:8080/api/apps/android-settings-app/index.html",
  "displayName": "Android Settings",
  "icon": "http://localhost:8080/api/apps/android-settings-app/dhis2-app-icon.png",
  "description": "Configure synchronization parameters for the DHIS2 Android App, customize appear"
},
{
  "name": "Custom-Js-Css",
  "namespace": "/api/apps/Custom-Js-Css",
  "defaultAction": "http://localhost:8080/api/apps/Custom-Js-Css/index.html",
  "displayName": "Custom Js Css",
  "icon": "http://localhost:8080/api/apps/Custom-Js-Css/img/Logo_48.png",
  "description": "Custom Js Css"
}

Note that the relative paths for bundled apps and the lack of case standardization are a bit odd and should probably be improved, but I left those as they were previously for now.

@amcgee amcgee requested a review from KaiVandivier February 25, 2025 17:05
@amcgee amcgee added the deploy Deploy DHIS2 instance with IM. label Feb 25, 2025
Copy link

Instance deployed to https://dev.im.dhis2.org/pr-20074

Copy link

sonarqubecloud bot commented Feb 26, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy Deploy DHIS2 instance with IM.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant