From 652852dbb8f41bb5b04ba37c38556cc043e72d69 Mon Sep 17 00:00:00 2001 From: ivan-aksamentov Date: Mon, 16 Dec 2024 06:59:20 +0100 Subject: [PATCH] fix: dataset changelog url in update notification widget Resolves https://github.com/nextstrain/nextclade/issues/1557 --- .../Main/DatasetCurrentUpdateNotification.tsx | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/packages/nextclade-web/src/components/Main/DatasetCurrentUpdateNotification.tsx b/packages/nextclade-web/src/components/Main/DatasetCurrentUpdateNotification.tsx index 75f30bc79..23f0abf5e 100644 --- a/packages/nextclade-web/src/components/Main/DatasetCurrentUpdateNotification.tsx +++ b/packages/nextclade-web/src/components/Main/DatasetCurrentUpdateNotification.tsx @@ -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' @@ -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 } @@ -27,11 +41,11 @@ export function DatasetCurrentUpdateNotification() {

{t('A new version of this dataset is available.')}

-

- - {"What's new?"} - -

+ {datasetUpdated.files?.changelog && ( +

+ {t("What's new?")} +

+ )}