Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d0081a9

Browse files
committed
fix(DHIS2-19851): ensure that stable versions - not development - are shown as latest version
1 parent ac2e27c commit d0081a9

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

client/src/pages/AppView/AppView.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ const AppView = ({ match }) => {
211211
const logoSrc = app.images.find((img) => img.logo)?.imageUrl
212212
const screenshots = app.images.filter((img) => !img.logo)
213213
const versions = app.versions.sort((a, b) => b.created - a.created)
214-
const latestVersion = versions[0]
214+
const stableVersions = versions.filter((v) => v.channel === 'stable')
215+
const latestVersion = stableVersions?.[0] ?? versions[0]
215216

216217
const selectTab = (tabName) => () => {
217218
history.push('?tab=' + tabName)
@@ -263,7 +264,10 @@ const AppView = ({ match }) => {
263264
latestVersion={latestVersion}
264265
sourceUrl={app.sourceUrl}
265266
/>
266-
<LatestUpdates changelog={changelog?.data} />
267+
<LatestUpdates
268+
versions={versions}
269+
changelog={changelog?.data}
270+
/>
267271
</>
268272
)}
269273

client/src/pages/AppView/LatestUpdates.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
1+
import PropTypes from 'prop-types'
12
import ReactMarkdown from 'react-markdown'
23
import { useHistory } from 'react-router-dom'
34
import styles from './LatestUpdates.module.css'
45

5-
export const LatestUpdates = ({ changelog }) => {
6+
export const LatestUpdates = ({ versions, changelog }) => {
67
const history = useHistory()
78
if (!changelog) {
89
return null
910
}
11+
12+
const versionsToShow = changelog.filter(
13+
({ version }) =>
14+
!!versions.find(
15+
(v) => v.version === version && v.channel === 'stable'
16+
)
17+
)
18+
19+
if (versionsToShow?.length === 0) {
20+
return null
21+
}
22+
1023
return (
1124
<div className={styles.latestUpdatesWrapper}>
1225
<div className={styles.latestUpdates}>
1326
<h2 className={styles.latestUpdatesHeader}>Latest updates:</h2>
1427

1528
<ol className={styles.versionList}>
16-
{changelog?.slice(0, 3).map((version, i) => {
29+
{versionsToShow?.slice(0, 3).map((version, i) => {
1730
return (
1831
<li key={version.version}>
1932
<h3
@@ -44,3 +57,8 @@ export const LatestUpdates = ({ changelog }) => {
4457
</div>
4558
)
4659
}
60+
61+
LatestUpdates.propTypes = {
62+
changelog: PropTypes.object,
63+
versions: PropTypes.array,
64+
}

server/src/models/v1/out/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const def = Joi.object().keys({
4040
hasPlugin: Joi.boolean().allow(null, false),
4141

4242
// only indicating if there is a changelog or not here
43-
// to avoid addding a masssive changelog to the payload
43+
// to avoid adding a massive changelog to the payload
4444
hasChangelog: Joi.boolean().allow(null, false),
4545

4646
pluginType: Joi.string().allow(null),

0 commit comments

Comments
 (0)