Skip to content

Commit

Permalink
Merge branch 'master' into libs-501-fix-pwa-regression
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiVandivier committed Dec 11, 2023
2 parents 2542c1f + 3253800 commit 45759ac
Show file tree
Hide file tree
Showing 27 changed files with 156 additions and 106 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/rebuild-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'dhis2: rebuild developer docs'

on:
push:
branches:
- master
paths:
- 'docs/**'
- 'CHANGELOG.md'

concurrency:
group: ${{ github.workflow}}-${{ github.ref }}
cancel-in-progress: true

jobs:
rebuild-docs:
runs-on: ubuntu-latest
steps:
- run: curl -X POST -d {} https://api.netlify.com/build_hooks/${{ secrets.NETLIFY_DEVELOPER_DOCS_TOKEN }}
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [3.9.4](https://github.com/dhis2/app-runtime/compare/v3.9.3...v3.9.4) (2023-06-19)


### Bug Fixes

* **types:** add generic result type to oncomplete param ([#1350](https://github.com/dhis2/app-runtime/issues/1350)) ([a069603](https://github.com/dhis2/app-runtime/commit/a069603b4f3b2c9caa2158d7b4087e432cf90668))

## [3.9.3](https://github.com/dhis2/app-runtime/compare/v3.9.2...v3.9.3) (2023-05-16)


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ A query REPL platform application is also available at `./examples/query-playgro

Running `yarn build` at root will automatically update the example app's copy, and running `yarn start` will build the runtime and then start the example.

A [`DHIS2 App Platform`](https://platform.dhis2.nu) example is available at [./examples/query-playground](./examples/query-playground). This is a full, deployable DHIS2 application and a live standalone version is available at [runtime.dhis2.nu/playground](https://runtime.dhis2.nu/playground)
A [`DHIS2 App Platform`](https://platform.dhis2.nu) example is available at [./examples/query-playground](./examples/query-playground). This is a full, deployable DHIS2 application and a live standalone version is available at [every play instance](https://play.dhis2.org), such as the `dev` instance [play.dhis2.org/dev](https://play.dhis2.org/dev/api/apps/query-playground/index.html).

## Release

Expand Down
8 changes: 5 additions & 3 deletions docs/advanced/offline/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Offline tools

!> **WARNING** These features are considered **experimental** and are **subject to breaking changes outside of the normal release cycle.**
:::warning Experimental
These features are considered **experimental** and are **subject to breaking changes outside of the normal release cycle.**
:::

The app platform provides some support for PWA features, including a `manifest.json` file for installability and service worker which can provide offline caching. In addition to those features, the app runtime provides support for ["cacheable sections"](advanced/offline/CacheableSections), which are sections of an app that can be individually cached on-demand. The [`useCacheableSection` hook](advanced/offline/CacheableSections#usecacheablesection-api) and the [`CacheableSection` component](advanced/offline/CacheableSections#cacheablesection-api) provide the controls for the section and the wrapper for the section, respectively. The [`useCachedSections` hook](advanced/offline/CacheableSections#usecachedsections-api) returns a list of sections that are stored in the cache and a function that can delete them.
The app platform provides some support for PWA features, including a `manifest.json` file for installability and service worker which can provide offline caching. In addition to those features, the app runtime provides support for ["cacheable sections"](./CacheableSections.md), which are sections of an app that can be individually cached on-demand. The [`useCacheableSection` hook](./CacheableSections.md#usecacheablesection-api) and the [`CacheableSection` component](./CacheableSections.md#cacheablesection-api) provide the controls for the section and the wrapper for the section, respectively. The [`useCachedSections` hook](./CacheableSections.md#usecachedsections-api) returns a list of sections that are stored in the cache and a function that can delete them.

An important tool for offline-capable apps is the [`useDhis2ConnectionStatus` hook](advanced/offline/useDhis2ConnectionStatus.md), which can be used to determine whether or not the app can connect to the DHIS2 server. There is also a [`useOnlineStatus` hook](advanced/offline/useOnlineStatus.md) which returns whether or not the client is connected to the internet, but `useDhis2ConnectionStatus` is probably the one you want to use. On instances where DHIS2 is deployed locally in an environment without internet, `useOnlineStatus` can cause problems, because it will always return `false` even though the app can communicate with the DHIS2 server and therefore function just fine. `useDhis2ConnectionStatus` was created to address this problem.
An important tool for offline-capable apps is the [`useDhis2ConnectionStatus` hook](./useDhis2ConnectionStatus.md), which can be used to determine whether or not the app can connect to the DHIS2 server. There is also a [`useOnlineStatus` hook](./useOnlineStatus.md) which returns whether or not the client is connected to the internet, but `useDhis2ConnectionStatus` is probably the one you want to use. On instances where DHIS2 is deployed locally in an environment without internet, `useOnlineStatus` can cause problems, because it will always return `false` even though the app can communicate with the DHIS2 server and therefore function just fine. `useDhis2ConnectionStatus` was created to address this problem.

## Examples

Expand Down
4 changes: 3 additions & 1 deletion docs/advanced/offline/useOnlineStatus.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# useOnlineStatus

!> This hook only detects whether or not you're connected to the internet, which could be problematic for DHIS2 instances that are hosted locally or offline, where what really matters is whether or not you can communicate with the DHIS2 server. The [`useDhis2ConnectionStatus` hook](advanced/offline/useDhis2ConnectionStatus) is usually better for that reason, and is therefore recommended.
:::info Internet Only
This hook only detects whether or not you're connected to the internet, which could be problematic for DHIS2 instances that are hosted locally or offline, where what really matters is whether or not you can communicate with the DHIS2 server. The [`useDhis2ConnectionStatus` hook](./useDhis2ConnectionStatus.md) is usually better for that reason, and is therefore recommended.
:::

The `useOnlineStatus` returns whether the client is online or offline. It debounces the returned values by default to prevent rapid changes of any UI elements that depend on the online status.

Expand Down
4 changes: 3 additions & 1 deletion docs/advanced/services.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Services

!> **NOTE**<br/>Services are purely a concept **internal** to `@dhis2/app-runtime` - you don't need to care about them to use it.
:::caution Note
Services are purely a concept **internal** to `@dhis2/app-runtime` - you don't need to care about them to use it.
:::

Internally, `@dhis2/app-runtime` is composed of several functionally-isolated **services**. Each of these services is a private (unpublished) npm package which is bundled into the final `@dhis2/app-runtime` library at build-time. Each services exposes a relevant Context provider as well as various Hook and Component interfaces which are re-exported by the `@dhis2/app-runtime` public package. There are currently only 2 services, but more will be added soon.

Expand Down
30 changes: 15 additions & 15 deletions docs/components/DataMutation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DataMutation Component

A thin wrapper around the [useDataMutation](hooks/useDataMutation.md) hook
A thin wrapper around the [useDataMutation](../hooks/useDataMutation.md) hook

## Basic Usage

Expand All @@ -19,13 +19,13 @@ return (

## Input Props

| Name | Type | Required | Description |
| :------------: | :-----------------------------: | :----------: | ----------------------------------------------------------------------------------------------------------------------------- |
| **mutation** | [_Mutation_](types/Mutation.md) | **required** | The Mutation definition describing the requested operation |
| **variables** | _Object_ | | Variables to be passed to the dynamic portions of the mutation |
| **onComplete** | _Function_ | | Callback function to be called on successfull completion of the mutation. Called with the response data as the only argument. |
| **onError** | _Function_ | | Callback function to be called on failure of the mutation. Called with the error instance as the only argument. |
| **lazy** | _boolean_ | | If false, run the mutation immediately after the component mounts.<br/>_**Default**: `true`_ |
| Name | Type | Required | Description |
| :------------: | :--------------------------------: | :----------: | ----------------------------------------------------------------------------------------------------------------------------- |
| **mutation** | [_Mutation_](../types/Mutation.md) | **required** | The Mutation definition describing the requested operation |
| **variables** | _Object_ | | Variables to be passed to the dynamic portions of the mutation |
| **onComplete** | _Function_ | | Callback function to be called on successfull completion of the mutation. Called with the response data as the only argument. |
| **onError** | _Function_ | | Callback function to be called on failure of the mutation. Called with the error instance as the only argument. |
| **lazy** | _boolean_ | | If false, run the mutation immediately after the component mounts.<br/>_**Default**: `true`_ |

## Render Function Props

Expand All @@ -34,13 +34,13 @@ The render function is called whenever the state of the mutation changes. It is
1. `mutate` - a function which can be called to trigger the mutation (for instance in an onClick callback)
2. `state` - an object containing the following properties:

| Name | Type | Description |
| :---------: | :-------------------------------------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **called** | _boolean_ | **true** if the mutation has been triggered through a call to the `mutate` function or on component mount with `lazy: false` |
| **loading** | _boolean_ | **true** if the data is not yet available and no error has yet been encountered |
| **error** | _Error_<br/>or<br/>_undefined_ | **undefined** if no error has occurred, otherwise the Error which was thrown |
| **data** | _MutationResult_<br/>or<br/>_undefined_ | **undefined** if the data is loading or an error has occurred, otherwise a map from the name of each **QueryDefinition** defined in the **Query** to the resulting data for that query |
| **engine** | [_Data Engine_](advanced/DataEngine) | A reference to the DataEngine instance |
| Name | Type | Description |
| :---------: | :----------------------------------------: | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **called** | _boolean_ | **true** if the mutation has been triggered through a call to the `mutate` function or on component mount with `lazy: false` |
| **loading** | _boolean_ | **true** if the data is not yet available and no error has yet been encountered |
| **error** | _Error_<br/>or<br/>_undefined_ | **undefined** if no error has occurred, otherwise the Error which was thrown |
| **data** | _MutationResult_<br/>or<br/>_undefined_ | **undefined** if the data is loading or an error has occurred, otherwise a map from the name of each **QueryDefinition** defined in the **Query** to the resulting data for that query |
| **engine** | [_Data Engine_](../advanced/DataEngine.md) | A reference to the DataEngine instance |

## Example

Expand Down
Loading

0 comments on commit 45759ac

Please sign in to comment.