-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into update-alpha [skip release]
- Loading branch information
Showing
29 changed files
with
248 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Custom Connection Status Message | ||
|
||
By default, the header bar shows either an "Online" or "Offline" message based on whether the app can connect to the DHIS2 server. If it's useful for an app to share other relevant info in that badge, for example "3 changes saved locally", then it's possible to set a custom message there: | ||
|
||
![Custom online status message](custom-online-status-message.png) | ||
|
||
## Hooks | ||
|
||
```ts | ||
import { | ||
useSetOnlineStatusMessage, | ||
useOnlineStatusMessageValue, | ||
useOnlineStatusMessage, | ||
} from '@dhis2/app-runtime' | ||
``` | ||
|
||
### `useSetOnlineStatusMessage` | ||
|
||
It's most likely that you'll only use `useSetOnlineStatusMessage()`, a hook that returns a `setState` function. It can set the value in the Header Bar without causing a rerender for itself. | ||
|
||
`setOnlineStatusMessage()` accepts a `ReactNode`-type object, so icons or other components can be added to the badge, but don't go crazy. A simple string is also a valid `ReactNode`: | ||
|
||
```ts | ||
const setOnlineStatusMessage: (message: ReactNode) => void = | ||
useSetOnlineStatusMessage() | ||
``` | ||
|
||
### `useOnlineStatusMessageValue` | ||
|
||
This hook returns just the value: | ||
|
||
```ts | ||
const onlineStatusMessage: ReactNode = useOnlineStatusMessageValue() | ||
``` | ||
|
||
### `useOnlineStatusMessage` | ||
|
||
This hook returns both the value and the `set` function: | ||
|
||
```ts | ||
const { onlineMessage, setOnlineStatusMessage } = useOnlineStatusMessage() | ||
``` | ||
|
||
## Example | ||
|
||
You can see an example in use in the [Aggregate Data Entry app](https://github.com/dhis2/aggregate-data-entry-app/blob/dadd61392ea010a8017a19a25eaf76f885d9eea7/src/data-workspace/use-handle-headerbar-status.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.