Skip to content

Commit

Permalink
fix: translate bundled application names
Browse files Browse the repository at this point in the history
  • Loading branch information
mediremi committed Mar 17, 2021
1 parent acfe7ce commit 57ba7a3
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 38 deletions.
4 changes: 2 additions & 2 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: 2021-03-17T12:13:51.869Z\n"
"PO-Revision-Date: 2021-03-17T12:13:51.869Z\n"
"POT-Creation-Date: 2021-03-17T14:45:51.504Z\n"
"PO-Revision-Date: 2021-03-17T14:45:51.504Z\n"

msgid "No apps found"
msgstr ""
Expand Down
29 changes: 1 addition & 28 deletions src/components/AppList/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import i18n from '@dhis2/d2-i18n'
import { PropTypes } from '@dhis2/prop-types'
import {
NoticeBox,
CenteredContent,
CircularLoader,
InputField,
} from '@dhis2/ui'
import { InputField } from '@dhis2/ui'
import React from 'react'
import { useHistory } from 'react-router-dom'
import { useQueryParam, StringParam, withDefault } from 'use-query-params'
Expand Down Expand Up @@ -89,11 +84,8 @@ AllApps.propTypes = {
}

const AppList = ({
error,
loading,
apps,
appsWithUpdates,
errorLabel,
updatesAvailableLabel,
allAppsLabel,
searchLabel,
Expand All @@ -106,22 +98,6 @@ const AppList = ({
setQuery(value, 'replaceIn')
}

if (error) {
return (
<NoticeBox error title={errorLabel}>
{error.message}
</NoticeBox>
)
}

if (loading) {
return (
<CenteredContent>
<CircularLoader />
</CenteredContent>
)
}

const searchFilter = app =>
!query ||
app.name.toLocaleLowerCase().includes(query.toLocaleLowerCase())
Expand All @@ -147,13 +123,10 @@ const AppList = ({

AppList.propTypes = {
allAppsLabel: PropTypes.string.isRequired,
errorLabel: PropTypes.string.isRequired,
searchLabel: PropTypes.string.isRequired,
updatesAvailableLabel: PropTypes.string.isRequired,
apps: PropTypes.array,
appsWithUpdates: PropTypes.array,
error: PropTypes.object,
loading: PropTypes.bool,
}

export default AppList
36 changes: 28 additions & 8 deletions src/components/CoreApps/CoreApps.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useDataQuery, useConfig } from '@dhis2/app-runtime'
import i18n from '@dhis2/d2-i18n'
import { NoticeBox, CenteredContent, CircularLoader } from '@dhis2/ui'
import React from 'react'
import getLatestVersion from '../../get-latest-version'
import AppList from '../AppList'
Expand Down Expand Up @@ -63,7 +64,28 @@ export const CoreApps = () => {
const { baseUrl } = useConfig()
const { loading, error, data } = useDataQuery(query)

const overridenCoreApps = data?.coreApps.filter(app => app.bundled)
if (error) {
return (
<NoticeBox
error
title={i18n.t(
'Something went wrong whilst loading your core apps'
)}
>
{error.message}
</NoticeBox>
)
}

if (loading) {
return (
<CenteredContent>
<CircularLoader />
</CenteredContent>
)
}

const overridenCoreApps = data.coreApps.filter(app => app.bundled)
const apps = coreApps
.map(coreApp => {
const overridenApp = overridenCoreApps?.find(
Expand All @@ -72,13 +94,16 @@ export const CoreApps = () => {
if (overridenApp) {
return overridenApp
}
const iconUrl = data?.modules.modules.find(
const module = data.modules.modules.find(
m => m.name === `dhis-web-${coreApp.short_name}`
)?.icon
)
const iconUrl = module?.icon
const icons = iconUrl ? { 48: iconUrl } : {}
const name = module?.displayName || coreApp.name
return {
...coreApp,
baseUrl: `${baseUrl}/dhis-web-${coreApp.short_name}`,
name,
icons,
}
})
Expand All @@ -95,13 +120,8 @@ export const CoreApps = () => {

return (
<AppList
error={error}
loading={loading}
apps={apps}
appsWithUpdates={appsWithUpdates}
errorLabel={i18n.t(
'Something went wrong whilst loading your core apps'
)}
updatesAvailableLabel={i18n.t('Core apps with updates available')}
allAppsLabel={i18n.t('All core apps')}
searchLabel={i18n.t('Search core apps')}
Expand Down

0 comments on commit 57ba7a3

Please sign in to comment.