mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-08 20:58:11 +08:00
Fix InfoFormat parameter checking (#1831)
Went through and ensured that undefined/null values were caught and handled correctly in render functions. Also documented some of the more complicated functions. --- Closes #1825
This commit is contained in:
@@ -3,7 +3,7 @@ import React from "react";
|
|||||||
|
|
||||||
const renderContributors = (contributors, affiliations, skeleton) => {
|
const renderContributors = (contributors, affiliations, skeleton) => {
|
||||||
// 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?.length === 0 && true) return null;
|
if (!contributors || contributors.length === 0 || true) return null;
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<H3 className={skeleton ? Classes.SKELETON : null}>Contributors</H3>
|
<H3 className={skeleton ? Classes.SKELETON : null}>Contributors</H3>
|
||||||
@@ -25,6 +25,7 @@ const renderContributors = (contributors, affiliations, skeleton) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// generates a list of unique institutions by order of appearance in contributors
|
||||||
const buildAffiliations = (contributors = []) => {
|
const buildAffiliations = (contributors = []) => {
|
||||||
const affiliations = [];
|
const affiliations = [];
|
||||||
contributors.forEach((contributor) => {
|
contributors.forEach((contributor) => {
|
||||||
@@ -43,11 +44,7 @@ const renderAffiliations = (affiliations, skeleton) => {
|
|||||||
<H3 className={skeleton ? Classes.SKELETON : null}>Affiliations</H3>
|
<H3 className={skeleton ? Classes.SKELETON : null}>Affiliations</H3>
|
||||||
<UL>
|
<UL>
|
||||||
{affiliations.map((item, index) => (
|
{affiliations.map((item, index) => (
|
||||||
<div
|
<div key={item} className={skeleton ? Classes.SKELETON : null}>
|
||||||
id={`#afil${index}`}
|
|
||||||
key={item}
|
|
||||||
className={skeleton ? Classes.SKELETON : null}
|
|
||||||
>
|
|
||||||
<sup>{index + 1}</sup>
|
<sup>{index + 1}</sup>
|
||||||
{" "}
|
{" "}
|
||||||
{item}
|
{item}
|
||||||
@@ -61,16 +58,14 @@ const renderAffiliations = (affiliations, skeleton) => {
|
|||||||
const renderDOILink = (type, doi, skeleton) => {
|
const renderDOILink = (type, doi, skeleton) => {
|
||||||
if (!doi) return null;
|
if (!doi) return null;
|
||||||
return (
|
return (
|
||||||
doi && (
|
<>
|
||||||
<>
|
<H3 className={skeleton ? Classes.SKELETON : null}>{type}</H3>
|
||||||
<H3 className={skeleton ? Classes.SKELETON : null}>{type}</H3>
|
<p className={skeleton ? Classes.SKELETON : null}>
|
||||||
<p className={skeleton ? Classes.SKELETON : null}>
|
<a href={doi} target="_blank" rel="noopener">
|
||||||
<a href={doi} target="_blank" rel="noopener">
|
{doi}
|
||||||
{doi}
|
</a>
|
||||||
</a>
|
</p>
|
||||||
</p>
|
</>
|
||||||
</>
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -84,6 +79,8 @@ const renderOrganism = (organism, skeleton) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Render list of metadata attributes found in categorical field
|
||||||
|
// Ignores categories with empty or null values
|
||||||
const renderSingleValueCategories = (singleValueCategories, skeleton) => {
|
const renderSingleValueCategories = (singleValueCategories, skeleton) => {
|
||||||
if (singleValueCategories.size === 0) return null;
|
if (singleValueCategories.size === 0) return null;
|
||||||
return (
|
return (
|
||||||
@@ -104,6 +101,8 @@ const renderSingleValueCategories = (singleValueCategories, skeleton) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 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, skeleton) => {
|
const renderLinks = (projectLinks, aboutURL, skeleton) => {
|
||||||
if (!projectLinks && !aboutURL) return null;
|
if (!projectLinks && !aboutURL) return null;
|
||||||
if (projectLinks)
|
if (projectLinks)
|
||||||
@@ -147,6 +146,7 @@ const renderLinks = (projectLinks, aboutURL, skeleton) => {
|
|||||||
|
|
||||||
const NUM_CATEGORIES = 8;
|
const NUM_CATEGORIES = 8;
|
||||||
|
|
||||||
|
// Generates arbitrary placeholder array for singleValueCategories skeleton shape
|
||||||
const singleValueCategoriesPlaceholder = Array.from(Array(NUM_CATEGORIES)).map(
|
const singleValueCategoriesPlaceholder = Array.from(Array(NUM_CATEGORIES)).map(
|
||||||
(_, index) => {
|
(_, index) => {
|
||||||
return [index, index];
|
return [index, index];
|
||||||
|
|||||||
Reference in New Issue
Block a user