Skip to content

Commit

Permalink
fix: sort app versions in descending order and remove button text und…
Browse files Browse the repository at this point in the history
…erline (#315)

* fix: remove text decoration from download link

* fix: sort app versions in descending order
  • Loading branch information
mediremi authored Sep 7, 2021
1 parent 1f8e09a commit 946a795
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 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-09-07T11:04:30.998Z\n"
"PO-Revision-Date: 2021-09-07T11:04:30.998Z\n"
"POT-Creation-Date: 2021-09-07T11:19:00.521Z\n"
"PO-Revision-Date: 2021-09-07T11:19:00.521Z\n"

msgid "Version {{version}} installed"
msgstr "Version {{version}} installed"
Expand Down
14 changes: 7 additions & 7 deletions src/components/AppDetails/AppDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import { Versions } from './Versions'

const Metadata = ({ installedVersion, versions }) => {
const relativeTime = datetime => moment(datetime).fromNow()
versions = versions.sort((a, b) => a.created - b.created)
const latestVersion = getLatestVersion(versions)?.version
const firstPublishedVersion = versions[versions.length - 1]
const lastPublishedVersion = versions[0]

return (
<ul className={styles.metadataList}>
Expand All @@ -29,14 +30,12 @@ const Metadata = ({ installedVersion, versions }) => {
</li>
<li className={styles.metadataItem}>
{i18n.t('Last updated {{relativeTime}}', {
relativeTime: relativeTime(
versions[versions.length - 1].created
),
relativeTime: relativeTime(lastPublishedVersion.created),
})}
</li>
<li className={styles.metadataItem}>
{i18n.t('First published {{relativeTime}}', {
relativeTime: relativeTime(versions[0].created),
relativeTime: relativeTime(firstPublishedVersion.created),
})}
</li>
</ul>
Expand Down Expand Up @@ -104,6 +103,7 @@ export const AppDetails = ({
const screenshots = appHubApp?.images
.filter(i => !i.logo)
.map(i => i.imageUrl)
const versions = appHubApp?.versions.sort((a, b) => b.created - a.created)

return (
<Card className={styles.appCard}>
Expand Down Expand Up @@ -153,7 +153,7 @@ export const AppDetails = ({
</h2>
<Metadata
installedVersion={installedApp.version}
versions={appHubApp.versions}
versions={versions}
/>
</div>
)}
Expand Down Expand Up @@ -181,7 +181,7 @@ export const AppDetails = ({
</h2>
<Versions
installedVersion={installedApp?.version}
versions={appHubApp.versions}
versions={versions}
onVersionInstall={onVersionInstall}
/>
</section>
Expand Down
4 changes: 4 additions & 0 deletions src/components/AppDetails/AppDetails.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,7 @@
.installBtn {
margin-right: var(--spacers-dp8);
}

.downloadLink {
text-decoration: none;
}
6 changes: 5 additions & 1 deletion src/components/AppDetails/Versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ const VersionsTable = ({ installedVersion, versions, onVersionInstall }) => (
? i18n.t('Installed')
: i18n.t('Install')}
</Button>
<a download href={version.downloadUrl}>
<a
download
href={version.downloadUrl}
className={styles.downloadLink}
>
<Button small secondary>
{i18n.t('Download')}
</Button>
Expand Down

0 comments on commit 946a795

Please sign in to comment.