Skip to content

Commit

Permalink
Merge pull request #651 from dhis2/beta
Browse files Browse the repository at this point in the history
chore(release): cut new major version
  • Loading branch information
varl authored Sep 20, 2021
2 parents cc82bdf + cd15af6 commit ff45dd3
Show file tree
Hide file tree
Showing 25 changed files with 2,315 additions and 33,025 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@ module.exports = {
parserOptions: {
allowImportExportEverywhere: true,
},
overrides: [
{
files: ['*.test.js'],
rules: {
'react/prop-types': 'off',
},
},
],
}
61 changes: 22 additions & 39 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# [8.0.0-beta.10](https://github.com/dhis2/app-platform/compare/v8.0.0-beta.9...v8.0.0-beta.10) (2021-09-15)


### chore

* **deps:** upgrade to 7.0.0 of @dhis2/ui ([b624c9e](https://github.com/dhis2/app-platform/commit/b624c9e732a639ee457b90f8264e0fdb21d0dee0))


### BREAKING CHANGES

* **deps:** @dhis2/ui 7.x has dropped support for the deprecated
entrypoints @dhis2/ui-core and @dhis2/ui-widgets.
Please use @dhis2/ui to import components you need in your app.
Everything from core and widgets is available.

# [8.0.0-beta.9](https://github.com/dhis2/app-platform/compare/v8.0.0-beta.8...v8.0.0-beta.9) (2021-09-15)


### Bug Fixes

* **sw-registration:** reregister SW after hard reload ([4c86468](https://github.com/dhis2/app-platform/commit/4c8646871b00211f41e3b9ad09ae70c40338b4fd))

## [7.6.6](https://github.com/dhis2/app-platform/compare/v7.6.5...v7.6.6) (2021-09-15)


Expand Down Expand Up @@ -53,25 +75,6 @@
* simplify message payload to be compatible with firefox ([5e5a633](https://github.com/dhis2/app-platform/commit/5e5a633440e1b103669dae3d0b1e8786cde9f96b))


### Features

* add service worker and pwa capabilities ([#550](https://github.com/dhis2/app-platform/issues/550)) ([225069e](https://github.com/dhis2/app-platform/commit/225069e11d924734c5ac2e257af7d5e9185c612a)), closes [#580](https://github.com/dhis2/app-platform/issues/580) [#582](https://github.com/dhis2/app-platform/issues/582) [#592](https://github.com/dhis2/app-platform/issues/592)
* allow RegEx for filter patterns in d2.config.js ([9699330](https://github.com/dhis2/app-platform/commit/96993301f1d3ba4eec719bd2ecf93b72995653ba))
* use new headerbar with online status indicator ([#626](https://github.com/dhis2/app-platform/issues/626)) ([3bd7d37](https://github.com/dhis2/app-platform/commit/3bd7d37d0776dfd44ab583a95ad47734c1302f84))

# [7.6.0-alpha.1](https://github.com/dhis2/app-platform/compare/v7.5.1...v7.6.0-alpha.1) (2021-08-31)


### Bug Fixes

* catch errors in completeRecording ([e67ae82](https://github.com/dhis2/app-platform/commit/e67ae821b33990435f3846f3ce933362105520bb))
* check whole URL against filter patterns ([5468114](https://github.com/dhis2/app-platform/commit/5468114e8631610d4e70f6c54a288a62cc7f28c2))
* only return sections with cached data from getCachedSections ([f6242d1](https://github.com/dhis2/app-platform/commit/f6242d1b6b25268f3a0c441060264d584d023afe))
* reopen indexedDB if global state resets ([0aded68](https://github.com/dhis2/app-platform/commit/0aded6846b1f9abc567e44144006cb516516e8b3))
* return true if either cache or idb entry is removed ([43d8001](https://github.com/dhis2/app-platform/commit/43d8001ab2aa6077bb0dc3fbaecb2228399a26e4))
* simplify message payload to be compatible with firefox ([5e5a633](https://github.com/dhis2/app-platform/commit/5e5a633440e1b103669dae3d0b1e8786cde9f96b))


### Features

* add service worker and pwa capabilities ([#550](https://github.com/dhis2/app-platform/issues/550)) ([225069e](https://github.com/dhis2/app-platform/commit/225069e11d924734c5ac2e257af7d5e9185c612a)), closes [#580](https://github.com/dhis2/app-platform/issues/580) [#582](https://github.com/dhis2/app-platform/issues/582) [#592](https://github.com/dhis2/app-platform/issues/592)
Expand Down Expand Up @@ -127,26 +130,6 @@
* **publish:** pack when file param is unused ([cc4c802](https://github.com/dhis2/app-platform/commit/cc4c8027db7d14473f1961fb0967dc8ea79eb5a1))


### Features

* add option to skip packing when running build ([669ab94](https://github.com/dhis2/app-platform/commit/669ab9400a3dfda0b8b5e1c740b7646209f85112))
* **pack:** adds pack command ([be700f1](https://github.com/dhis2/app-platform/commit/be700f16197491ee6d1aeb4a5afbd843e991d8ed))
* **publish:** expose publish command module ([ff55d5a](https://github.com/dhis2/app-platform/commit/ff55d5a69a99de27a0df97853164c5e5b43e6268))

# [7.2.0-beta.1](https://github.com/dhis2/app-platform/compare/v7.1.2...v7.2.0-beta.1) (2021-07-23)


### Bug Fixes

* add flags to specify name and version for non-platform apps ([a24e0e6](https://github.com/dhis2/app-platform/commit/a24e0e6bcdd2f55ef4162ccfa5d65a831802cae6))
* correctly parse base config, simplify logic, only rm dir on build ([9891ea3](https://github.com/dhis2/app-platform/commit/9891ea32431b9e452f8aa4cd6f3f4ee29798e057))
* don't throw if d2.config.js doesn't exist ([3385e0e](https://github.com/dhis2/app-platform/commit/3385e0e3682379b2d1ad8b03332f2fb7fcbbecdf))
* **fs:** re-read package.json from disk to make sure it is not stale ([918d113](https://github.com/dhis2/app-platform/commit/918d1137297455cbf4506f9a65bc7fda7d659bad))
* **pack:** use the built app config ([e22d186](https://github.com/dhis2/app-platform/commit/e22d1865ace1d8170dded7191511a7496f1f9051))
* **publish:** only prompt in CI mode ([6872ca0](https://github.com/dhis2/app-platform/commit/6872ca0887fbe1f33180f2dfd4b7c07b4b47746f))
* **publish:** pack when file param is unused ([cc4c802](https://github.com/dhis2/app-platform/commit/cc4c8027db7d14473f1961fb0967dc8ea79eb5a1))


### Features

* add option to skip packing when running build ([669ab94](https://github.com/dhis2/app-platform/commit/669ab9400a3dfda0b8b5e1c740b7646209f85112))
Expand Down
13 changes: 7 additions & 6 deletions adapter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dhis2/app-adapter",
"version": "7.6.6",
"version": "8.0.0-beta.10",
"repository": {
"type": "git",
"url": "https://github.com/amcgee/dhis2-app-platform",
Expand All @@ -21,11 +21,12 @@
"build"
],
"dependencies": {
"@dhis2/pwa": "7.6.6",
"@dhis2/pwa": "8.0.0-beta.10",
"moment": "^2.24.0"
},
"devDependencies": {
"@dhis2/cli-app-scripts": "7.6.6",
"@dhis2/cli-app-scripts": "8.0.0-beta.10",
"@testing-library/react": "^12.0.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
"react": "^16.8",
Expand All @@ -36,15 +37,15 @@
"test": "d2-app-scripts test"
},
"peerDependencies": {
"@dhis2/app-runtime": "^2",
"@dhis2/app-runtime": "^3",
"@dhis2/d2-i18n": "^1",
"@dhis2/ui": "^6",
"@dhis2/ui": "^7",
"classnames": "^2",
"moment": "^2",
"prop-types": "^15",
"react": "^16.8",
"react-dom": "^16.8",
"styled-jsx": "^3"
"styled-jsx": "^4"
},
"jest": {
"setupFilesAfterEnv": [
Expand Down
72 changes: 67 additions & 5 deletions adapter/src/components/Alerts.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,50 @@
import { useAlerts } from '@dhis2/app-runtime'
import { AlertBar, AlertStack } from '@dhis2/ui'
import React from 'react'
import React, { useState, useEffect } from 'react'

export const Alerts = () => {
const alerts = useAlerts()
/*
* The alert-manager which populates the `useAlerts` hook from `@dhis2/app-service-alerts`
* hook with alerts only supports simply adding and removing alerts. However, the
* `AlertBar` from `@dhis2/ui` should leave the screen with a hide-animation, so this
* requires an additional state. The `alertStackAlerts` state in the Alerts component
* provides this addional state:
* - It contains all alerts from the alert-manager, with `options.hidden` set to `false`
* - And also alerts which have been removed from the alert-manager, but still have their
* leave animation in progress, whtih `options.hidden` set to `true`)
* Alerts are removed from the `alertStackAlerts` state once the `onHidden` callback fires
*/

const Alerts = () => {
const alertManagerAlerts = useAlerts()
const [alertStackAlerts, setAlertStackAlerts] = useState(alertManagerAlerts)
const removeAlertStackAlert = id =>
setAlertStackAlerts(
alertStackAlerts.filter(
alertStackAlert => alertStackAlert.id !== id
)
)

useEffect(() => {
if (alertManagerAlerts.length > 0 || alertStackAlerts.length > 0) {
setAlertStackAlerts(
mergeAlertStackAlerts(alertStackAlerts, alertManagerAlerts)
)
}
}, [alertManagerAlerts])

return (
<AlertStack>
{alerts.map(
{alertStackAlerts.map(
({ message, remove, id, options: { onHidden, ...props } }) => (
<AlertBar
{...props}
key={id}
onHidden={() => {
onHidden && onHidden()
remove()
removeAlertStackAlert(id)
if (alertManagerAlerts.some(a => a.id === id)) {
remove()
}
}}
>
{message}
Expand All @@ -24,3 +54,35 @@ export const Alerts = () => {
</AlertStack>
)
}

function mergeAlertStackAlerts(alertStackAlerts, alertManagerAlerts) {
return Object.values({
/*
* Assume that all alerts in the alertStackAlerts array are hiding.
* After the object merge only the alerts not in the alertManagerAlerts
* array will have `options.hidden === true`.
*/
...toIdBasedObjectWithHiddenOption(alertStackAlerts, true),
/*
* All alertManagerAlerts should be showing. This object merge will
* overwrite any alertStackAlert by the alertManagerAlert with
* the same `id`, thus ensuring the alert is visible.
*/
...toIdBasedObjectWithHiddenOption(alertManagerAlerts, false),
})
}

function toIdBasedObjectWithHiddenOption(arr, hidden) {
return arr.reduce((obj, item) => {
obj[item.id] = {
...item,
options: {
...item.options,
hidden,
},
}
return obj
}, {})
}

export { Alerts, mergeAlertStackAlerts }
Loading

0 comments on commit ff45dd3

Please sign in to comment.