Skip to content

Commit

Permalink
Use "missing" instead of undefined in datasets tab
Browse files Browse the repository at this point in the history
  • Loading branch information
kreafox committed Feb 9, 2023
1 parent fa2bcb7 commit e215775
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
15 changes: 12 additions & 3 deletions src/components/ItemView/Datasets.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ const Datasets = (props) => {
setActiveIndex(newIndex);
}

const datasets = React.useMemo(
const sortedDatasets = React.useMemo(
() =>
(children || []).sort(
(a, b) =>
Expand All @@ -289,7 +289,12 @@ const Datasets = (props) => {
[children],
);

const datasetsByYear = groupBy(datasets, 'publicationYearForResource');
const datasets = groupBy(sortedDatasets, 'publicationYearForResource');

const datasetsByYear = {};
delete Object.assign(datasetsByYear, datasets, {
Missing: datasets['undefined'],
})['undefined'];

const panes = Object.keys(datasetsByYear).map((dataset) => ({
menuItem: dataset,
Expand Down Expand Up @@ -413,8 +418,12 @@ const Datasets = (props) => {
),
}));

return datasets && datasets.length > 0 ? (
return children && children.length > 0 ? (
<>
<div className="dataset-container">
<h2>Datasets</h2>
</div>

<div className="item tabs-title">Publication year</div>
<Tab
className="datasets-tab"
Expand Down
4 changes: 0 additions & 4 deletions src/components/ItemView/ItemView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,6 @@ function ItemView(props) {
<Callout>{description?.raw}</Callout>
</div>

<div className="dataset-container">
<h2>Datasets</h2>
</div>

<Datasets item={item} appConfig={appConfig} />

<MetadataSection item={item} appConfig={appConfig} docid={docid} />
Expand Down

0 comments on commit e215775

Please sign in to comment.