Skip to content

Commit

Permalink
fix: pass dhis_version to App Hub apps API
Browse files Browse the repository at this point in the history
  • Loading branch information
mediremi committed Apr 14, 2021
1 parent 8ddee00 commit ae2d60e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 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-04-02T16:41:53.558Z\n"
"PO-Revision-Date: 2021-04-02T16:41:53.558Z\n"
"POT-Creation-Date: 2021-04-14T15:29:09.038Z\n"
"PO-Revision-Date: 2021-04-14T15:29:09.038Z\n"

msgid "App uninstalled successfully"
msgstr ""
Expand Down
6 changes: 5 additions & 1 deletion src/pages/AppHub/AppHub.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useDataQuery } from '@dhis2/app-runtime'
import { useConfig, useDataQuery } from '@dhis2/app-runtime'
import i18n from '@dhis2/d2-i18n'
import { PropTypes } from '@dhis2/prop-types'
import { InputField, Pagination } from '@dhis2/ui'
Expand Down Expand Up @@ -98,13 +98,17 @@ AppsList.propTypes = {
}

export const AppHub = () => {
const { systemInfo } = useConfig()
const [queryParams, setQueryParams] = useQueryParams({
query: withDefault(StringParam, ''),
page: withDefault(NumberParam, 1),
})
const [debouncedQuery] = useDebounce(queryParams.query, 300)
const { loading, error, data, called, refetch } = useDataQuery(query, {
lazy: true,
variables: {
dhis_version: systemInfo.version,
},
})
useEffect(() => {
refetch(queryParams)
Expand Down
14 changes: 11 additions & 3 deletions src/pages/CoreApps/CoreApps.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,24 @@ const query = {
// TODO: Add ability to request certain app IDs to `/v2/apps` API and use
// that instead
appHub: {
resource: 'appHub/v1/apps',
resource: 'appHub/v2/apps',
params: ({ dhis_version }) => ({
paging: false,
dhis_version,
}),
},
modules: {
resource: 'action::menu/getModules',
},
}

export const CoreApps = () => {
const { baseUrl } = useConfig()
const { loading, error, data } = useDataQuery(query)
const { baseUrl, systemInfo } = useConfig()
const { loading, error, data } = useDataQuery(query, {
variables: {
dhis_version: systemInfo.version,
},
})

if (error) {
return (
Expand Down
15 changes: 12 additions & 3 deletions src/pages/CustomApps/CustomApps.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useDataQuery } from '@dhis2/app-runtime'
import { useDataQuery, useConfig } from '@dhis2/app-runtime'
import i18n from '@dhis2/d2-i18n'
import { NoticeBox, CenteredContent, CircularLoader } from '@dhis2/ui'
import React from 'react'
Expand All @@ -16,12 +16,21 @@ const query = {
// TODO: Add ability to request certain app IDs to `/v2/apps` API and use
// that instead
appHub: {
resource: 'appHub/v1/apps',
resource: 'appHub/v2/apps',
params: ({ dhis_version }) => ({
paging: false,
dhis_version,
}),
},
}

export const CustomApps = () => {
const { loading, error, data } = useDataQuery(query)
const { systemInfo } = useConfig()
const { loading, error, data } = useDataQuery(query, {
variables: {
dhis_version: systemInfo.version,
},
})

if (error) {
return (
Expand Down

0 comments on commit ae2d60e

Please sign in to comment.