Skip to content

Commit

Permalink
Merge branch 'master' into plugin-changes-for-global-shell
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiVandivier committed Nov 6, 2024
2 parents 64fbe3e + 39186d3 commit 668ef82
Show file tree
Hide file tree
Showing 31 changed files with 7,718 additions and 5,256 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/dhis2-verify-lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Build
run: yarn build

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
name: lib-build
path: |
Expand All @@ -77,7 +77,7 @@ jobs:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: lib-build

Expand All @@ -104,7 +104,7 @@ jobs:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: lib-build

Expand All @@ -123,7 +123,7 @@ jobs:
with:
node-version: 14.x

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: lib-build

Expand Down
49 changes: 49 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
## [3.11.2](https://github.com/dhis2/app-runtime/compare/v3.11.1...v3.11.2) (2024-10-14)


### Bug Fixes

* expand FetchErrorDetails type ([#1389](https://github.com/dhis2/app-runtime/issues/1389)) ([ff0ad60](https://github.com/dhis2/app-runtime/commit/ff0ad6077aecdb7627ec985a61c159159be6b8ea))

## [3.11.1](https://github.com/dhis2/app-runtime/compare/v3.11.0...v3.11.1) (2024-10-09)


### Bug Fixes

* handle alert returned async by parentAlertsAdd [LIBS-695] ([#1388](https://github.com/dhis2/app-runtime/issues/1388)) ([9c989b2](https://github.com/dhis2/app-runtime/commit/9c989b2f9c408b7d5988dd0ec8756e86ddf2632f))

# [3.11.0](https://github.com/dhis2/app-runtime/compare/v3.10.6...v3.11.0) (2024-09-10)


### Features

* fixed dimensions efficiency ([#1386](https://github.com/dhis2/app-runtime/issues/1386)) ([2b07a14](https://github.com/dhis2/app-runtime/commit/2b07a14ea7e781c1948cfa651a4ad5759a811c79))

## [3.10.6](https://github.com/dhis2/app-runtime/compare/v3.10.5...v3.10.6) (2024-07-26)


### Bug Fixes

* **cacheable-section:** stable references to avoid loops [LIBS-642] ([#1385](https://github.com/dhis2/app-runtime/issues/1385)) ([e3a5fbf](https://github.com/dhis2/app-runtime/commit/e3a5fbfd3e290cc68493a97adbbd27b9f3dca082))

## [3.10.5](https://github.com/dhis2/app-runtime/compare/v3.10.4...v3.10.5) (2024-06-24)


### Bug Fixes

* update plugin sizing definition ([#1383](https://github.com/dhis2/app-runtime/issues/1383)) ([266dc49](https://github.com/dhis2/app-runtime/commit/266dc49423516189cf4dee706cc78e720af744e2))

## [3.10.4](https://github.com/dhis2/app-runtime/compare/v3.10.3...v3.10.4) (2024-04-09)


### Bug Fixes

* **deps:** remove cli-app-scripts peer dep [LIBS-587] ([#1379](https://github.com/dhis2/app-runtime/issues/1379)) ([3598375](https://github.com/dhis2/app-runtime/commit/3598375a826304b61b9b2cbd279043531628dc70))

## [3.10.3](https://github.com/dhis2/app-runtime/compare/v3.10.2...v3.10.3) (2024-03-20)


### Bug Fixes

* plugin documentation typo ([#1376](https://github.com/dhis2/app-runtime/issues/1376)) ([e51dfb9](https://github.com/dhis2/app-runtime/commit/e51dfb9aa856f6f4c9cfd843d773f6c4a79a52e3))

## [3.10.2](https://github.com/dhis2/app-runtime/compare/v3.10.1...v3.10.2) (2024-01-04)


Expand Down
22 changes: 12 additions & 10 deletions docs/components/Plugin.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Plugin Component

_NOTE:_ This component is experimental and is available for import from `@dhis2/app-runtime/experimental`. The api for this component is not guaranteed to be stable.
:::info Experimental
This component is experimental and is available for import from `@dhis2/app-runtime/experimental`. The api for this component is not guaranteed to be stable.
:::

A wrapper that creates an iframe for a specified plugin and establishes a two-way communication channel with said plugin, allowing you to pass props (including callbacks between an app and a plugin). Note that the plugin must be built using the app-platform with entryPoints.plugin specified in the d2.config.js file.

Expand All @@ -14,7 +16,7 @@ import { Plugin } from '@dhis2/app-runtime/experimental'
// within the app
const MyApp = () => (
<Plugin
pluginShortName={mutation}
pluginShortName={'myPluginShortName'}
onError={(err) => {
console.error(err)
}}
Expand Down Expand Up @@ -49,14 +51,14 @@ const MyPlugin = (propsFromParent) => {

## Plugin Props (reserved props)

| Name | Type | Required | Description |
| :--------------------: | :------------: | :---------------------------------------------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **pluginShortName** | _string_ | _required_ if `pluginSource` is not provided | The shortName of the app/plugin you wish to load (matching the result from api/apps). Used to look up the plugin entry point. If this is not provided, `pluginSource` must be provided. `pluginSource` will take precedence if provided. |
| **pluginSource** | _string_ (url) | _required_ if `pluginShortName` is not provided | The URL of the plugin. If this is not provided, `pluginShortName` must be provided. |
| **onError** | _Function_ | _optional_ | Callback function to be called when an error in the plugin triggers an error boundary. You can use this to pass an error back up to the app and create a custom handling/UX if errors occur in the plugin. In general, it is recommended that you use the plugin's built-in error boundaries |
| **showAlertsInPlugin** | _boolean_ | _optional_ | If `true`, any alerts within the plugin (defined with the `useAlert` hook) will be rendered within the iframe. By default, this is `false`. It is recommended, in general, that you do not override this and allow alerts to be hoisted up to the app level |
| **height** | _number_ | _optional_ | If a height is provided, the iframe will be fixed to the specified height. If no height is provided, the iframe will automatically resize based on its contents. |
| **width** | _number_ | _optional_ | If a width is provided, the iframe will be fixed to the specified width. If no width is provided, the iframe will automatically resize based on its contents. |
| Name | Type | Required | Description |
| :--------------------: | :------------: | :---------------------------------------------: | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **pluginShortName** | _string_ | _required_ if `pluginSource` is not provided | The shortName of the app/plugin you wish to load (matching the result from api/apps). Used to look up the plugin entry point. If this is not provided, `pluginSource` must be provided. `pluginSource` will take precedence if provided. |
| **pluginSource** | _string_ (url) | _required_ if `pluginShortName` is not provided | The URL of the plugin. If this is not provided, `pluginShortName` must be provided. |
| **onError** | _Function_ | _optional_ | Callback function to be called when an error in the plugin triggers an error boundary. You can use this to pass an error back up to the app and create a custom handling/UX if errors occur in the plugin. In general, it is recommended that you use the plugin's built-in error boundaries |
| **showAlertsInPlugin** | _boolean_ | _optional_ | If `true`, any alerts within the plugin (defined with the `useAlert` hook) will be rendered within the iframe. By default, this is `false`. It is recommended, in general, that you do not override this and allow alerts to be hoisted up to the app level |
| **height** | _string_ | _optional_ | If a height is provided, the iframe will be fixed to the specified height. If no height is provided, the iframe will automatically resize its height based on its contents. The value of `height` will not be passed to the plugin, as it is in an internal implementation detail. If you do need to also pass the height to the plugin, you can pass another variable (e.g. `pluginHeight`). |
| **width** | _string_ | _optional_ | If a width is provided, the iframe will be fixed to the specified width. If no width is provided, the iframe will automatically resize its width based on its contents. The value of `width` will not be passed to the plugin, as it is in an internal implementation detail. If you do need to also pass the width to the plugin, you can pass another variable (e.g. `pluginWidth`). |

## Plugin Props (custom props)

Expand Down
32 changes: 16 additions & 16 deletions examples/cra/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1054,32 +1054,32 @@
integrity sha512-ij4wRiunFfaJxjB0BdrYHIH8FxBJpOwNPhhAcunlmPdXudL1WQV1qoP9un6JsEBAgQH+7UXyyjh0g7jTxXK6tg==

"@dhis2/app-runtime@file:../../runtime":
version "3.10.0-alpha.2"
version "3.10.6"
dependencies:
"@dhis2/app-service-alerts" "3.10.0-alpha.2"
"@dhis2/app-service-config" "3.10.0-alpha.2"
"@dhis2/app-service-data" "3.10.0-alpha.2"
"@dhis2/app-service-offline" "3.10.0-alpha.2"
"@dhis2/app-service-plugin" "3.10.0-alpha.2"
"@dhis2/app-service-alerts" "3.10.6"
"@dhis2/app-service-config" "3.10.6"
"@dhis2/app-service-data" "3.10.6"
"@dhis2/app-service-offline" "3.10.6"
"@dhis2/app-service-plugin" "3.10.6"

"@dhis2/app-service-alerts@3.10.0-alpha.2", "@dhis2/app-service-alerts@file:../../services/alerts":
version "3.10.0-alpha.2"
"@dhis2/app-service-alerts@3.10.6", "@dhis2/app-service-alerts@file:../../services/alerts":
version "3.10.6"

"@dhis2/app-service-config@3.10.0-alpha.2", "@dhis2/app-service-config@file:../../services/config":
version "3.10.0-alpha.2"
"@dhis2/app-service-config@3.10.6", "@dhis2/app-service-config@file:../../services/config":
version "3.10.6"

"@dhis2/app-service-data@3.10.0-alpha.2", "@dhis2/app-service-data@file:../../services/data":
version "3.10.0-alpha.2"
"@dhis2/app-service-data@3.10.6", "@dhis2/app-service-data@file:../../services/data":
version "3.10.6"
dependencies:
react-query "^3.13.11"

"@dhis2/app-service-offline@3.10.0-alpha.2", "@dhis2/app-service-offline@file:../../services/offline":
version "3.10.0-alpha.2"
"@dhis2/app-service-offline@3.10.6", "@dhis2/app-service-offline@file:../../services/offline":
version "3.10.6"
dependencies:
lodash "^4.17.21"

"@dhis2/app-service-plugin@3.10.0-alpha.2", "@dhis2/app-service-plugin@file:../../services/plugin":
version "3.10.0-alpha.2"
"@dhis2/app-service-plugin@3.10.6", "@dhis2/app-service-plugin@file:../../services/plugin":
version "3.10.6"
dependencies:
post-robot "^10.0.46"

Expand Down
16 changes: 16 additions & 0 deletions examples/query-playground/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
### Description

A playground for exploring the DHIS2 API and debugging Data Engine queries and mutations

#### How to publish

Since this lives in the repository with the app-runtime library, releasing new versions of this app should be done in a special way to avoid affecting the library's versions:

1. Add any new changes with `chore` commits (not `fix` or `feat`)
2. Make sure the supported DHIS2 versions are correct in `d2.config.js`
3. Manually update the app version in `package.json` -- **Don't use `yarn version`** because we don't want to a create a git tag for this repo
4. Add a `chore` commit for the version bump in `package.json` (make sure this will get its own commit on `master` and doesn't get squashed with others)
5. Build the app with `yarn build`
6. Publish the new version to the App Hub
1. Either on the command line using [`yarn d2-app-scripts publish`](https://developers.dhis2.org/docs/app-platform/scripts/publish/) with an API key you generated on the App Hub
2. Or by using the "New version" GUI on the App Hub by going to "Your Apps" => "Data Query Playground" => "New Version". This requires access to the DHIS2 organization
3 changes: 3 additions & 0 deletions examples/query-playground/d2.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ const config = {
title: 'Data Query Playground',
type: 'app',

id: '99d5e87f-4948-4af6-8c0b-727c77235fd1',
minDHIS2Version: '2.32',

entryPoints: {
app: './src/App',
},
Expand Down
14 changes: 8 additions & 6 deletions examples/query-playground/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "query-playground",
"version": "1.0.0",
"version": "1.1.1",
"description": "",
"license": "BSD-3-Clause",
"private": true,
Expand All @@ -11,18 +11,20 @@
"test": "d2-app-scripts test"
},
"devDependencies": {
"@dhis2/cli-app-scripts": "^5.2.0"
"@dhis2/cli-app-scripts": "<7.6.0"
},
"dependencies": {
"@codemirror/lang-json": "^6.0.1",
"@dhis2/app-runtime": "*",
"@dhis2/ui": "^5.5.3",
"brace": "^0.11.1",
"@dhis2/ui": "^6.25.3",
"@uiw/codemirror-theme-github": "^4.21.25",
"@uiw/codemirror-theme-monokai": "^4.21.25",
"@uiw/react-codemirror": "^4.21.25",
"classnames": "^2.2.6",
"prop-types": "^15.7.2",
"react": "^16.9.0",
"react-ace": "^7.0.4",
"react-dom": "^16.9.0",
"styled-jsx": "^3.2.2"
"styled-jsx": "^4"
},
"resolutions": {
"@dhis2/app-runtime": "file:../../runtime",
Expand Down
3 changes: 0 additions & 3 deletions examples/query-playground/src/components/Editor.css

This file was deleted.

30 changes: 16 additions & 14 deletions examples/query-playground/src/components/Editor.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { json } from '@codemirror/lang-json'
import { githubLight } from '@uiw/codemirror-theme-github'
import { monokai } from '@uiw/codemirror-theme-monokai'
import CodeMirror from '@uiw/react-codemirror'
import PropTypes from 'prop-types'
import React from 'react'
import AceEditor from 'react-ace'
import styles from './Editor.module.css'

import 'brace/mode/json'
import 'brace/theme/monokai'
import 'brace/theme/github'
import './Editor.css'

export const Editor = (props) => (
<AceEditor
fontSize={14}
mode="json"
theme="github"
editorProps={{ $blockScrolling: true }}
showPrintMargin={false}
export const Editor = ({ theme, ...editorProps }) => (
<CodeMirror
className={styles.editor}
extensions={[json()]}
theme={theme === 'light' ? githubLight : monokai}
basicSetup={{ tabSize: 4 }}
width="100%"
height="100%"
{...props}
{...editorProps}
/>
)
Editor.propTypes = {
theme: PropTypes.oneOf(['light', 'dark']),
}
9 changes: 9 additions & 0 deletions examples/query-playground/src/components/Editor.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.editor {
height: 100%;
font-size: 13px;
}

/* Need this selector to override the blanket rule `* { font-family: Roboto; }` */
.editor * {
font-family: inherit;
}
8 changes: 4 additions & 4 deletions examples/query-playground/src/components/QueryEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ export const QueryEditor = ({
execute({ query: parsed, type }).then(setResult)
}

const onKeyPress = (event) => {
const onKeyDown = (event) => {
if ((event.ctrlKey || event.metaKey) && event.key === 'Enter') {
onExecute()
event.stopPropagation()
}
}

return (
<div className={styles.editor} onKeyPress={onKeyPress}>
<div className={styles.editor} onKeyDown={onKeyDown}>
<Editor
value={currentQuery}
theme="monokai"
theme="dark"
onChange={setQuery}
name="editor"
placeholder={i18n.t('Enter a query here...')}
focus={true}
autoFocus={true}
/>

{error && <span className={styles.error}>{error}</span>}
Expand Down
2 changes: 1 addition & 1 deletion examples/query-playground/src/components/QueryResults.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const QueryResults = ({ result }) => {
<div className={styles.results}>
<Editor
value={result}
theme="github"
theme="light"
readOnly={true}
name="results"
placeholder={i18n.t('Results will appear here...')}
Expand Down
2 changes: 1 addition & 1 deletion examples/query-playground/src/components/QueryTab.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropTypes } from '@dhis2/prop-types'
import PropTypes from 'prop-types'
import React from 'react'
import { QueryEditor } from './QueryEditor'
import { QueryResults } from './QueryResults'
Expand Down
7 changes: 7 additions & 0 deletions examples/query-playground/src/components/QueryTab.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
flex-grow: 1;
}

/*
max-height fixes sizing and scrolling for CodeMirror --
it's a bit inelegant with a hardcoded constant, but figuring out a smart
dynamic size was getting complicated with many nested elements in the DOM,
so this saves a bit of a refactor
*/
.results {
width: 50%;
max-height: calc(100vh - 98px);
}
2 changes: 1 addition & 1 deletion examples/query-playground/src/components/TabControls.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import i18n from '@dhis2/d2-i18n'
import { PropTypes } from '@dhis2/prop-types'
import {
Button,
ButtonStrip,
Expand All @@ -11,6 +10,7 @@ import {
TabBar,
Tab,
} from '@dhis2/ui'
import PropTypes from 'prop-types'
import React, { useState } from 'react'
import styles from './TabControls.module.css'

Expand Down
Loading

0 comments on commit 668ef82

Please sign in to comment.