From cb29172e635147760843dfb37eeca6f613c891fd Mon Sep 17 00:00:00 2001 From: Cheng Shi Date: Fri, 1 Nov 2024 23:36:08 -0400 Subject: [PATCH 01/10] fix: change the hard-coded part and format of date --- .../file-info-cell/file-info-data/FileDate.tsx | 7 ++++--- src/sections/file/file-embargo/FileEmbargoDate.tsx | 8 +++++--- src/sections/file/file-metadata/FileMetadata.tsx | 13 +++++++------ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/sections/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/FileDate.tsx b/src/sections/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/FileDate.tsx index b160cfe86..b79d8a6a8 100644 --- a/src/sections/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/FileDate.tsx +++ b/src/sections/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/FileDate.tsx @@ -2,14 +2,15 @@ import { FileDate as FileDateModel } from '../../../../../../../files/domain/mod import { useTranslation } from 'react-i18next' import { DateHelper } from '../../../../../../../shared/helpers/DateHelper' -// TODO: use time tag with dateTime attr https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time - export function FileDate({ date }: { date: FileDateModel }) { const { t } = useTranslation('files') return (
- {t(`table.date.${date.type}`)} {DateHelper.toDisplayFormat(date.date)} +
) diff --git a/src/sections/file/file-embargo/FileEmbargoDate.tsx b/src/sections/file/file-embargo/FileEmbargoDate.tsx index 6a238851c..d2a36965a 100644 --- a/src/sections/file/file-embargo/FileEmbargoDate.tsx +++ b/src/sections/file/file-embargo/FileEmbargoDate.tsx @@ -26,9 +26,11 @@ export function FileEmbargoDate({
{t(embargoTypeOfDate(embargo.isActive, datasetPublishingStatus))}{' '} - {format === 'YYYY-MM-DD' - ? DateHelper.toDisplayFormatYYYYMMDD(embargo.dateAvailable) - : DateHelper.toDisplayFormat(embargo.dateAvailable)} +
) diff --git a/src/sections/file/file-metadata/FileMetadata.tsx b/src/sections/file/file-metadata/FileMetadata.tsx index 88f079926..4ecd9edf5 100644 --- a/src/sections/file/file-metadata/FileMetadata.tsx +++ b/src/sections/file/file-metadata/FileMetadata.tsx @@ -97,16 +97,18 @@ export function FileMetadata({ {t('metadata.fields.depositDate')} - {/* TODO: use time tag with dateTime attr https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time */} - {DateHelper.toDisplayFormatYYYYMMDD(metadata.depositDate)} + + + {metadata.publicationDate && ( {t('metadata.fields.metadataReleaseDate')} - {/* TODO: use time tag with dateTime attr https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time */} - {DateHelper.toDisplayFormatYYYYMMDD(metadata.publicationDate)} + + + )} {(metadata.publicationDate || metadata.embargo) && ( @@ -114,7 +116,6 @@ export function FileMetadata({ {t('metadata.fields.publicationDate')} - {/* TODO: use time tag with dateTime attr https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time */} {metadata.embargo ? ( ) : ( - DateHelper.toDisplayFormatYYYYMMDD(metadata.publicationDate) + )} From 1b827c0deff13d3c6f6f5f49c9fc4ca4947abcd4 Mon Sep 17 00:00:00 2001 From: Cheng Shi Date: Sat, 2 Nov 2024 11:21:06 -0400 Subject: [PATCH 02/10] test: change the testcases to match new changes --- .../file-info-data/FileDate.tsx | 5 +- .../file/file-embargo/FileEmbargoDate.tsx | 6 +- .../file-embargo/FileEmbargoDate.spec.tsx | 23 +++---- .../file/file-metadata/FileMetadata.spec.tsx | 28 ++++---- .../e2e/sections/dataset/Dataset.spec.tsx | 66 +++++++------------ 5 files changed, 53 insertions(+), 75 deletions(-) diff --git a/src/sections/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/FileDate.tsx b/src/sections/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/FileDate.tsx index b79d8a6a8..1aa10a0a3 100644 --- a/src/sections/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/FileDate.tsx +++ b/src/sections/dataset/dataset-files/files-table/file-info/file-info-cell/file-info-data/FileDate.tsx @@ -7,10 +7,7 @@ export function FileDate({ date }: { date: FileDateModel }) { return (
- + {t(`table.date.${date.type}`)}
) diff --git a/src/sections/file/file-embargo/FileEmbargoDate.tsx b/src/sections/file/file-embargo/FileEmbargoDate.tsx index d2a36965a..6bbbcc818 100644 --- a/src/sections/file/file-embargo/FileEmbargoDate.tsx +++ b/src/sections/file/file-embargo/FileEmbargoDate.tsx @@ -12,7 +12,7 @@ interface FileEmbargoDateProps { export function FileEmbargoDate({ embargo, datasetPublishingStatus, - format = 'short' + format = 'YYYY-MM-DD' }: FileEmbargoDateProps) { const { t } = useTranslation('files') @@ -20,13 +20,11 @@ export function FileEmbargoDate({ return <> } - // TODO: use time tag with dateTime attr https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time - return (
{t(embargoTypeOfDate(embargo.isActive, datasetPublishingStatus))}{' '} -