Skip to content

Commit

Permalink
Merge branch 'master' into use-multicalendar-dates
Browse files Browse the repository at this point in the history
  • Loading branch information
janhenrikoverland authored Feb 9, 2023
2 parents eb716eb + ae5cac3 commit 0aad838
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 232 deletions.
19 changes: 2 additions & 17 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2022-09-23T12:57:32.255Z\n"
"PO-Revision-Date: 2022-09-23T12:57:32.255Z\n"
"POT-Creation-Date: 2023-02-08T10:41:55.462Z\n"
"PO-Revision-Date: 2023-02-08T10:41:55.462Z\n"

msgid "All items"
msgstr "All items"
Expand Down Expand Up @@ -706,21 +706,6 @@ msgstr "Open as Map"
msgid "Visually plot data on a world map. Data elements use separate map layers."
msgstr "Visually plot data on a world map. Data elements use separate map layers."

msgid "Reporting rate"
msgstr "Reporting rate"

msgid "Reporting rate on time"
msgstr "Reporting rate on time"

msgid "Actual reports"
msgstr "Actual reports"

msgid "Actual reports on time"
msgstr "Actual reports on time"

msgid "Expected reports"
msgstr "Expected reports"

msgid "No data available"
msgstr "No data available"

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"@dhis2/analytics": "^24.5.0-alpha.1",
"@dhis2/app-runtime": "^3.7.0",
"@dhis2/app-runtime-adapter-d2": "^1.1.0",
"@dhis2/app-service-datastore": "^1.0.0-beta.3",
"@dhis2/d2-i18n": "^1.1.0",
"@dhis2/ui": "^8.7.6",
"@krakenjs/post-robot": "^11.0.0",
Expand Down
64 changes: 34 additions & 30 deletions src/AppWrapper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useConfig, useDataEngine } from '@dhis2/app-runtime'
import { D2Shim } from '@dhis2/app-runtime-adapter-d2'
import { DataStoreProvider } from '@dhis2/app-service-datastore'
import React from 'react'
import { Provider as ReduxProvider } from 'react-redux'
import thunk from 'redux-thunk'
Expand All @@ -9,6 +10,7 @@ import UserSettingsProvider, {
} from './components/UserSettingsProvider.js'
import configureStore from './configureStore.js'
import metadataMiddleware from './middleware/metadata.js'
import { USER_DATASTORE_NAMESPACE } from './modules/currentAnalyticalObject.js'
import history from './modules/history.js'
import './locales/index.js'

Expand All @@ -31,36 +33,38 @@ const AppWrapper = () => {

return (
<ReduxProvider store={store}>
<UserSettingsProvider>
<UserSettingsCtx.Consumer>
{({ userSettings }) => {
return userSettings?.uiLocale ? (
<D2Shim
d2Config={d2Config}
i18nRoot="./i18n_old"
locale={userSettings.uiLocale}
>
{({ d2 }) => {
if (!d2) {
// TODO: Handle errors in d2 initialization
return null
} else {
return (
<App
d2={d2}
location={history.location}
baseUrl={baseUrl}
dataEngine={engine}
userSettings={userSettings}
/>
)
}
}}
</D2Shim>
) : null
}}
</UserSettingsCtx.Consumer>
</UserSettingsProvider>
<DataStoreProvider namespace={USER_DATASTORE_NAMESPACE}>
<UserSettingsProvider>
<UserSettingsCtx.Consumer>
{({ userSettings }) => {
return userSettings?.uiLocale ? (
<D2Shim
d2Config={d2Config}
i18nRoot="./i18n_old"
locale={userSettings.uiLocale}
>
{({ d2 }) => {
if (!d2) {
// TODO: Handle errors in d2 initialization
return null
} else {
return (
<App
d2={d2}
location={history.location}
baseUrl={baseUrl}
dataEngine={engine}
userSettings={userSettings}
/>
)
}
}}
</D2Shim>
) : null
}}
</UserSettingsCtx.Consumer>
</UserSettingsProvider>
</DataStoreProvider>
</ReduxProvider>
)
}
Expand Down
116 changes: 0 additions & 116 deletions src/api/__tests__/userDataStore.spec.js

