Skip to content

Add cht-conf support for upload-ui-extensions action #792

@jkuester

Description

@jkuester

Add a new action: src/fn/upload-ui-extensions.js. Can follow similar patterns as to what is in upload-extension-libs.js.

  • Validation:
    • Each extension must include a .js and a .properties.json file.
    • In the .properties.json (maybe can use joi to do this?):
      • The type must be set and must be either app_main_tab or app_drawer_tab.
      • The title must be set and must be a string
      • The icon must be set and must be a string
      • If roles is set, it must be a string[]
      • If config is set, it must be a Record<string, unknown>
  • Each UI Extension gets its own document in the medic database:
    • type - ui-extension
    • _id - ui-extension:${fileName} (not including the file extension)
    • Include all the contents of the .properties.json as fields in the doc.
    • Include the contents of the .js file as an attachment called extension.js
  • We should support only uploading specific extensions following the same pattern as the upload-*-forms actions.
    • E.g. when you execute cht upload-app-forms -- delivery it will only upload the delivery form and not all app forms.
    • We can get the -- ... data via the environment.extraArgs property. I believe this is just a string array of everything including and after -- (delimited by spaces). So, we might need to drop the initial -- entry (as is done in the args-form-filter lib).
    • If any specific extension names are provided, we should only upload those.

It may make sense to extract at least some of this logic into a lib for better code management and easier unit testing....

Metadata

Metadata

Assignees

Labels

Help wantedGood for first time contributions

Type

No type

Projects

Status

🔍 In Review

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions