From 27b5b86a214ed621f1183f7c81308502e933d60d Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 13:36:17 -0400 Subject: [PATCH 01/32] chore: don't require authors/dates for papers --- src/js/components/Provenance/Tables/PublicationsTable.tsx | 4 ++-- src/js/types/provenance.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/js/components/Provenance/Tables/PublicationsTable.tsx b/src/js/components/Provenance/Tables/PublicationsTable.tsx index 59a071e7..a8d6a2c3 100644 --- a/src/js/components/Provenance/Tables/PublicationsTable.tsx +++ b/src/js/components/Provenance/Tables/PublicationsTable.tsx @@ -36,7 +36,7 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { title: td('Authors'), dataIndex: 'authors', render: (_, { authors }) => - authors.map((author, i) => ( + (authors ?? []).map((author, i) => ( {author} @@ -46,7 +46,7 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { title: td('Dates'), dataIndex: 'dates', render: (_, { dates }) => - dates.map((date, i) => ( + (dates ?? []).map((date, i) => ( {date} diff --git a/src/js/types/provenance.ts b/src/js/types/provenance.ts index c44bfef3..20f4f068 100644 --- a/src/js/types/provenance.ts +++ b/src/js/types/provenance.ts @@ -83,8 +83,8 @@ export interface License { } export interface PrimaryPublication { - authors: string[]; - dates: string[]; + authors?: string[]; + dates?: string[]; identifier: Identifier; publicationVenue: string; title: string; From 796d27c5d189e573bfaf50030f63f606d61b3627 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 13:42:04 -0400 Subject: [PATCH 02/32] lint: make constant regex var name uppercase --- src/js/components/Util/LinkIfUrl.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/components/Util/LinkIfUrl.js b/src/js/components/Util/LinkIfUrl.js index a05bf25e..d693bffd 100644 --- a/src/js/components/Util/LinkIfUrl.js +++ b/src/js/components/Util/LinkIfUrl.js @@ -14,11 +14,11 @@ import { Typography } from 'antd'; + repeated at least once $ until the end of the string */ -const url_regex = /^(http|https):\/\/[^ "]+$/; +const URL_REGEX = /^(http|https):\/\/[^ "]+$/; // Renders text as link if the text provided is a valid url. const LinkIfUrl = ({ text }) => { - if (text.match(url_regex)) { + if (text.match(URL_REGEX)) { return ( {text} From af9803aa3e9ff3aad822f866f7b1592dcc453380 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 13:43:45 -0400 Subject: [PATCH 03/32] feat: be more intelligent about DOIs in provenance table --- .../Provenance/Tables/PublicationsTable.tsx | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/js/components/Provenance/Tables/PublicationsTable.tsx b/src/js/components/Provenance/Tables/PublicationsTable.tsx index a8d6a2c3..f72f27fa 100644 --- a/src/js/components/Provenance/Tables/PublicationsTable.tsx +++ b/src/js/components/Provenance/Tables/PublicationsTable.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { ReactNode } from 'react'; import { Tag, Typography } from 'antd'; import BaseProvenanceTable from './BaseProvenanceTable'; @@ -6,6 +6,15 @@ import LinkIfUrl from '../../Util/LinkIfUrl'; import { useTranslationCustom, useTranslationDefault } from '@/hooks'; import { ProvenanceStoreDataset } from '@/types/provenance'; +const DOI_REGEX = /^10.\d{4,9}\/[-._;()/:A-Z0-9]+$/i; +const isDOI = (s: string) => s.match(DOI_REGEX); + +const DOILink = ({ doi, children }: { doi: string; children?: ReactNode }) => ( + + {children ?? doi} + +); + const PublicationsTable = ({ publications }: PublicationsTableProps) => { const t = useTranslationCustom(); const td = useTranslationDefault(); @@ -18,14 +27,8 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { title: td('Title'), dataIndex: 'title', - render: (_, { title, identifier }) => - identifier.identifier === '' ? ( - t(title) - ) : ( - - {t(title)} - - ), + render: (_, { title, identifier: { identifier } }) => + isDOI(identifier) ? {t(title)} : t(title), }, { title: td('Publication Venue'), @@ -55,12 +58,13 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { { title: td('Identifier'), dataIndex: 'identifier.identifier', - render: (_, { identifier }) => , + render: (_, { identifier: { identifier } }) => + isDOI(identifier) ? : , }, { title: td('Identifier Source'), dataIndex: 'identifier.identifierSource', - render: (_, { identifier }) => t(identifier.identifierSource), + render: (_, { identifier: { identifierSource } }) => t(identifierSource), }, ]} /> From 927a57129267840213cfaba061be9d82381ed76d Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 13:47:16 -0400 Subject: [PATCH 04/32] refact: memoize columns for provenance publications --- .../Provenance/Tables/PublicationsTable.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/js/components/Provenance/Tables/PublicationsTable.tsx b/src/js/components/Provenance/Tables/PublicationsTable.tsx index f72f27fa..4abaa296 100644 --- a/src/js/components/Provenance/Tables/PublicationsTable.tsx +++ b/src/js/components/Provenance/Tables/PublicationsTable.tsx @@ -1,10 +1,11 @@ -import React, { ReactNode } from 'react'; +import React, { ReactNode, useMemo } from 'react'; import { Tag, Typography } from 'antd'; import BaseProvenanceTable from './BaseProvenanceTable'; import LinkIfUrl from '../../Util/LinkIfUrl'; import { useTranslationCustom, useTranslationDefault } from '@/hooks'; -import { ProvenanceStoreDataset } from '@/types/provenance'; +import { PrimaryPublication, ProvenanceStoreDataset } from '@/types/provenance'; +import { ColumnsType } from 'antd/es/table'; const DOI_REGEX = /^10.\d{4,9}\/[-._;()/:A-Z0-9]+$/i; const isDOI = (s: string) => s.match(DOI_REGEX); @@ -19,10 +20,9 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { const t = useTranslationCustom(); const td = useTranslationDefault(); - return ( - + [ { title: td('Title'), dataIndex: 'title', @@ -66,9 +66,11 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { dataIndex: 'identifier.identifierSource', render: (_, { identifier: { identifierSource } }) => t(identifierSource), }, - ]} - /> + ] as ColumnsType, + [td] ); + + return ; }; export interface PublicationsTableProps { From d32a4e9c3b1abaa92afdde951fb41d0e5c8f79f8 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 14:10:29 -0400 Subject: [PATCH 05/32] style: don't render extra properties as tags --- .../components/Provenance/Tables/ExtraPropertiesTable.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/js/components/Provenance/Tables/ExtraPropertiesTable.tsx b/src/js/components/Provenance/Tables/ExtraPropertiesTable.tsx index 2032193c..ae1ac02e 100644 --- a/src/js/components/Provenance/Tables/ExtraPropertiesTable.tsx +++ b/src/js/components/Provenance/Tables/ExtraPropertiesTable.tsx @@ -20,9 +20,10 @@ const ExtraPropertiesTable = ({ extraProperties }: ExtraPropertiesTableProps) => dataIndex: 'values', render: (_, { values }) => values.map((v, i) => ( - - - + <> + + {" "} + )), }, ]} From 3f22087e044e3b4ce816b26dffe1eab388e180b9 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 14:13:31 -0400 Subject: [PATCH 06/32] feat: fix annotation type, show pub author list under title --- .../Provenance/Tables/PublicationsTable.tsx | 52 ++++++++++++------- src/js/types/provenance.ts | 30 +++++++---- .../locales/en/default_translation_en.json | 2 + .../locales/fr/default_translation_fr.json | 2 + 4 files changed, 58 insertions(+), 28 deletions(-) diff --git a/src/js/components/Provenance/Tables/PublicationsTable.tsx b/src/js/components/Provenance/Tables/PublicationsTable.tsx index 4abaa296..8cdd94e5 100644 --- a/src/js/components/Provenance/Tables/PublicationsTable.tsx +++ b/src/js/components/Provenance/Tables/PublicationsTable.tsx @@ -1,11 +1,12 @@ import React, { ReactNode, useMemo } from 'react'; + import { Tag, Typography } from 'antd'; +import { ColumnsType } from 'antd/es/table'; import BaseProvenanceTable from './BaseProvenanceTable'; import LinkIfUrl from '../../Util/LinkIfUrl'; import { useTranslationCustom, useTranslationDefault } from '@/hooks'; -import { PrimaryPublication, ProvenanceStoreDataset } from '@/types/provenance'; -import { ColumnsType } from 'antd/es/table'; +import { Person, PrimaryPublication, ProvenanceStoreDataset } from '@/types/provenance'; const DOI_REGEX = /^10.\d{4,9}\/[-._;()/:A-Z0-9]+$/i; const isDOI = (s: string) => s.match(DOI_REGEX); @@ -16,6 +17,19 @@ const DOILink = ({ doi, children }: { doi: string; children?: ReactNode }) => ( ); +const formatAuthorList = (authors: Person[]): string => { + const fullNames = authors.map((a) => a.fullName); + if (fullNames.length === 0) { + return ''; + } else if (fullNames.length === 1) { + return `${fullNames[0]}.`; + } else if (fullNames.length === 2) { + return `${fullNames.join(' and ')}.`; + } else { + return `${fullNames.slice(0, -1).join(', ')}, and ${fullNames.at(-1)}.`; + } +}; + const PublicationsTable = ({ publications }: PublicationsTableProps) => { const t = useTranslationCustom(); const td = useTranslationDefault(); @@ -24,11 +38,23 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { () => [ { - title: td('Title'), - dataIndex: 'title', + title: td('Publication'), + key: 'publication', - render: (_, { title, identifier: { identifier } }) => - isDOI(identifier) ? {t(title)} : t(title), + render: (_, { title, identifier: { identifier }, authors }) => { + const formattedTitle = `${t(title)}${title.endsWith('.') ? '' : '.'}`; + return ( + <> + {isDOI(identifier) ? {formattedTitle} : formattedTitle} + {authors ? ( + <> +
+ {formatAuthorList(authors)} + + ) : null} + + ); + }, }, { title: td('Publication Venue'), @@ -36,22 +62,12 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { render: (text) => t(text), }, { - title: td('Authors'), - dataIndex: 'authors', - render: (_, { authors }) => - (authors ?? []).map((author, i) => ( - - {author} - - )), - }, - { - title: td('Dates'), + title: td('Date'), dataIndex: 'dates', render: (_, { dates }) => (dates ?? []).map((date, i) => ( - {date} + {date.date} )), }, diff --git a/src/js/types/provenance.ts b/src/js/types/provenance.ts index 20f4f068..d3f7e52b 100644 --- a/src/js/types/provenance.ts +++ b/src/js/types/provenance.ts @@ -21,7 +21,7 @@ export interface DatsFile { distributions: Distribution[]; extraProperties: ExtraProperty[]; isAbout: IsAbout[]; - keywords: Keyword[]; + keywords: Annotation[]; licenses: License[]; primaryPublications: PrimaryPublication[]; privacy: string; @@ -43,29 +43,30 @@ export interface Funder { export interface Creator { name: string; - roles: Keyword[]; + roles: Annotation[]; abbreviation?: string; } -export interface Keyword { - value: string; +export interface Annotation { + value: string | number; + valueIRI?: string; } export interface Distribution { access: Access; formats: string[]; size: number; - unit: Keyword; + unit: Annotation; } export interface Access { - authorizations: Keyword[]; + authorizations: Annotation[]; landingPage: string; } export interface ExtraProperty { category: string; - values: Keyword[]; + values: Annotation[]; } export interface IsAbout { @@ -82,9 +83,18 @@ export interface License { name: string; } +export interface Person { + fullName: string; +} + +export interface DateInfo { + date: string; + type?: Annotation; +} + export interface PrimaryPublication { - authors?: string[]; - dates?: string[]; + authors?: Person[]; + dates?: DateInfo[]; identifier: Identifier; publicationVenue: string; title: string; @@ -96,5 +106,5 @@ export interface SpatialCoverage { } export interface Type { - information: Keyword; + information: Annotation; } diff --git a/src/public/locales/en/default_translation_en.json b/src/public/locales/en/default_translation_en.json index 849a1a71..1a9ea182 100644 --- a/src/public/locales/en/default_translation_en.json +++ b/src/public/locales/en/default_translation_en.json @@ -18,6 +18,7 @@ "Distributions": "Distributions", "Is About": "Is About", "Primary Publications": "Primary Publications", + "Publication": "Publication", "Acknowledges": "Acknowledges", "Spatial Coverage": "Spatial Coverage", "Extra Properties": "Extra Properties", @@ -38,6 +39,7 @@ "Title": "Title", "Publication Venue": "Publication Venue", "Authors": "Authors", + "Date": "Date", "Dates": "Dates", "Description": "Description", "Manage Charts": "Manage Charts", diff --git a/src/public/locales/fr/default_translation_fr.json b/src/public/locales/fr/default_translation_fr.json index ebe0c518..002c79a4 100644 --- a/src/public/locales/fr/default_translation_fr.json +++ b/src/public/locales/fr/default_translation_fr.json @@ -18,6 +18,7 @@ "Distributions": "Distributions", "Is About": "Sujet", "Primary Publications": "Publications primaires", + "Publication": "Publication", "Acknowledges": "Reconnaît", "Spatial Coverage": "Couverture spatiale", "Extra Properties": "Propriétés supplémentaires", @@ -38,6 +39,7 @@ "Title": "Titre", "Publication Venue": "Lieu de publication", "Authors": "Auteurs", + "Date": "Date", "Dates": "Dates", "Description": "Description", "Manage Charts": "Gestion des tableaux", From 6d021729371854bc9cec1bb21f2c16bc506f657a Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 14:13:46 -0400 Subject: [PATCH 07/32] refact: memoize columns for extra props table --- .../Tables/ExtraPropertiesTable.tsx | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/js/components/Provenance/Tables/ExtraPropertiesTable.tsx b/src/js/components/Provenance/Tables/ExtraPropertiesTable.tsx index ae1ac02e..9f6013e6 100644 --- a/src/js/components/Provenance/Tables/ExtraPropertiesTable.tsx +++ b/src/js/components/Provenance/Tables/ExtraPropertiesTable.tsx @@ -1,19 +1,19 @@ -import React from 'react'; -import { Tag } from 'antd'; +import React, { useMemo } from 'react'; + +import { ColumnsType } from 'antd/es/table'; import BaseProvenanceTable from '@/components/Provenance/Tables/BaseProvenanceTable'; import LinkIfUrl from '../../Util/LinkIfUrl'; import { useTranslationCustom, useTranslationDefault } from '@/hooks'; -import { ProvenanceStoreDataset } from '@/types/provenance'; +import { ExtraProperty, ProvenanceStoreDataset } from '@/types/provenance'; const ExtraPropertiesTable = ({ extraProperties }: ExtraPropertiesTableProps) => { const t = useTranslationCustom(); const td = useTranslationDefault(); - return ( - + [ { title: td('Category'), dataIndex: 'category', render: (text) => t(text) }, { title: td('Values'), @@ -21,14 +21,15 @@ const ExtraPropertiesTable = ({ extraProperties }: ExtraPropertiesTableProps) => render: (_, { values }) => values.map((v, i) => ( <> - - {" "} + {' '} )), }, - ]} - /> + ] as ColumnsType, + [td] ); + + return ; }; export interface ExtraPropertiesTableProps { From c0e23b27336b844cb45737c443142726fde2f7aa Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 14:38:25 -0400 Subject: [PATCH 08/32] fix: type error --- src/js/components/Provenance/DatasetProvenance.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/components/Provenance/DatasetProvenance.tsx b/src/js/components/Provenance/DatasetProvenance.tsx index d1ed9f2a..022cf557 100644 --- a/src/js/components/Provenance/DatasetProvenance.tsx +++ b/src/js/components/Provenance/DatasetProvenance.tsx @@ -57,7 +57,7 @@ const DatasetProvenance = ({ metadata, loading }: DatasetProvenanceProps) => { }> {metadata.keywords.map((keyword, i) => ( - {t(keyword.value)} + {t(keyword.value.toString())} ))} From 9bfcf5cf68f8020aff0eea251503a76d86c3bf8f Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 14:39:05 -0400 Subject: [PATCH 09/32] fix: more type errors --- src/js/components/Provenance/Tables/CreatedByTable.tsx | 2 +- src/js/components/Provenance/Tables/DistributionsTable.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/components/Provenance/Tables/CreatedByTable.tsx b/src/js/components/Provenance/Tables/CreatedByTable.tsx index 30ddb65e..7a837d55 100644 --- a/src/js/components/Provenance/Tables/CreatedByTable.tsx +++ b/src/js/components/Provenance/Tables/CreatedByTable.tsx @@ -33,7 +33,7 @@ const CreatedByTable = ({ creators }: CreatedByTableProps) => { roles && roles.map((r, i) => ( - {t(r.value)} + {t(r.value.toString())} )), }, diff --git a/src/js/components/Provenance/Tables/DistributionsTable.tsx b/src/js/components/Provenance/Tables/DistributionsTable.tsx index e87c0151..b4b9d471 100644 --- a/src/js/components/Provenance/Tables/DistributionsTable.tsx +++ b/src/js/components/Provenance/Tables/DistributionsTable.tsx @@ -27,7 +27,7 @@ const DistributionsTable = ({ distributions }: DistributionsTableProps) => { { title: td('Unit'), dataIndex: 'unit', - render: (_, { unit }) => t(unit.value), + render: (_, { unit }) => t(unit.value.toString()), }, { title: td('Access'), From abf0e90afa2d73dc7bc5fba1c73a7939b19b82b5 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 14:39:23 -0400 Subject: [PATCH 10/32] fix: one more --- src/js/components/Provenance/Tables/DistributionsTable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/components/Provenance/Tables/DistributionsTable.tsx b/src/js/components/Provenance/Tables/DistributionsTable.tsx index b4b9d471..9125a7ff 100644 --- a/src/js/components/Provenance/Tables/DistributionsTable.tsx +++ b/src/js/components/Provenance/Tables/DistributionsTable.tsx @@ -47,7 +47,7 @@ const DistributionsTable = ({ distributions }: DistributionsTableProps) => { render: (_, { access }) => access.authorizations.map((a, i) => ( - {t(a.value)} + {t(a.value.toString())} )), }, From 4434107d9b5c6d7d4cb10f17856e32097eccc106 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 14:41:20 -0400 Subject: [PATCH 11/32] refact: memoize distributions table columns --- .../Provenance/Tables/DistributionsTable.tsx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/js/components/Provenance/Tables/DistributionsTable.tsx b/src/js/components/Provenance/Tables/DistributionsTable.tsx index 9125a7ff..aff70350 100644 --- a/src/js/components/Provenance/Tables/DistributionsTable.tsx +++ b/src/js/components/Provenance/Tables/DistributionsTable.tsx @@ -1,19 +1,20 @@ -import React from 'react'; +import React, { useMemo } from 'react'; + import { Tag, Typography } from 'antd'; +import { ColumnsType } from 'antd/es/table'; const { Link } = Typography; import BaseProvenanceTable from './BaseProvenanceTable'; import { useTranslationDefault, useTranslationCustom } from '@/hooks'; -import { ProvenanceStoreDataset } from '@/types/provenance'; +import { Distribution, ProvenanceStoreDataset } from '@/types/provenance'; const DistributionsTable = ({ distributions }: DistributionsTableProps) => { const t = useTranslationCustom(); const td = useTranslationDefault(); - return ( - + [ { title: td('Formats'), dataIndex: 'formats', @@ -53,9 +54,11 @@ const DistributionsTable = ({ distributions }: DistributionsTableProps) => { }, ], }, - ]} - /> + ] as ColumnsType, + [td] ); + + return ; }; export interface DistributionsTableProps { From 54c2c519eb2cdb0a7b2dd7d6786a42769a6daf6e Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 14:47:11 -0400 Subject: [PATCH 12/32] fix: typo in component name --- .../components/Provenance/DatasetProvenance.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/js/components/Provenance/DatasetProvenance.tsx b/src/js/components/Provenance/DatasetProvenance.tsx index 022cf557..bc061f68 100644 --- a/src/js/components/Provenance/DatasetProvenance.tsx +++ b/src/js/components/Provenance/DatasetProvenance.tsx @@ -67,31 +67,31 @@ const DatasetProvenance = ({ metadata, loading }: DatasetProvenanceProps) => { {/* TableTitle has translation in it*/} {/* --- CREATED BY ---*/} - + {/* --- DISTRIBUTIONS ---*/} - + {/* --- IS ABOUT ---*/} - + {/* --- PUBLICATIONS ---*/} - + {/* --- ACKNOWLEDGES ---*/} - + {/* --- SPATIAL COVERAGE ---*/} - + {/* --- EXTRA PROPERTIES ---*/} - + {/* --- DOWNLOAD DATS --- */} @@ -108,7 +108,7 @@ export type DatasetProvenanceProps = { export default DatasetProvenance; -const TableTitleWitTranslation = ({ title }: { title: string }) => { +const TableTitleWithTranslation = ({ title }: { title: string }) => { const { t } = useTranslation(DEFAULT_TRANSLATION); return ( From 9e58382e2d4074f915e10cd31e01f2d04a1769e5 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 15:00:03 -0400 Subject: [PATCH 13/32] style: render pub authors in italics --- src/js/components/Provenance/Tables/PublicationsTable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/components/Provenance/Tables/PublicationsTable.tsx b/src/js/components/Provenance/Tables/PublicationsTable.tsx index 8cdd94e5..473150c4 100644 --- a/src/js/components/Provenance/Tables/PublicationsTable.tsx +++ b/src/js/components/Provenance/Tables/PublicationsTable.tsx @@ -49,7 +49,7 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { {authors ? ( <>
- {formatAuthorList(authors)} + {formatAuthorList(authors)} ) : null} From 7926b50abda1c305ae9bd17b73fd8799efa97b24 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 15:00:22 -0400 Subject: [PATCH 14/32] style: don't render empty tables in provenance --- .../Provenance/DatasetProvenance.tsx | 56 ++++++++++++++----- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/src/js/components/Provenance/DatasetProvenance.tsx b/src/js/components/Provenance/DatasetProvenance.tsx index bc061f68..02d8e7a2 100644 --- a/src/js/components/Provenance/DatasetProvenance.tsx +++ b/src/js/components/Provenance/DatasetProvenance.tsx @@ -67,32 +67,60 @@ const DatasetProvenance = ({ metadata, loading }: DatasetProvenanceProps) => { {/* TableTitle has translation in it*/} {/* --- CREATED BY ---*/} - - + {metadata.creators?.length ? ( + <> + + + + ) : null} {/* --- DISTRIBUTIONS ---*/} - - + {metadata.distributions?.length ? ( + <> + + + + ) : null} {/* --- IS ABOUT ---*/} - - + {metadata.isAbout?.length ? ( + <> + + + + ) : null} {/* --- PUBLICATIONS ---*/} - - + {metadata.primaryPublications?.length ? ( + <> + + + + ) : null} {/* --- ACKNOWLEDGES ---*/} - - + {metadata.acknowledges?.length ? ( + <> + + + + ) : null} {/* --- SPATIAL COVERAGE ---*/} - - + {metadata.spatialCoverage?.length ? ( + <> + + + + ) : null} {/* --- EXTRA PROPERTIES ---*/} - - + {metadata.extraProperties?.length ? ( + <> + + + + ) : null} {/* --- DOWNLOAD DATS --- */} From c37941ee4d2519282951c223ec111c11438fed70 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 15:18:55 -0400 Subject: [PATCH 15/32] lint: rm unused styling --- src/js/components/Provenance/DatasetProvenance.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/components/Provenance/DatasetProvenance.tsx b/src/js/components/Provenance/DatasetProvenance.tsx index 02d8e7a2..0022170c 100644 --- a/src/js/components/Provenance/DatasetProvenance.tsx +++ b/src/js/components/Provenance/DatasetProvenance.tsx @@ -30,7 +30,7 @@ const DatasetProvenance = ({ metadata, loading }: DatasetProvenanceProps) => { {t(metadata.version)} , ]} - style={{ borderRadius: '11px', maxWidth: '1400px' }} + style={{ borderRadius: '11px' }} loading={loading} > {/* --- DESCRIPTION ---*/} From 725929782ad83cb697b441044adaee46a1cb0625 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 15:19:14 -0400 Subject: [PATCH 16/32] chore: acknowledges -> acknowledgements --- src/js/components/Provenance/DatasetProvenance.tsx | 2 +- src/public/locales/en/default_translation_en.json | 2 +- src/public/locales/fr/default_translation_fr.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/js/components/Provenance/DatasetProvenance.tsx b/src/js/components/Provenance/DatasetProvenance.tsx index 0022170c..b4f3d0a1 100644 --- a/src/js/components/Provenance/DatasetProvenance.tsx +++ b/src/js/components/Provenance/DatasetProvenance.tsx @@ -101,7 +101,7 @@ const DatasetProvenance = ({ metadata, loading }: DatasetProvenanceProps) => { {/* --- ACKNOWLEDGES ---*/} {metadata.acknowledges?.length ? ( <> - + ) : null} diff --git a/src/public/locales/en/default_translation_en.json b/src/public/locales/en/default_translation_en.json index 1a9ea182..a78f30bd 100644 --- a/src/public/locales/en/default_translation_en.json +++ b/src/public/locales/en/default_translation_en.json @@ -19,7 +19,7 @@ "Is About": "Is About", "Primary Publications": "Primary Publications", "Publication": "Publication", - "Acknowledges": "Acknowledges", + "Acknowledgements": "Acknowledgements", "Spatial Coverage": "Spatial Coverage", "Extra Properties": "Extra Properties", "Name": "Name", diff --git a/src/public/locales/fr/default_translation_fr.json b/src/public/locales/fr/default_translation_fr.json index 002c79a4..3060cf3c 100644 --- a/src/public/locales/fr/default_translation_fr.json +++ b/src/public/locales/fr/default_translation_fr.json @@ -19,7 +19,7 @@ "Is About": "Sujet", "Primary Publications": "Publications primaires", "Publication": "Publication", - "Acknowledges": "Reconnaît", + "Acknowledgements": "Remerciements", "Spatial Coverage": "Couverture spatiale", "Extra Properties": "Propriétés supplémentaires", "Name": "Nom", From af01359c2d7903523095ba0fbd592f25b0b55c21 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 15:29:32 -0400 Subject: [PATCH 17/32] refact: typescript-ify LinkIfUrl and factor patterns to separate files --- .../Tables/ExtraPropertiesTable.tsx | 2 +- .../Provenance/Tables/PublicationsTable.tsx | 7 +++---- src/js/components/Util/LinkIfUrl.tsx | 18 ++++++++++++++++++ .../LinkIfUrl.js => constants/patterns.ts} | 19 ++----------------- src/js/utils/strings.ts | 4 ++++ 5 files changed, 28 insertions(+), 22 deletions(-) create mode 100644 src/js/components/Util/LinkIfUrl.tsx rename src/js/{components/Util/LinkIfUrl.js => constants/patterns.ts} (51%) create mode 100644 src/js/utils/strings.ts diff --git a/src/js/components/Provenance/Tables/ExtraPropertiesTable.tsx b/src/js/components/Provenance/Tables/ExtraPropertiesTable.tsx index 9f6013e6..979167b8 100644 --- a/src/js/components/Provenance/Tables/ExtraPropertiesTable.tsx +++ b/src/js/components/Provenance/Tables/ExtraPropertiesTable.tsx @@ -21,7 +21,7 @@ const ExtraPropertiesTable = ({ extraProperties }: ExtraPropertiesTableProps) => render: (_, { values }) => values.map((v, i) => ( <> - {' '} + {' '} )), }, diff --git a/src/js/components/Provenance/Tables/PublicationsTable.tsx b/src/js/components/Provenance/Tables/PublicationsTable.tsx index 473150c4..799aeb74 100644 --- a/src/js/components/Provenance/Tables/PublicationsTable.tsx +++ b/src/js/components/Provenance/Tables/PublicationsTable.tsx @@ -8,8 +8,7 @@ import LinkIfUrl from '../../Util/LinkIfUrl'; import { useTranslationCustom, useTranslationDefault } from '@/hooks'; import { Person, PrimaryPublication, ProvenanceStoreDataset } from '@/types/provenance'; -const DOI_REGEX = /^10.\d{4,9}\/[-._;()/:A-Z0-9]+$/i; -const isDOI = (s: string) => s.match(DOI_REGEX); +import { stringIsDOI } from '@/utils/strings'; const DOILink = ({ doi, children }: { doi: string; children?: ReactNode }) => ( @@ -45,7 +44,7 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { const formattedTitle = `${t(title)}${title.endsWith('.') ? '' : '.'}`; return ( <> - {isDOI(identifier) ? {formattedTitle} : formattedTitle} + {stringIsDOI(identifier) ? {formattedTitle} : formattedTitle} {authors ? ( <>
@@ -75,7 +74,7 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { title: td('Identifier'), dataIndex: 'identifier.identifier', render: (_, { identifier: { identifier } }) => - isDOI(identifier) ? : , + stringIsDOI(identifier) ? : , }, { title: td('Identifier Source'), diff --git a/src/js/components/Util/LinkIfUrl.tsx b/src/js/components/Util/LinkIfUrl.tsx new file mode 100644 index 00000000..9d1eb448 --- /dev/null +++ b/src/js/components/Util/LinkIfUrl.tsx @@ -0,0 +1,18 @@ +import React from 'react'; +import { Typography } from 'antd'; + +import { stringIsURL } from '@/utils/strings'; + +// Renders text as link if the text provided is a valid url. +const LinkIfUrl = ({ text }: { text: string }) => { + if (stringIsURL(text)) { + return ( + + {text} + + ); + } + return <>{text}; +}; + +export default LinkIfUrl; diff --git a/src/js/components/Util/LinkIfUrl.js b/src/js/constants/patterns.ts similarity index 51% rename from src/js/components/Util/LinkIfUrl.js rename to src/js/constants/patterns.ts index d693bffd..2fe9af6e 100644 --- a/src/js/components/Util/LinkIfUrl.js +++ b/src/js/constants/patterns.ts @@ -1,5 +1,4 @@ -import React from 'react'; -import { Typography } from 'antd'; +export const DOI_PATTERN = /^10.\d{4,9}\/[-._;()/:A-Z0-9]+$/i; /* ^ starts with... @@ -14,18 +13,4 @@ import { Typography } from 'antd'; + repeated at least once $ until the end of the string */ -const URL_REGEX = /^(http|https):\/\/[^ "]+$/; - -// Renders text as link if the text provided is a valid url. -const LinkIfUrl = ({ text }) => { - if (text.match(URL_REGEX)) { - return ( - - {text} - - ); - } - return text; -}; - -export default LinkIfUrl; +export const URL_PATTERN = /^(http|https):\/\/[^ "]+$/; diff --git a/src/js/utils/strings.ts b/src/js/utils/strings.ts new file mode 100644 index 00000000..a30bd27d --- /dev/null +++ b/src/js/utils/strings.ts @@ -0,0 +1,4 @@ +import { DOI_PATTERN, URL_PATTERN } from '@/constants/patterns'; + +export const stringIsDOI = (s: string) => !!s.match(DOI_PATTERN); +export const stringIsURL = (s: string) => !!s.match(URL_PATTERN); From f24a00597e6d4524d6edfe95253fccacea3eb83e Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 15:34:30 -0400 Subject: [PATCH 18/32] feat: link pub to URL if identifier is URL --- .../Provenance/Tables/PublicationsTable.tsx | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/js/components/Provenance/Tables/PublicationsTable.tsx b/src/js/components/Provenance/Tables/PublicationsTable.tsx index 799aeb74..fa1b4a8c 100644 --- a/src/js/components/Provenance/Tables/PublicationsTable.tsx +++ b/src/js/components/Provenance/Tables/PublicationsTable.tsx @@ -8,14 +8,18 @@ import LinkIfUrl from '../../Util/LinkIfUrl'; import { useTranslationCustom, useTranslationDefault } from '@/hooks'; import { Person, PrimaryPublication, ProvenanceStoreDataset } from '@/types/provenance'; -import { stringIsDOI } from '@/utils/strings'; +import { stringIsDOI, stringIsURL } from '@/utils/strings'; -const DOILink = ({ doi, children }: { doi: string; children?: ReactNode }) => ( - - {children ?? doi} +const URLLink = ({ url, children }: { url: string; children?: ReactNode }) => ( + + {children || url} ); +const DOILink = ({ doi, children }: { doi: string; children?: ReactNode }) => ( + {children} +); + const formatAuthorList = (authors: Person[]): string => { const fullNames = authors.map((a) => a.fullName); if (fullNames.length === 0) { @@ -44,7 +48,13 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { const formattedTitle = `${t(title)}${title.endsWith('.') ? '' : '.'}`; return ( <> - {stringIsDOI(identifier) ? {formattedTitle} : formattedTitle} + {stringIsDOI(identifier) ? ( + {formattedTitle} + ) : stringIsURL(identifier) ? ( + {formattedTitle} + ) : ( + formattedTitle + )} {authors ? ( <>
From 39fd0b75cc6126a2557c24bfb1668593c2dd1b9f Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 15:44:43 -0400 Subject: [PATCH 19/32] style: format pub dates --- src/js/components/Provenance/Tables/PublicationsTable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/components/Provenance/Tables/PublicationsTable.tsx b/src/js/components/Provenance/Tables/PublicationsTable.tsx index fa1b4a8c..9e850f8a 100644 --- a/src/js/components/Provenance/Tables/PublicationsTable.tsx +++ b/src/js/components/Provenance/Tables/PublicationsTable.tsx @@ -76,7 +76,7 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { render: (_, { dates }) => (dates ?? []).map((date, i) => ( - {date.date} + {(new Date(Date.parse(date.date))).toLocaleDateString()} )), }, From 0bf57811653b5aad95414a4e6d3bd8067ed3a59a Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 15:46:22 -0400 Subject: [PATCH 20/32] lint --- src/js/components/Provenance/Tables/PublicationsTable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/components/Provenance/Tables/PublicationsTable.tsx b/src/js/components/Provenance/Tables/PublicationsTable.tsx index 9e850f8a..313231b7 100644 --- a/src/js/components/Provenance/Tables/PublicationsTable.tsx +++ b/src/js/components/Provenance/Tables/PublicationsTable.tsx @@ -76,7 +76,7 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { render: (_, { dates }) => (dates ?? []).map((date, i) => ( - {(new Date(Date.parse(date.date))).toLocaleDateString()} + {new Date(Date.parse(date.date)).toLocaleDateString()} )), }, From bad0d5e5229c97462a47de6f8ba1d8dcabfe160b Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Wed, 11 Oct 2023 15:52:12 -0400 Subject: [PATCH 21/32] style: ensure layout is at least 100vh --- src/js/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/index.tsx b/src/js/index.tsx index a346c0c6..f15ab5cf 100644 --- a/src/js/index.tsx +++ b/src/js/index.tsx @@ -37,7 +37,7 @@ const App = () => { }, [lang, i18n.language, navigate]); return ( - + From 91397706ba6d7cc03c4a55df9821c4a731d165c8 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Mon, 16 Oct 2023 09:41:33 -0400 Subject: [PATCH 22/32] fix: show doi instead of doi url in doi link --- src/js/components/Provenance/Tables/PublicationsTable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/components/Provenance/Tables/PublicationsTable.tsx b/src/js/components/Provenance/Tables/PublicationsTable.tsx index 313231b7..d2e16fc8 100644 --- a/src/js/components/Provenance/Tables/PublicationsTable.tsx +++ b/src/js/components/Provenance/Tables/PublicationsTable.tsx @@ -17,7 +17,7 @@ const URLLink = ({ url, children }: { url: string; children?: ReactNode }) => ( ); const DOILink = ({ doi, children }: { doi: string; children?: ReactNode }) => ( - {children} + {children || doi} ); const formatAuthorList = (authors: Person[]): string => { From 00977cf9b68e7ca35122b39d86a4bd5d52d571be Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Mon, 16 Oct 2023 10:02:11 -0400 Subject: [PATCH 23/32] fix a 0-render --- src/js/components/Provenance/DatasetProvenance.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/components/Provenance/DatasetProvenance.tsx b/src/js/components/Provenance/DatasetProvenance.tsx index b4f3d0a1..76e31d43 100644 --- a/src/js/components/Provenance/DatasetProvenance.tsx +++ b/src/js/components/Provenance/DatasetProvenance.tsx @@ -44,7 +44,7 @@ const DatasetProvenance = ({ metadata, loading }: DatasetProvenanceProps) => { {t(metadata.privacy)} )} - {metadata.licenses.length && ( + {!!metadata.licenses?.length && ( }> {metadata.licenses.map((l, i) => ( @@ -53,7 +53,7 @@ const DatasetProvenance = ({ metadata, loading }: DatasetProvenanceProps) => { ))} )} - {metadata.keywords.length && ( + {!!metadata.keywords?.length && ( }> {metadata.keywords.map((keyword, i) => ( From de73902a6de47ed7e3ca7c2953b0f90ff27671e1 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Mon, 16 Oct 2023 10:04:58 -0400 Subject: [PATCH 24/32] fix: author rendering if 0-length array plus lint --- .../Provenance/DatasetProvenance.tsx | 28 +++++++++---------- .../Provenance/Tables/PublicationsTable.tsx | 4 +-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/js/components/Provenance/DatasetProvenance.tsx b/src/js/components/Provenance/DatasetProvenance.tsx index 76e31d43..65949796 100644 --- a/src/js/components/Provenance/DatasetProvenance.tsx +++ b/src/js/components/Provenance/DatasetProvenance.tsx @@ -67,60 +67,60 @@ const DatasetProvenance = ({ metadata, loading }: DatasetProvenanceProps) => { {/* TableTitle has translation in it*/} {/* --- CREATED BY ---*/} - {metadata.creators?.length ? ( + {!!metadata.creators?.length && ( <> - ) : null} + )} {/* --- DISTRIBUTIONS ---*/} - {metadata.distributions?.length ? ( + {!!metadata.distributions?.length && ( <> - ) : null} + )} {/* --- IS ABOUT ---*/} - {metadata.isAbout?.length ? ( + {!!metadata.isAbout?.length && ( <> - ) : null} + )} {/* --- PUBLICATIONS ---*/} - {metadata.primaryPublications?.length ? ( + {!!metadata.primaryPublications?.length && ( <> - ) : null} + )} {/* --- ACKNOWLEDGES ---*/} - {metadata.acknowledges?.length ? ( + {!!metadata.acknowledges?.length && ( <> - ) : null} + )} {/* --- SPATIAL COVERAGE ---*/} - {metadata.spatialCoverage?.length ? ( + {!!metadata.spatialCoverage?.length && ( <> - ) : null} + )} {/* --- EXTRA PROPERTIES ---*/} - {metadata.extraProperties?.length ? ( + {!!metadata.extraProperties?.length && ( <> - ) : null} + )} {/* --- DOWNLOAD DATS --- */} diff --git a/src/js/components/Provenance/Tables/PublicationsTable.tsx b/src/js/components/Provenance/Tables/PublicationsTable.tsx index d2e16fc8..ceea3ec9 100644 --- a/src/js/components/Provenance/Tables/PublicationsTable.tsx +++ b/src/js/components/Provenance/Tables/PublicationsTable.tsx @@ -55,12 +55,12 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { ) : ( formattedTitle )} - {authors ? ( + {!!authors?.length && ( <>
{formatAuthorList(authors)} - ) : null} + )} ); }, From ff3a18d08b265d7610789e84ea04160e601d5b53 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Mon, 16 Oct 2023 13:24:23 -0400 Subject: [PATCH 25/32] feat: add sorters and filtering for publications table --- .../Provenance/Tables/PublicationsTable.tsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/js/components/Provenance/Tables/PublicationsTable.tsx b/src/js/components/Provenance/Tables/PublicationsTable.tsx index ceea3ec9..c01ed0ac 100644 --- a/src/js/components/Provenance/Tables/PublicationsTable.tsx +++ b/src/js/components/Provenance/Tables/PublicationsTable.tsx @@ -64,11 +64,14 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { ); }, + + sorter: (a, b) => a.title.localeCompare(b.title), }, { title: td('Publication Venue'), dataIndex: 'publicationVenue', render: (text) => t(text), + sorter: (a, b) => a.publicationVenue.localeCompare(b.publicationVenue), }, { title: td('Date'), @@ -79,6 +82,16 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { {new Date(Date.parse(date.date)).toLocaleDateString()}
)), + sorter: (a, b) => { + if (!a.dates?.length) { + if (!b.dates?.length) return 0; + return 1; // Sort blank entries after + } else if (!b.dates?.length) { + return -1; // Sort blank entries after + } else { + return Date.parse(a.dates[0].date) - Date.parse(b.dates[0].date); + } + }, }, { title: td('Identifier'), @@ -90,9 +103,12 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { title: td('Identifier Source'), dataIndex: 'identifier.identifierSource', render: (_, { identifier: { identifierSource } }) => t(identifierSource), + sorter: (a, b) => a.identifier.identifierSource.localeCompare(b.identifier.identifierSource), + filters: Array.from(new Set(publications.map(p => p.identifier.identifierSource))) + .map((v) => ({ text: v, value: v })), }, ] as ColumnsType, - [td] + [td, publications] ); return ; From bf1b4f584c354f1c2e02d704ba45cb01828463f7 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Mon, 16 Oct 2023 13:24:40 -0400 Subject: [PATCH 26/32] lint --- src/js/components/Provenance/Tables/PublicationsTable.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/js/components/Provenance/Tables/PublicationsTable.tsx b/src/js/components/Provenance/Tables/PublicationsTable.tsx index c01ed0ac..8714f182 100644 --- a/src/js/components/Provenance/Tables/PublicationsTable.tsx +++ b/src/js/components/Provenance/Tables/PublicationsTable.tsx @@ -87,7 +87,7 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { if (!b.dates?.length) return 0; return 1; // Sort blank entries after } else if (!b.dates?.length) { - return -1; // Sort blank entries after + return -1; // Sort blank entries after } else { return Date.parse(a.dates[0].date) - Date.parse(b.dates[0].date); } @@ -104,8 +104,10 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { dataIndex: 'identifier.identifierSource', render: (_, { identifier: { identifierSource } }) => t(identifierSource), sorter: (a, b) => a.identifier.identifierSource.localeCompare(b.identifier.identifierSource), - filters: Array.from(new Set(publications.map(p => p.identifier.identifierSource))) - .map((v) => ({ text: v, value: v })), + filters: Array.from(new Set(publications.map((p) => p.identifier.identifierSource))).map((v) => ({ + text: v, + value: v, + })), }, ] as ColumnsType, [td, publications] From ebd938c606ab8dd8765cb32e10dcc9a551f098a8 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Mon, 16 Oct 2023 13:34:26 -0400 Subject: [PATCH 27/32] style: don't use tags for funder acknowledgements --- src/js/components/Provenance/Tables/AcknowledgesTable.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/js/components/Provenance/Tables/AcknowledgesTable.tsx b/src/js/components/Provenance/Tables/AcknowledgesTable.tsx index 165c3f65..92100add 100644 --- a/src/js/components/Provenance/Tables/AcknowledgesTable.tsx +++ b/src/js/components/Provenance/Tables/AcknowledgesTable.tsx @@ -1,5 +1,4 @@ import React from 'react'; -import { Tag } from 'antd'; import BaseProvenanceTable from './BaseProvenanceTable'; import LinkIfUrl from '../../Util/LinkIfUrl'; @@ -24,10 +23,11 @@ const AcknowledgesTable = ({ acknowledges }: AcknowledgesTableProps) => { dataIndex: 'funders', render: (_, { funders }) => funders.map((f, i) => ( - + - {f.abbreviation ? `(${t(f.abbreviation)})` : ''} - + {f.abbreviation ? ` (${t(f.abbreviation)})` : ''} + {i < funders.length - 1 ? '; ' : ''} + )), }, ]} From aeca5a5158eebee0a1a06bffb2f566c721f259b7 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Mon, 16 Oct 2023 13:35:31 -0400 Subject: [PATCH 28/32] style: delimit array of extra props values with semicolons --- src/js/components/Provenance/Tables/ExtraPropertiesTable.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/js/components/Provenance/Tables/ExtraPropertiesTable.tsx b/src/js/components/Provenance/Tables/ExtraPropertiesTable.tsx index 979167b8..1cecb2ed 100644 --- a/src/js/components/Provenance/Tables/ExtraPropertiesTable.tsx +++ b/src/js/components/Provenance/Tables/ExtraPropertiesTable.tsx @@ -21,7 +21,8 @@ const ExtraPropertiesTable = ({ extraProperties }: ExtraPropertiesTableProps) => render: (_, { values }) => values.map((v, i) => ( <> - {' '} + + {i < values.length - 1 ? '; ' : ''} )), }, From 1ed76b792eb0d1777d2fed3f9c77dd8cb7e1df89 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Mon, 16 Oct 2023 13:41:30 -0400 Subject: [PATCH 29/32] style: don't put paper date in a tag --- .../Provenance/Tables/PublicationsTable.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/js/components/Provenance/Tables/PublicationsTable.tsx b/src/js/components/Provenance/Tables/PublicationsTable.tsx index 8714f182..2c4bcfd5 100644 --- a/src/js/components/Provenance/Tables/PublicationsTable.tsx +++ b/src/js/components/Provenance/Tables/PublicationsTable.tsx @@ -76,12 +76,15 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { { title: td('Date'), dataIndex: 'dates', - render: (_, { dates }) => - (dates ?? []).map((date, i) => ( - + render: (_, { dates }) => { + const _dates = dates ?? []; + return _dates.map((date, i) => ( + <> {new Date(Date.parse(date.date)).toLocaleDateString()} - - )), + {i < _dates.length - 1 ? '; ' : ''} + + )); + }, sorter: (a, b) => { if (!a.dates?.length) { if (!b.dates?.length) return 0; From 914241d6ef04d25fc300617f373e61ca894068d7 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Mon, 16 Oct 2023 13:44:43 -0400 Subject: [PATCH 30/32] lint --- src/js/components/Provenance/Tables/PublicationsTable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/components/Provenance/Tables/PublicationsTable.tsx b/src/js/components/Provenance/Tables/PublicationsTable.tsx index 2c4bcfd5..7f04b58b 100644 --- a/src/js/components/Provenance/Tables/PublicationsTable.tsx +++ b/src/js/components/Provenance/Tables/PublicationsTable.tsx @@ -1,6 +1,6 @@ import React, { ReactNode, useMemo } from 'react'; -import { Tag, Typography } from 'antd'; +import { Typography } from 'antd'; import { ColumnsType } from 'antd/es/table'; import BaseProvenanceTable from './BaseProvenanceTable'; From a91da516c7e3a7e3d4ebdbcce61b7232a75d1c96 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Mon, 16 Oct 2023 13:46:51 -0400 Subject: [PATCH 31/32] style: add default sort order of descend to date for pub --- src/js/components/Provenance/Tables/PublicationsTable.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/js/components/Provenance/Tables/PublicationsTable.tsx b/src/js/components/Provenance/Tables/PublicationsTable.tsx index 7f04b58b..9bddbeea 100644 --- a/src/js/components/Provenance/Tables/PublicationsTable.tsx +++ b/src/js/components/Provenance/Tables/PublicationsTable.tsx @@ -95,6 +95,7 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { return Date.parse(a.dates[0].date) - Date.parse(b.dates[0].date); } }, + defaultSortOrder: 'descend', }, { title: td('Identifier'), From 43721606b0b10b7460753025a79d556ab3d52835 Mon Sep 17 00:00:00 2001 From: David Lougheed Date: Mon, 16 Oct 2023 13:49:01 -0400 Subject: [PATCH 32/32] fix: filtering not working for pub id source --- src/js/components/Provenance/Tables/PublicationsTable.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/js/components/Provenance/Tables/PublicationsTable.tsx b/src/js/components/Provenance/Tables/PublicationsTable.tsx index 9bddbeea..772eba28 100644 --- a/src/js/components/Provenance/Tables/PublicationsTable.tsx +++ b/src/js/components/Provenance/Tables/PublicationsTable.tsx @@ -112,6 +112,7 @@ const PublicationsTable = ({ publications }: PublicationsTableProps) => { text: v, value: v, })), + onFilter: (filterValue, p) => p.identifier.identifierSource === filterValue, }, ] as ColumnsType, [td, publications]