From 1135152227e31e83c0a65fdafaf2acbbafb3a272 Mon Sep 17 00:00:00 2001 From: Birk Johansson Date: Fri, 16 Feb 2024 17:24:11 +0100 Subject: [PATCH] feat: show version download count (#739) --- client/src/components/Versions/Versions.js | 5 +++-- .../Versions/VersionsTable/VersionsTable.js | 20 +++++++++++++++---- .../UserApp/VersionsCard/VersionsCard.js | 1 + 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/client/src/components/Versions/Versions.js b/client/src/components/Versions/Versions.js index e9e125808..50556487c 100644 --- a/client/src/components/Versions/Versions.js +++ b/client/src/components/Versions/Versions.js @@ -10,7 +10,7 @@ import { usePagination, useQuery } from 'src/api' const { defaultAppChannel } = config.ui -const useChannels = appId => { +const useChannels = (appId) => { const [availableChannels, setAvailableChannels] = useState([ defaultAppChannel, ]) @@ -38,7 +38,7 @@ const useChannels = appId => { return { availableChannels, channelsFilter, setChannelsFilter } } -const Versions = ({ appId, renderDeleteVersionButton }) => { +const Versions = ({ appId, renderDeleteVersionButton, showDownloadCount }) => { const { availableChannels, channelsFilter, setChannelsFilter } = useChannels(appId) @@ -102,6 +102,7 @@ const Versions = ({ appId, renderDeleteVersionButton }) => { ) : ( diff --git a/client/src/components/Versions/VersionsTable/VersionsTable.js b/client/src/components/Versions/VersionsTable/VersionsTable.js index b107de46e..74d30e25d 100644 --- a/client/src/components/Versions/VersionsTable/VersionsTable.js +++ b/client/src/components/Versions/VersionsTable/VersionsTable.js @@ -17,7 +17,7 @@ import { renderDhisVersionsCompatibility } from 'src/lib/render-dhis-versions-co const { appChannelToDisplayName } = config.ui -const useCreateGetDownloadUrl = url => { +const useCreateGetDownloadUrl = (url) => { const [token, setToken] = useState() const { getAccessTokenSilently } = useAuth0() @@ -30,12 +30,16 @@ const useCreateGetDownloadUrl = url => { }, [url, getAccessTokenSilently]) return useCallback( - url => (token ? url.concat(`?token=${token}`) : url), + (url) => (token ? url.concat(`?token=${token}`) : url), [token] ) } -const VersionsTable = ({ versions, renderDeleteVersionButton }) => { +const VersionsTable = ({ + versions, + renderDeleteVersionButton, + showDownloadCount, +}) => { const getDownloadUrl = useCreateGetDownloadUrl() return ( @@ -46,11 +50,14 @@ const VersionsTable = ({ versions, renderDeleteVersionButton }) => { Channel DHIS2 version compatibility Upload date + {showDownloadCount && ( + Downloads + )} - {versions.map(version => ( + {versions.map((version) => ( {version.version} @@ -69,6 +76,11 @@ const VersionsTable = ({ versions, renderDeleteVersionButton }) => { ).toLocaleDateString()} + {showDownloadCount && ( + + {version.downloadCount} + + )} { appId={app.id} versions={versions} renderDeleteVersionButton={renderDeleteVersionButton} + showDownloadCount={true} />