From 69c213fe4b3a7a8f9772b63321cb3ca0e3d53b25 Mon Sep 17 00:00:00 2001 From: Sky Rubenstein Date: Fri, 20 Dec 2024 16:02:52 -0500 Subject: [PATCH 1/3] Add count to top of data library --- .../data_search/DatasetSearchTable.jsx | 2 +- .../DatasetSearchTableConstants.tsx | 9 ++++++--- .../data_search/DatasetSearchTableDisplay.tsx | 20 +++++++++++-------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/components/data_search/DatasetSearchTable.jsx b/src/components/data_search/DatasetSearchTable.jsx index a9d916f9b..1e5529c99 100644 --- a/src/components/data_search/DatasetSearchTable.jsx +++ b/src/components/data_search/DatasetSearchTable.jsx @@ -281,7 +281,7 @@ export const DatasetSearchTable = (props) => { > {Object.values(datasetSearchTableTabs).map((tab) => { key: string; - label: string; + singular: string; + plural: string; makeHeaders: (datasets: DatasetTerm[], selected: number[], onSelect: (datasetIds: number[]) => void, exportableDatasets: { [duosId: string]: SnapshotSummaryModel[] }) => HeaderData[]; makeRows: (datasets: DatasetTerm[], headers: HeaderData[]) => CellData[][]; } @@ -442,13 +443,15 @@ export const makeDatasetTableRows = (datasets: DatasetTerm[], headers: HeaderDat export const datasetSearchTableTabs: DatasetSearchTableTabs = { study: { key: 'study-table-tab', - label: 'View By Studies', + singular: 'study', + plural: 'studies', makeHeaders: makeStudyTableHeaders, makeRows: makeStudyTableRowData, }, dataset: { key: 'datasets-table-tab', - label: 'View By Datasets', + singular: 'dataset', + plural: 'datasets', makeHeaders: makeDatasetTableHeader, makeRows: makeDatasetTableRows, } diff --git a/src/components/data_search/DatasetSearchTableDisplay.tsx b/src/components/data_search/DatasetSearchTableDisplay.tsx index f469a8e77..ab9d5123b 100644 --- a/src/components/data_search/DatasetSearchTableDisplay.tsx +++ b/src/components/data_search/DatasetSearchTableDisplay.tsx @@ -8,6 +8,7 @@ import { DatasetSearchTableTab, } from './DatasetSearchTableConstants'; import {SnapshotSummaryModel} from '../../types/tdrModel'; +import * as _ from 'lodash'; const styles = { baseStyle: { @@ -62,13 +63,16 @@ export const DatasetSearchTableDisplay = (props: DatasetSearchTableDisplayProps) ) : ( - + <> +
{rowData.length} {_.capitalize(rowData.length > 1 ? tab.plural : tab.singular)}
+ + ); }; From 9eff72246e3cd918bafd15e1519ebf0034451185 Mon Sep 17 00:00:00 2001 From: Sky Rubenstein Date: Mon, 6 Jan 2025 10:57:11 -0500 Subject: [PATCH 2/3] Always have count and move up the no datasets fit --- .../data_search/DatasetSearchTableDisplay.tsx | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/components/data_search/DatasetSearchTableDisplay.tsx b/src/components/data_search/DatasetSearchTableDisplay.tsx index ab9d5123b..ccee9a899 100644 --- a/src/components/data_search/DatasetSearchTableDisplay.tsx +++ b/src/components/data_search/DatasetSearchTableDisplay.tsx @@ -1,5 +1,4 @@ import * as React from 'react'; -import {Box} from '@mui/material'; import {isEmpty} from 'lodash'; import {DatasetTerm} from 'src/types/model'; import SimpleTable from '../SimpleTable'; @@ -55,24 +54,23 @@ export const DatasetSearchTableDisplay = (props: DatasetSearchTableDisplayProps) const headers = tab.makeHeaders(filteredData, selected, onSelect, exportableDatasets); const rowData = tab.makeRows(filteredData, headers); - return isEmpty(filteredData) ? ( - -

There are no datasets that fit these criteria.

-
- ) - : ( - <> -
{rowData.length} {_.capitalize(rowData.length > 1 ? tab.plural : tab.singular)}
+ return <> +
+ {rowData.length} {_.capitalize(rowData.length !== 1 ? tab.plural : tab.singular)} +
+ { + isEmpty(filteredData) ? +
There are no datasets that fit these criteria.
: - - ); + summary='faceted dataset search table' /> + } + ; }; From d8686286710db26a3f317e1f2cb2570d2c1926ef Mon Sep 17 00:00:00 2001 From: Sky Rubenstein Date: Mon, 6 Jan 2025 13:52:25 -0500 Subject: [PATCH 3/3] PR feedback --- src/components/data_search/DatasetSearchTableDisplay.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/data_search/DatasetSearchTableDisplay.tsx b/src/components/data_search/DatasetSearchTableDisplay.tsx index ccee9a899..71f33f2e9 100644 --- a/src/components/data_search/DatasetSearchTableDisplay.tsx +++ b/src/components/data_search/DatasetSearchTableDisplay.tsx @@ -63,14 +63,14 @@ export const DatasetSearchTableDisplay = (props: DatasetSearchTableDisplayProps) { isEmpty(filteredData) ? -
There are no datasets that fit these criteria.
: +
There are no {tab.plural} that fit these criteria.
: + summary={`faceted ${tab.singular} search table`} /> } ; };