diff --git a/client/src/components/infoDrawer/infoFormat.js b/client/src/components/infoDrawer/infoFormat.js index 6909e7cf..f68cacda 100644 --- a/client/src/components/infoDrawer/infoFormat.js +++ b/client/src/components/infoDrawer/infoFormat.js @@ -1,8 +1,6 @@ -import { H3, H1, UL } from "@blueprintjs/core"; +import { H3, H1, UL, HTMLTable, Classes } from "@blueprintjs/core"; import React from "react"; -import Truncate from "../util/truncate"; - 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; @@ -71,63 +69,63 @@ const renderDOILink = (type, doi) => { ); }; -const renderOrganism = (organism) => { - if (!organism) return null; - return ( - <> -

Organism

-

{organism}

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

Dataset Metadata

- + // 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; + }, [])} + + ); }; @@ -184,14 +182,15 @@ const InfoFormat = React.memo( const affiliations = buildAffiliations(contributors); return ( -
-

{title ?? datasetTitle}

- {renderContributors(contributors, affiliations)} - {renderDOILink("DOI", doi)} - {renderDOILink("Preprint DOI", preprintDOI)} - {renderOrganism(organism)} - {renderSingleValueCategories(singleValueCategories)} - {renderLinks(projectLinks, aboutURL)} +
+
+

{title ?? datasetTitle}

+ {renderContributors(contributors, affiliations)} + {renderDatasetMetadata(singleValueCategories, { organism })} + {renderLinks(projectLinks, aboutURL)} + {renderDOILink("DOI", doi)} + {renderDOILink("Preprint DOI", preprintDOI)} +
); } diff --git a/client/src/components/leftSidebar/topLeftLogoAndTitle.js b/client/src/components/leftSidebar/topLeftLogoAndTitle.js index e4f3d5a7..97bf8739 100644 --- a/client/src/components/leftSidebar/topLeftLogoAndTitle.js +++ b/client/src/components/leftSidebar/topLeftLogoAndTitle.js @@ -1,4 +1,3 @@ -// jshint esversion: 6 import React from "react"; import { connect } from "react-redux"; import { Button } from "@blueprintjs/core"; @@ -11,13 +10,19 @@ import InformationMenu from "./infoMenu"; const DATASET_TITLE_FONT_SIZE = 14; -@connect((state) => ({ - datasetTitle: state.config?.displayNames?.dataset ?? "", - libraryVersions: state.config?.["library_versions"], - aboutLink: state.config?.links?.["about-dataset"], - tosURL: state.config?.parameters?.["about_legal_tos"], - privacyURL: state.config?.parameters?.["about_legal_privacy"], -})) +@connect((state) => { + const { corpora_props: corporaProps } = state.config; + const correctVersion = + corporaProps?.version?.["corpora_schema_version"] !== "1.0.0"; + return { + datasetTitle: state.config?.displayNames?.dataset ?? "", + libraryVersions: state.config?.["library_versions"], + aboutLink: state.config?.links?.["about-dataset"], + tosURL: state.config?.parameters?.["about_legal_tos"], + privacyURL: state.config?.parameters?.["about_legal_privacy"], + title: correctVersion ? corporaProps?.title : undefined, + }; +}) class LeftSideBar extends React.Component { handleClick = () => { const { dispatch } = this.props; @@ -32,6 +37,7 @@ class LeftSideBar extends React.Component { privacyURL, tosURL, dispatch, + title, } = this.props; return ( @@ -86,7 +92,7 @@ class LeftSideBar extends React.Component { > - {datasetTitle} + {title ?? datasetTitle}