mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-06 02:28:11 +08:00
Data drawer final round of prod QA fixes (#1955)
* add long title * add organism to Dataset Metadata and create headers * begin HTMLTable for metadata * switch out truncating for scrolling * add optional chaining to redux state mapping Co-authored-by: maniarathi <mani.arathi@gmail.com>
This commit is contained in:
co-authored by
maniarathi
parent
78176f9711
commit
a5c9ae2432
@@ -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 React from "react";
|
||||||
|
|
||||||
import Truncate from "../util/truncate";
|
|
||||||
|
|
||||||
const renderContributors = (contributors, affiliations) => {
|
const renderContributors = (contributors, affiliations) => {
|
||||||
// eslint-disable-next-line no-constant-condition -- Temp removed contributor section to avoid publishing PII
|
// eslint-disable-next-line no-constant-condition -- Temp removed contributor section to avoid publishing PII
|
||||||
if (!contributors || contributors.length === 0 || true) return null;
|
if (!contributors || contributors.length === 0 || true) return null;
|
||||||
@@ -71,63 +69,63 @@ const renderDOILink = (type, doi) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderOrganism = (organism) => {
|
|
||||||
if (!organism) return null;
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<H3>Organism</H3>
|
|
||||||
<p>{organism}</p>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const ONTOLOGY_KEY = "ontology_term_id";
|
const ONTOLOGY_KEY = "ontology_term_id";
|
||||||
const CAT_WIDTH = "30%";
|
|
||||||
const VAL_WIDTH = "35%";
|
|
||||||
// Render list of metadata attributes found in categorical field
|
// Render list of metadata attributes found in categorical field
|
||||||
const renderSingleValueCategories = (singleValueCategories) => {
|
const renderDatasetMetadata = (singleValueCategories, corporaMetadata) => {
|
||||||
if (singleValueCategories.size === 0) return null;
|
if (singleValueCategories.size === 0) return null;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<H3>Dataset Metadata</H3>
|
<H3>Dataset Metadata</H3>
|
||||||
<UL>
|
<HTMLTable
|
||||||
{Array.from(singleValueCategories).reduce((elems, pair) => {
|
striped
|
||||||
const [category, value] = pair;
|
condensed
|
||||||
// If the value is empty skip it
|
style={{ display: "block", width: "100%", overflowX: "auto" }}
|
||||||
if (!value) return elems;
|
>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Field</th>
|
||||||
|
<th>Label</th>
|
||||||
|
<th>Ontology ID</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{Object.entries(corporaMetadata).map(([key, value]) => {
|
||||||
|
return (
|
||||||
|
<tr {...{ key }}>
|
||||||
|
<td>{`${key}:`}</td>
|
||||||
|
<td>{value}</td>
|
||||||
|
<td />
|
||||||
|
</tr>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
{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 this category is a ontology term, let's add its value to the previous node
|
||||||
if (String(category).includes(ONTOLOGY_KEY)) {
|
if (String(category).includes(ONTOLOGY_KEY)) {
|
||||||
const prevElem = elems.pop();
|
const prevElem = elems.pop();
|
||||||
// Props aren't extensible so we must clone and alter the component to append the new child
|
const newChildren = [...prevElem.props.children];
|
||||||
elems.push(
|
newChildren.splice(2, 1, [<td key="ontology">{value}</td>]);
|
||||||
React.cloneElement(
|
// Props aren't extensible so we must clone and alter the component to append the new child
|
||||||
prevElem,
|
elems.push(
|
||||||
prevElem.props,
|
React.cloneElement(prevElem, prevElem.props, newChildren)
|
||||||
// Concat returns a new array
|
);
|
||||||
prevElem.props.children.concat([
|
} else {
|
||||||
<Truncate key="ontology">
|
// Create the list item
|
||||||
<span style={{ width: VAL_WIDTH }}>{value}</span>
|
elems.push(
|
||||||
</Truncate>,
|
<tr key={category}>
|
||||||
])
|
<td>{`${category}:`}</td>
|
||||||
)
|
<td>{value}</td>
|
||||||
);
|
<td />
|
||||||
} else {
|
</tr>
|
||||||
// Create the list item
|
);
|
||||||
elems.push(
|
}
|
||||||
<li key={category} style={{ width: "100%" }}>
|
return elems;
|
||||||
<Truncate>
|
}, [])}
|
||||||
<span style={{ width: CAT_WIDTH }}>{`${category}:`}</span>
|
</tbody>
|
||||||
</Truncate>
|
</HTMLTable>
|
||||||
<Truncate>
|
|
||||||
<span style={{ width: VAL_WIDTH }}>{value}</span>
|
|
||||||
</Truncate>
|
|
||||||
</li>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return elems;
|
|
||||||
}, [])}
|
|
||||||
</UL>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -184,14 +182,15 @@ const InfoFormat = React.memo(
|
|||||||
const affiliations = buildAffiliations(contributors);
|
const affiliations = buildAffiliations(contributors);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ margin: 24, overflow: "auto" }}>
|
<div className={Classes.DIALOG_BODY}>
|
||||||
<H1>{title ?? datasetTitle}</H1>
|
<div className={Classes.DIALOG_BODY}>
|
||||||
{renderContributors(contributors, affiliations)}
|
<H1>{title ?? datasetTitle}</H1>
|
||||||
{renderDOILink("DOI", doi)}
|
{renderContributors(contributors, affiliations)}
|
||||||
{renderDOILink("Preprint DOI", preprintDOI)}
|
{renderDatasetMetadata(singleValueCategories, { organism })}
|
||||||
{renderOrganism(organism)}
|
{renderLinks(projectLinks, aboutURL)}
|
||||||
{renderSingleValueCategories(singleValueCategories)}
|
{renderDOILink("DOI", doi)}
|
||||||
{renderLinks(projectLinks, aboutURL)}
|
{renderDOILink("Preprint DOI", preprintDOI)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// jshint esversion: 6
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { Button } from "@blueprintjs/core";
|
import { Button } from "@blueprintjs/core";
|
||||||
@@ -11,13 +10,19 @@ import InformationMenu from "./infoMenu";
|
|||||||
|
|
||||||
const DATASET_TITLE_FONT_SIZE = 14;
|
const DATASET_TITLE_FONT_SIZE = 14;
|
||||||
|
|
||||||
@connect((state) => ({
|
@connect((state) => {
|
||||||
datasetTitle: state.config?.displayNames?.dataset ?? "",
|
const { corpora_props: corporaProps } = state.config;
|
||||||
libraryVersions: state.config?.["library_versions"],
|
const correctVersion =
|
||||||
aboutLink: state.config?.links?.["about-dataset"],
|
corporaProps?.version?.["corpora_schema_version"] !== "1.0.0";
|
||||||
tosURL: state.config?.parameters?.["about_legal_tos"],
|
return {
|
||||||
privacyURL: state.config?.parameters?.["about_legal_privacy"],
|
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 {
|
class LeftSideBar extends React.Component {
|
||||||
handleClick = () => {
|
handleClick = () => {
|
||||||
const { dispatch } = this.props;
|
const { dispatch } = this.props;
|
||||||
@@ -32,6 +37,7 @@ class LeftSideBar extends React.Component {
|
|||||||
privacyURL,
|
privacyURL,
|
||||||
tosURL,
|
tosURL,
|
||||||
dispatch,
|
dispatch,
|
||||||
|
title,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -86,7 +92,7 @@ class LeftSideBar extends React.Component {
|
|||||||
>
|
>
|
||||||
<Truncate>
|
<Truncate>
|
||||||
<span style={{ maxWidth: 155 }} data-testid="header">
|
<span style={{ maxWidth: 155 }} data-testid="header">
|
||||||
{datasetTitle}
|
{title ?? datasetTitle}
|
||||||
</span>
|
</span>
|
||||||
</Truncate>
|
</Truncate>
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Reference in New Issue
Block a user