Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve provenance display across multiple facets #116

Merged
merged 32 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
27b5b86
chore: don't require authors/dates for papers
davidlougheed Oct 11, 2023
796d27c
lint: make constant regex var name uppercase
davidlougheed Oct 11, 2023
af9803a
feat: be more intelligent about DOIs in provenance table
davidlougheed Oct 11, 2023
927a571
refact: memoize columns for provenance publications
davidlougheed Oct 11, 2023
d32a4e9
style: don't render extra properties as tags
davidlougheed Oct 11, 2023
3f22087
feat: fix annotation type, show pub author list under title
davidlougheed Oct 11, 2023
6d02172
refact: memoize columns for extra props table
davidlougheed Oct 11, 2023
c0e23b2
fix: type error
davidlougheed Oct 11, 2023
9bfcf5c
fix: more type errors
davidlougheed Oct 11, 2023
abf0e90
fix: one more
davidlougheed Oct 11, 2023
4434107
refact: memoize distributions table columns
davidlougheed Oct 11, 2023
54c2c51
fix: typo in component name
davidlougheed Oct 11, 2023
9e58382
style: render pub authors in italics
davidlougheed Oct 11, 2023
7926b50
style: don't render empty tables in provenance
davidlougheed Oct 11, 2023
c37941e
lint: rm unused styling
davidlougheed Oct 11, 2023
7259297
chore: acknowledges -> acknowledgements
davidlougheed Oct 11, 2023
af01359
refact: typescript-ify LinkIfUrl and factor patterns to separate files
davidlougheed Oct 11, 2023
f24a005
feat: link pub to URL if identifier is URL
davidlougheed Oct 11, 2023
39fd0b7
style: format pub dates
davidlougheed Oct 11, 2023
0bf5781
lint
davidlougheed Oct 11, 2023
bad0d5e
style: ensure layout is at least 100vh
davidlougheed Oct 11, 2023
9139770
fix: show doi instead of doi url in doi link
davidlougheed Oct 16, 2023
00977cf
fix a 0-render
davidlougheed Oct 16, 2023
de73902
fix: author rendering if 0-length array
davidlougheed Oct 16, 2023
ff3a18d
feat: add sorters and filtering for publications table
davidlougheed Oct 16, 2023
bf1b4f5
lint
davidlougheed Oct 16, 2023
ebd938c
style: don't use tags for funder acknowledgements
davidlougheed Oct 16, 2023
aeca5a5
style: delimit array of extra props values with semicolons
davidlougheed Oct 16, 2023
1ed76b7
style: don't put paper date in a tag
davidlougheed Oct 16, 2023
914241d
lint
davidlougheed Oct 16, 2023
a91da51
style: add default sort order of descend to date for pub
davidlougheed Oct 16, 2023
4372160
fix: filtering not working for pub id source
davidlougheed Oct 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 47 additions & 19 deletions src/js/components/Provenance/DatasetProvenance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const DatasetProvenance = ({ metadata, loading }: DatasetProvenanceProps) => {
{t(metadata.version)}
</Title>,
]}
style={{ borderRadius: '11px', maxWidth: '1400px' }}
style={{ borderRadius: '11px' }}
loading={loading}
>
{/* --- DESCRIPTION ---*/}
Expand All @@ -44,7 +44,7 @@ const DatasetProvenance = ({ metadata, loading }: DatasetProvenanceProps) => {
{t(metadata.privacy)}
</Item>
)}
{metadata.licenses.length && (
{!!metadata.licenses?.length && (
<Item span={12} label={<DescriptionTitle title={td('Licenses')} />}>
{metadata.licenses.map((l, i) => (
<Tag key={i} color="cyan">
Expand All @@ -53,11 +53,11 @@ const DatasetProvenance = ({ metadata, loading }: DatasetProvenanceProps) => {
))}
</Item>
)}
{metadata.keywords.length && (
{!!metadata.keywords?.length && (
<Item span={24} label={<DescriptionTitle title={td('Keywords')} />}>
{metadata.keywords.map((keyword, i) => (
<Tag key={i} color="cyan">
{t(keyword.value)}
{t(keyword.value.toString())}
</Tag>
))}
</Item>
Expand All @@ -67,32 +67,60 @@ const DatasetProvenance = ({ metadata, loading }: DatasetProvenanceProps) => {

{/* TableTitle has translation in it*/}
{/* --- CREATED BY ---*/}
<TableTitleWitTranslation title="Created By" />
<CreatedByTable creators={metadata.creators} />
{!!metadata.creators?.length && (
<>
<TableTitleWithTranslation title="Created By" />
<CreatedByTable creators={metadata.creators} />
</>
)}

{/* --- DISTRIBUTIONS ---*/}
<TableTitleWitTranslation title="Distributions" />
<DistributionsTable distributions={metadata.distributions} />
{!!metadata.distributions?.length && (
<>
<TableTitleWithTranslation title="Distributions" />
<DistributionsTable distributions={metadata.distributions} />
</>
)}

{/* --- IS ABOUT ---*/}
<TableTitleWitTranslation title="Is About" />
<IsAboutTable isAbout={metadata.isAbout} />
{!!metadata.isAbout?.length && (
<>
<TableTitleWithTranslation title="Is About" />
<IsAboutTable isAbout={metadata.isAbout} />
</>
)}

{/* --- PUBLICATIONS ---*/}
<TableTitleWitTranslation title="Primary Publications" />
<PublicationsTable publications={metadata.primaryPublications} />
{!!metadata.primaryPublications?.length && (
<>
<TableTitleWithTranslation title="Primary Publications" />
<PublicationsTable publications={metadata.primaryPublications} />
</>
)}

{/* --- ACKNOWLEDGES ---*/}
<TableTitleWitTranslation title="Acknowledges" />
<AcknowledgesTable acknowledges={metadata.acknowledges} />
{!!metadata.acknowledges?.length && (
<>
<TableTitleWithTranslation title="Acknowledgements" />
<AcknowledgesTable acknowledges={metadata.acknowledges} />
</>
)}

{/* --- SPATIAL COVERAGE ---*/}
<TableTitleWitTranslation title="Spatial Coverage" />
<SpatialCoverageTable spatialCoverage={metadata.spatialCoverage} />
{!!metadata.spatialCoverage?.length && (
<>
<TableTitleWithTranslation title="Spatial Coverage" />
<SpatialCoverageTable spatialCoverage={metadata.spatialCoverage} />
</>
)}

{/* --- EXTRA PROPERTIES ---*/}
<TableTitleWitTranslation title="Extra Properties" />
<ExtraPropertiesTable extraProperties={metadata.extraProperties} />
{!!metadata.extraProperties?.length && (
<>
<TableTitleWithTranslation title="Extra Properties" />
<ExtraPropertiesTable extraProperties={metadata.extraProperties} />
</>
)}

{/* --- DOWNLOAD DATS --- */}
<DownloadDats metadata={metadata} />
Expand All @@ -108,7 +136,7 @@ export type DatasetProvenanceProps = {

export default DatasetProvenance;

const TableTitleWitTranslation = ({ title }: { title: string }) => {
const TableTitleWithTranslation = ({ title }: { title: string }) => {
const { t } = useTranslation(DEFAULT_TRANSLATION);

return (
Expand Down
8 changes: 4 additions & 4 deletions src/js/components/Provenance/Tables/AcknowledgesTable.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { Tag } from 'antd';

import BaseProvenanceTable from './BaseProvenanceTable';
import LinkIfUrl from '../../Util/LinkIfUrl';
Expand All @@ -24,10 +23,11 @@ const AcknowledgesTable = ({ acknowledges }: AcknowledgesTableProps) => {
dataIndex: 'funders',
render: (_, { funders }) =>
funders.map((f, i) => (
<Tag key={i} color="cyan">
<React.Fragment key={i}>
<LinkIfUrl text={f.name} />
{f.abbreviation ? `(${t(f.abbreviation)})` : ''}
</Tag>
{f.abbreviation ? ` (${t(f.abbreviation)})` : ''}
{i < funders.length - 1 ? '; ' : ''}
</React.Fragment>
)),
},
]}
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/Provenance/Tables/CreatedByTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const CreatedByTable = ({ creators }: CreatedByTableProps) => {
roles &&
roles.map((r, i) => (
<Tag key={i} color="cyan">
{t(r.value)}
{t(r.value.toString())}
</Tag>
)),
},
Expand Down
23 changes: 13 additions & 10 deletions src/js/components/Provenance/Tables/DistributionsTable.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<BaseProvenanceTable
dataSource={distributions}
columns={[
const columns = useMemo(
() =>
[
{
title: td('Formats'),
dataIndex: 'formats',
Expand All @@ -27,7 +28,7 @@ const DistributionsTable = ({ distributions }: DistributionsTableProps) => {
{
title: td('Unit'),
dataIndex: 'unit',
render: (_, { unit }) => t(unit.value),
render: (_, { unit }) => t(unit.value.toString()),
},
{
title: td('Access'),
Expand All @@ -47,15 +48,17 @@ const DistributionsTable = ({ distributions }: DistributionsTableProps) => {
render: (_, { access }) =>
access.authorizations.map((a, i) => (
<Tag key={i} color="cyan">
{t(a.value)}
{t(a.value.toString())}
</Tag>
)),
},
],
},
]}
/>
] as ColumnsType<Distribution>,
[td]
);

return <BaseProvenanceTable dataSource={distributions} columns={columns} />;
};

export interface DistributionsTableProps {
Expand Down
27 changes: 15 additions & 12 deletions src/js/components/Provenance/Tables/ExtraPropertiesTable.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
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 (
<BaseProvenanceTable
dataSource={extraProperties}
columns={[
const columns = useMemo(
() =>
[
{ title: td('Category'), dataIndex: 'category', render: (text) => t(text) },
{
title: td('Values'),
dataIndex: 'values',
render: (_, { values }) =>
values.map((v, i) => (
<Tag key={i} color="cyan">
<LinkIfUrl text={v.value} />
</Tag>
<>
<LinkIfUrl key={i} text={v.value.toString()} />
{i < values.length - 1 ? '; ' : ''}
</>
)),
},
]}
/>
] as ColumnsType<ExtraProperty>,
[td]
);

return <BaseProvenanceTable dataSource={extraProperties} columns={columns} />;
};

export interface ExtraPropertiesTableProps {
Expand Down
Loading