Skip to content

Commit

Permalink
fix: update latest updates text
Browse files Browse the repository at this point in the history
  • Loading branch information
kabaros committed Feb 5, 2025
1 parent b96db8b commit 6e8160a
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 54 deletions.
12 changes: 7 additions & 5 deletions client/src/components/Versions/VersionsTable/VersionsTable.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import ReactMarkdown from 'react-markdown'
import { useAuth0 } from '@auth0/auth0-react'
import { Divider } from '@dhis2/ui'
import PropTypes from 'prop-types'
import { useCallback, useEffect, useState } from 'react'
import ReactMarkdown from 'react-markdown'
import styles from './VersionsTable.module.css'
import config from 'config'
import { renderDhisVersionsCompatibility } from 'src/lib/render-dhis-versions-compatibility'
Expand All @@ -11,15 +11,17 @@ const { appChannelToDisplayName } = config.ui

const useCreateGetDownloadUrl = (url) => {
const [token, setToken] = useState()
const { getAccessTokenSilently } = useAuth0()
const { getAccessTokenSilently, isAuthenticated } = useAuth0()

useEffect(() => {
const getToken = async () => {
const token = await getAccessTokenSilently()
setToken(token)
if (isAuthenticated) {
const token = await getAccessTokenSilently()
setToken(token)
}
}
getToken()
}, [url, getAccessTokenSilently])
}, [url, getAccessTokenSilently, isAuthenticated])

return useCallback(
(url) => (token ? url.concat(`?token=${token}`) : url),
Expand Down
64 changes: 21 additions & 43 deletions client/src/pages/AppView/LatestUpdates.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Button } from '@dhis2/ui'
import ReactMarkdown from 'react-markdown'
import { useHistory } from 'react-router-dom'
import { getFormattedChangeType } from '../../utils/changelog'
import styles from './LatestUpdates.module.css'

export const LatestUpdates = ({ changelog }) => {
Expand All @@ -13,47 +12,26 @@ export const LatestUpdates = ({ changelog }) => {
<div className={styles.latestUpdates}>
<h2 className={styles.latestUpdatesHeader}>Latest updates:</h2>

{changelog?.slice(0, 3).map((version, i) => {
return (
<div key={version.version}>
<h3 className={styles.latestUpdatesVersionHeading}>
{version.version}
</h3>
{version.changeSummary.map((change) => {
return (
// todo: find a better key than i
<div key={i}>
{getFormattedChangeType(change)}
{change.isTranslation ? (
<span
className={styles.translation}
>
Translations sync
</span>
) : (
change.text
)}
{change.link ? (
<>
{' '}
(
<a
className={styles.link}
rel="noreferrer"
target="_blank"
href={change.link}
>
{'link'}
</a>
)
</>
) : null}
</div>
)
})}
</div>
)
})}
<ol className={styles.versionList}>
{changelog?.slice(0, 3).map((version, i) => {
return (
<li key={version.version}>
<h3
className={
styles.latestUpdatesVersionHeading
}
>
{version.version}
</h3>
<div className={styles.changeSummary}>
<ReactMarkdown>
{version.rawChangeSummary}
</ReactMarkdown>
</div>
</li>
)
})}
</ol>
</div>
<div className={styles.showAllLink}>
<span
Expand Down
27 changes: 21 additions & 6 deletions client/src/pages/AppView/LatestUpdates.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@
margin: 0;
}

.latestUpdatesVersionHeading {
font-size: 1em;
margin-bottom: var(--spacers-dp4);
font-weight: bold;
}

.showAllLink {
margin-top: var(--spacers-dp8);
text-decoration: underline;
Expand All @@ -26,3 +20,24 @@
.showAllLink:focus {
text-decoration: none;
}

.versionList {
list-style: none;
padding: 0;
font-size: 0.8rem;
}

.latestUpdatesVersionHeading {
font-size: 1.1em;
font-weight: bold;
}

.changeSummary :global(ul) {
list-style: disc;
padding-inline-start: var(--spacers-dp24);
}

.changeSummary :global(h3) {
font-size: 0.9em;
margin-bottom: 0.5em;
}

0 comments on commit 6e8160a

Please sign in to comment.