Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DT-791] Add count to top of data library #2758

Merged
merged 3 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/data_search/DatasetSearchTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export const DatasetSearchTable = (props) => {
>
{Object.values(datasetSearchTableTabs).map((tab) => <Tab
key={tab.key}
label={tab.label}
label={`View By ${_.capitalize(tab.plural)}`}
style={{
...styles.subTab,
...(tab.key === selectedTable.key ? styles.subTabActive : {})
Expand Down
9 changes: 6 additions & 3 deletions src/components/data_search/DatasetSearchTableConstants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import './DatasetSearch.css';

export interface DatasetSearchTableTab<T> {
key: string;
label: string;
singular: string;
plural: string;
makeHeaders: (datasets: DatasetTerm[], selected: number[], onSelect: (datasetIds: number[]) => void, exportableDatasets: { [duosId: string]: SnapshotSummaryModel[] }) => HeaderData<T>[];
makeRows: (datasets: DatasetTerm[], headers: HeaderData<T>[]) => CellData[][];
}
Expand Down Expand Up @@ -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,
}
Expand Down
38 changes: 20 additions & 18 deletions src/components/data_search/DatasetSearchTableDisplay.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -8,6 +7,7 @@ import {
DatasetSearchTableTab,
} from './DatasetSearchTableConstants';
import {SnapshotSummaryModel} from '../../types/tdrModel';
import * as _ from 'lodash';

const styles = {
baseStyle: {
Expand Down Expand Up @@ -54,21 +54,23 @@ export const DatasetSearchTableDisplay = (props: DatasetSearchTableDisplayProps)
const headers = tab.makeHeaders(filteredData, selected, onSelect, exportableDatasets);
const rowData = tab.makeRows(filteredData, headers);

return isEmpty(filteredData) ? (
<Box sx={{
display: 'flex',
flexDirection: 'column', alignItems: 'center', justifyContent: 'center', height: '100%' }}>
<h1>There are no datasets that fit these criteria.</h1>
</Box>
)
: (
<SimpleTable
rowData={rowData}
columnHeaders={headers}
selected={selected}
styles={styles}
tableSize={10}
summary='faceted dataset search table'
/>
);
return <>
<div style={{
fontWeight: 600,
borderBottom: '1px solid black'
}}>
{rowData.length} {_.capitalize(rowData.length !== 1 ? tab.plural : tab.singular)}
</div>
{
isEmpty(filteredData) ?
<div style={{fontWeight: 600, marginTop: '0.5rem'}}>There are no {tab.plural} that fit these criteria.</div> :
<SimpleTable
rowData={rowData}
columnHeaders={headers}
selected={selected}
styles={styles}
tableSize={10}
summary={`faceted ${tab.singular} search table`} />
}
</>;
};
Loading