This file was deleted.

41 changes: 0 additions & 41 deletions src/api/userDataStore.js

This file was deleted.

28 changes: 18 additions & 10 deletions src/components/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { apiFetchOrganisationUnitLevels } from '@dhis2/analytics'
import { useSetting } from '@dhis2/app-service-datastore'
import i18n from '@dhis2/d2-i18n'
import {
CssVariables,
Expand All @@ -13,11 +14,8 @@ import PropTypes from 'prop-types'
import React, { Component } from 'react'
import { connect } from 'react-redux'
import * as fromActions from '../actions/index.js'
import {
apiFetchAOFromUserDataStore,
CURRENT_AO_KEY,
} from '../api/userDataStore.js'
import { Snackbar } from '../components/Snackbar/Snackbar.js'
import { USER_DATASTORE_CURRENT_AO_KEY } from '../modules/currentAnalyticalObject.js'
import history from '../modules/history.js'
import defaultMetadata from '../modules/metadata.js'
import { getParentGraphMapFromVisualization } from '../modules/ui.js'
Expand Down Expand Up @@ -100,13 +98,11 @@ export class UnconnectedApp extends Component {
// /${id}/interpretation/${interpretationId}
const { id } = this.parseLocation(location)

const urlContainsCurrentAOKey = id === CURRENT_AO_KEY
const urlContainsCurrentAOKey = id === USER_DATASTORE_CURRENT_AO_KEY

if (urlContainsCurrentAOKey) {
const AO = await apiFetchAOFromUserDataStore()

this.props.addParentGraphMap(
getParentGraphMapFromVisualization(AO)
getParentGraphMapFromVisualization(this.props.currentAO)
)

// clear visualization and current
Expand All @@ -115,7 +111,7 @@ export class UnconnectedApp extends Component {
this.props.clearVisualization()
this.props.clearCurrent()

this.props.setUiFromVisualization(AO)
this.props.setUiFromVisualization(this.props.currentAO)
this.props.setCurrentFromUi(this.props.ui)
}

Expand Down Expand Up @@ -385,6 +381,7 @@ UnconnectedApp.propTypes = {
clearCurrent: PropTypes.func,
clearVisualization: PropTypes.func,
current: PropTypes.object,
currentAO: PropTypes.object,
d2: PropTypes.object,
dataEngine: PropTypes.object,
loadUserAuthority: PropTypes.func,
Expand All @@ -400,4 +397,15 @@ UnconnectedApp.propTypes = {
visualization: PropTypes.object,
}

export const App = connect(mapStateToProps, mapDispatchToProps)(UnconnectedApp)
const withCurrentAO = (Component) => {
return function WrappedComponent(props) {
const [currentAO] = useSetting(USER_DATASTORE_CURRENT_AO_KEY)

return <Component {...props} currentAO={currentAO} />
}
}

export const App = connect(
mapStateToProps,
mapDispatchToProps
)(withCurrentAO(UnconnectedApp))
4 changes: 2 additions & 2 deletions src/components/UpdateButton/UpdateVisualizationContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
acClearLoadError,
acSetPluginLoading,
} from '../../actions/loader.js'
import { CURRENT_AO_KEY } from '../../api/userDataStore.js'
import { USER_DATASTORE_CURRENT_AO_KEY } from '../../modules/currentAnalyticalObject.js'
import { GenericClientError } from '../../modules/error.js'
import history from '../../modules/history.js'
import { validateLayout } from '../../modules/layoutValidation.js'
Expand Down Expand Up @@ -36,7 +36,7 @@ const UpdateVisualizationContainer = ({
onUpdate()

const urlContainsCurrentAOKey =
history.location.pathname === '/' + CURRENT_AO_KEY
history.location.pathname === '/' + USER_DATASTORE_CURRENT_AO_KEY

const current = getCurrent()

Expand Down
Loading

0 comments on commit 0aad838

Please sign in to comment.