Skip to content

Commit

Permalink
refactor: remove dhis/prop-types and upgrade dhis/ui
Browse files Browse the repository at this point in the history
  • Loading branch information
kabaros committed Dec 15, 2023
1 parent f902c36 commit e58a863
Show file tree
Hide file tree
Showing 13 changed files with 781 additions and 36 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
"dependencies": {
"@dhis2/app-runtime": "^3.2.0",
"@dhis2/d2-i18n": "^1.1.0",
"@dhis2/prop-types": "^2.0.3",
"@dhis2/ui": "^7.2.0",
"@dhis2/ui": "^9.0.1",
"moment": "^2.29.0",
"prop-types": "^15.8.1",
"query-string": "^6.14.1",
"react-router-dom": "^5.2.0",
"semver": "^7.3.4",
Expand Down
2 changes: 1 addition & 1 deletion src/components/AppCard/AppCard.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropTypes } from '@dhis2/prop-types'
import PropTypes from 'prop-types'
import React from 'react'
import { AppIcon } from '../AppIcon/AppIcon.js'
import styles from './AppCard.module.css'
Expand Down
2 changes: 1 addition & 1 deletion src/components/AppCards/AppCards.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropTypes } from '@dhis2/prop-types'
import PropTypes from 'prop-types'
import React from 'react'
import styles from './AppCards.module.css'

Expand Down
2 changes: 1 addition & 1 deletion src/components/AppDetails/AppDetails.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import i18n from '@dhis2/d2-i18n'
import { PropTypes } from '@dhis2/prop-types'
import PropTypes from 'prop-types'
import { Card, Divider } from '@dhis2/ui'
import moment from 'moment'
import React, { useState } from 'react'
Expand Down
4 changes: 2 additions & 2 deletions src/components/AppDetails/ManageInstalledVersion.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useAlert, useConfig } from '@dhis2/app-runtime'
import i18n from '@dhis2/d2-i18n'
import { PropTypes } from '@dhis2/prop-types'
import { Button } from '@dhis2/ui'
import PropTypes from 'prop-types'
import { Button, CircularLoader } from '@dhis2/ui'
import React from 'react'
import semver from 'semver'
import { useApi } from '../../api.js'
Expand Down
17 changes: 16 additions & 1 deletion src/components/AppDetails/Versions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useAlert, useConfig } from '@dhis2/app-runtime'
import i18n from '@dhis2/d2-i18n'
import { PropTypes } from '@dhis2/prop-types'
import PropTypes from 'prop-types'
import {
Checkbox,
CircularLoader,
Expand Down Expand Up @@ -142,6 +142,15 @@ const VersionsTable = ({
: i18n.t('Install')
: ''}
</Button>
<a
download
href={version.downloadUrl}
className={styles.downloadLink}
>
<Button small secondary>
{i18n.t('Download')}
</Button>
</a>
</TableCell>
</TableRow>
)
Expand All @@ -159,6 +168,8 @@ VersionsTable.propTypes = {

export const Versions = ({ installedVersion, versions, onVersionInstall }) => {
const [channelsFilter, setChannelsFilter] = useState(new Set(['stable']))
const [versionBeingInstalled, setVersionBeingInstalled] = useState(null)

const installSuccessAlert = useAlert(i18n.t('App installed successfully'), {
success: true,
})
Expand All @@ -185,11 +196,14 @@ export const Versions = ({ installedVersion, versions, onVersionInstall }) => {

const handleVersionInstall = async (version) => {
try {
setVersionBeingInstalled(version.id)
await installVersion(version.id)
installSuccessAlert.show()
onVersionInstall()
} catch (error) {
installErrorAlert.show({ error })
} finally {
setVersionBeingInstalled(null)
}
}

Expand All @@ -202,6 +216,7 @@ export const Versions = ({ installedVersion, versions, onVersionInstall }) => {
/>
{filteredVersions.length > 0 ? (
<VersionsTable
versionBeingInstalled={versionBeingInstalled}
installedVersion={installedVersion}
versions={filteredVersions}
onVersionInstall={handleVersionInstall}
Expand Down
2 changes: 1 addition & 1 deletion src/components/AppIcon/AppIcon.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropTypes } from '@dhis2/prop-types'
import PropTypes from 'prop-types'
import React from 'react'
import styles from './AppIcon.module.css'

Expand Down
2 changes: 1 addition & 1 deletion src/components/AppsList/AppsList.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import i18n from '@dhis2/d2-i18n'
import { PropTypes } from '@dhis2/prop-types'
import PropTypes from 'prop-types'
import { InputField } from '@dhis2/ui'
import React from 'react'
import { useHistory } from 'react-router-dom'
Expand Down
2 changes: 1 addition & 1 deletion src/components/Sidebar/Sidebar.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useConfig } from '@dhis2/app-runtime'
import i18n from '@dhis2/d2-i18n'
import { PropTypes } from '@dhis2/prop-types'
import PropTypes from 'prop-types'
import { Menu, MenuItem } from '@dhis2/ui'
import React from 'react'
import { useHistory, useRouteMatch } from 'react-router-dom'
Expand Down
2 changes: 1 addition & 1 deletion src/pages/AppHub/AppHub.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useConfig, useDataQuery } from '@dhis2/app-runtime'
import i18n from '@dhis2/d2-i18n'
import { PropTypes } from '@dhis2/prop-types'
import PropTypes from 'prop-types'
import {
InputField,
Pagination,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/AppHubApp/AppHubApp.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useDataQuery } from '@dhis2/app-runtime'
import i18n from '@dhis2/d2-i18n'
import { PropTypes } from '@dhis2/prop-types'
import PropTypes from 'prop-types'
import { NoticeBox, CenteredContent, CircularLoader } from '@dhis2/ui'
import React from 'react'
import { useHistory } from 'react-router-dom'
Expand Down
2 changes: 1 addition & 1 deletion src/pages/InstalledApp/InstalledApp.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useDataQuery } from '@dhis2/app-runtime'
import i18n from '@dhis2/d2-i18n'
import { PropTypes } from '@dhis2/prop-types'
import PropTypes from 'prop-types'
import { NoticeBox, CenteredContent, CircularLoader } from '@dhis2/ui'
import React from 'react'
import { useHistory } from 'react-router-dom'
Expand Down
Loading

0 comments on commit e58a863

Please sign in to comment.