import { H3, H1, UL, HTMLTable, Classes } from "@blueprintjs/core"; import React from "react"; const renderContributors = (contributors, affiliations) => { // eslint-disable-next-line no-constant-condition -- Temp removed contributor section to avoid publishing PII if (!contributors || contributors.length === 0 || true) return null; return ( <>

Contributors

{contributors.map((contributor) => { const { email, name, institution } = contributor; return ( {name} {email && `(${email})`} {affiliations.indexOf(institution) + 1} ); })}

{renderAffiliations(affiliations)} ); }; // generates a list of unique institutions by order of appearance in contributors const buildAffiliations = (contributors = []) => { const affiliations = []; contributors.forEach((contributor) => { const { institution } = contributor; if (affiliations.indexOf(institution) === -1) { affiliations.push(institution); } }); return affiliations; }; const renderAffiliations = (affiliations) => { if (affiliations.length === 0) return null; return ( <>

Affiliations

); }; const renderDOILink = (type, doi) => { if (!doi) return null; return ( <>

{type}

{doi}

); }; const ONTOLOGY_KEY = "ontology_term_id"; // Render list of metadata attributes found in categorical field const renderDatasetMetadata = (singleValueCategories, corporaMetadata) => { if (singleValueCategories.size === 0) return null; return ( <>

Dataset Metadata

Field Label Ontology ID {Object.entries(corporaMetadata).map(([key, value]) => { return ( {`${key}:`} {value} ); })} {Array.from(singleValueCategories).reduce((elems, pair) => { const [category, value] = pair; // If the value is empty skip it if (!value) return elems; // If this category is a ontology term, let's add its value to the previous node if (String(category).includes(ONTOLOGY_KEY)) { const prevElem = elems.pop(); const newChildren = [...prevElem.props.children]; newChildren.splice(2, 1, [{value}]); // Props aren't extensible so we must clone and alter the component to append the new child elems.push( React.cloneElement(prevElem, prevElem.props, newChildren) ); } else { // Create the list item elems.push( {`${category}:`} {value} ); } return elems; }, [])} ); }; // Renders any links found in the config where link_type is not "SUMMARY" // If there are no links in the config, render the aboutURL const renderLinks = (projectLinks, aboutURL) => { if (!projectLinks && !aboutURL) return null; if (projectLinks) return ( <>

Project Links

); return ( <>

More Info

{aboutURL}

); }; const InfoFormat = React.memo( ({ datasetTitle, singleValueCategories, aboutURL, dataPortalProps = {} }) => { if (["1.0.0", "1.1.0"].indexOf(dataPortalProps.version?.["corpora_schema_version"]) === -1) { dataPortalProps = {}; } const { title, publication_doi: doi, preprint_doi: preprintDOI, organism, contributors, project_links: projectLinks, } = dataPortalProps; const affiliations = buildAffiliations(contributors); return (

{title ?? datasetTitle}

{renderContributors(contributors, affiliations)} {renderDatasetMetadata(singleValueCategories, { organism })} {renderLinks(projectLinks, aboutURL)} {renderDOILink("DOI", doi)} {renderDOILink("Preprint DOI", preprintDOI)}
); } ); export default InfoFormat;