Skip to content

Commit

Permalink
Merge pull request #1558 from nextstrain/fix/dataset-changelog-url
Browse files Browse the repository at this point in the history
fix: dataset changelog url in update notification widget
  • Loading branch information
ivan-aksamentov authored Dec 16, 2024
2 parents c95471b + 652852d commit 11bb4ec
Showing 1 changed file with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { isNil } from 'lodash'
import React, { useCallback } from 'react'
import path from 'path'
import React, { useCallback, useMemo } from 'react'
import { Button, Col, Row, UncontrolledAlert } from 'reactstrap'
import { useRecoilState, useSetRecoilState } from 'recoil'
import { LinkExternal } from 'src/components/Link/LinkExternal'
Expand All @@ -17,6 +18,19 @@ export function DatasetCurrentUpdateNotification() {
setDatasetUpdated(undefined)
}, [datasetUpdated, setDatasetCurrent, setDatasetUpdated])

const changelogUrl = useMemo(() => {
if (
isNil(datasetUpdated) ||
isNil(datasetUpdated.path) ||
isNil(datasetUpdated.files) ||
isNil(datasetUpdated.files.changelog)
) {
return undefined
}
const filename = path.basename(datasetUpdated.files.changelog)
return `https://github.com/nextstrain/nextclade_data/blob/release/data/${datasetUpdated.path}/${filename}`
}, [datasetUpdated])

if (isNil(datasetUpdated)) {
return null
}
Expand All @@ -27,11 +41,11 @@ export function DatasetCurrentUpdateNotification() {
<UncontrolledAlert closeClassName="d-none" fade={false} color="info" className="mx-1 py-2 px-2 d-flex w-100">
<AlertTextWrapper>
<p className="my-0">{t('A new version of this dataset is available.')}</p>
<p className="my-0">
<LinkExternal href="https://github.com/nextstrain/nextclade_data/blob/release/CHANGELOG.md">
{"What's new?"}
</LinkExternal>
</p>
{datasetUpdated.files?.changelog && (
<p className="my-0">
<LinkExternal href={changelogUrl}>{t("What's new?")}</LinkExternal>
</p>
)}
</AlertTextWrapper>

<AlertButtonWrapper>
Expand Down

0 comments on commit 11bb4ec

Please sign in to comment.