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-902] Replace DAC Column with Data Use Column in Data Library Dataset Table #2705

Merged
merged 3 commits into from
Nov 1, 2024
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
10 changes: 5 additions & 5 deletions src/components/dac_dataset_table/DACDatasetTableCellData.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function dataCustodianCellData({dataset, label = 'dataCustodianCellData'}
};
}

export function dataUseCellData({dataset, label = 'dataUseCellData'}) {
export function dataUseCellData({dataset, label = 'dataUseCellData', divClass = style['cell-data'], spanClass = style['data-use'], cellWidth = styles.cellWidths.dataUse, tooltipPlace = 'right'}) {
const codesAndDescriptions = dataset.dataUse?.primary ? dataset.dataUse.primary.map((dataUse) => {
if (dataUse.code === 'OTHER') {
return {'code': `OTH1`, 'description': dataUse.description};
Expand All @@ -93,10 +93,10 @@ export function dataUseCellData({dataset, label = 'dataUseCellData'}) {
}
const codeList = codesAndDescriptions.map(du => du.code);
const display =
<div className={style['cell-data']}>
<span className={style['data-use']} data-tip={true} data-for={`dataset-data-use-${dataset.datasetId}`}>{codeList.join(', ')}</span>
<div className={divClass}>
<span className={spanClass} data-tip={true} data-for={`dataset-data-use-${dataset.datasetId}`}>{codeList.join(', ')}</span>
<ReactTooltip
place={'right'}
place={tooltipPlace}
effect={'solid'}
id={`dataset-data-use-${dataset.datasetId}`}>
<ul>{codesAndDescriptions.map((translation, index) => {
Expand All @@ -108,7 +108,7 @@ export function dataUseCellData({dataset, label = 'dataUseCellData'}) {
data: display,
value: codeList.join(', '),
id: `data-use-cell-data-${dataset.datasetId}`,
cellStyle: {width: styles.cellWidths.dataUse},
cellStyle: {width: cellWidth},
label
};
}
Expand Down
5 changes: 5 additions & 0 deletions src/components/data_search/DatasetSearch.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.data-use-cell {
overflow: hidden;
text-overflow: ellipsis;
text-wrap: nowrap;
}
28 changes: 15 additions & 13 deletions src/components/data_search/DatasetSearchTableConstants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {OverflowTooltip, tooltipStyle} from '../Tooltips';
import {SnapshotSummaryModel} from 'src/types/tdrModel';
import DatasetExportButton from './DatasetExportButton';
import ReactTooltip from 'react-tooltip';
import {dataUseCellData} from '../dac_dataset_table/DACDatasetTableCellData';
import './DatasetSearch.css';

export interface DatasetSearchTableTab<T> {
key: string;
Expand Down Expand Up @@ -230,7 +232,7 @@ export const makeDatasetTableHeader = (datasets: DatasetTerm[], selected: number
dataType: string;
donorSize: string;
dataLocation: string;
dac: string;
dataUse: string;
exportToTerra: number;
}
const cellWidths: CellWidths = {
Expand All @@ -243,7 +245,7 @@ export const makeDatasetTableHeader = (datasets: DatasetTerm[], selected: number
dataType: '15%',
donorSize: '7%',
dataLocation: '13%',
dac: '10%',
dataUse: '10%',
exportToTerra: 100,
};
const isSelectable = (dataset: DatasetTerm) => dataset.accessManagement != 'open' && dataset.accessManagement != 'external';
Expand Down Expand Up @@ -402,18 +404,18 @@ export const makeDatasetTableHeader = (datasets: DatasetTerm[], selected: number
}
},
{
label: 'DAC',
label: 'Data Use',
sortable: true,
cellStyle: makeHeaderStyle(cellWidths.dac),
cellDataFn: (dataset: DatasetTerm) => ({
data: <OverflowTooltip place={'top'} tooltipText={dataset.dac?.dacName} id={`${dataset.datasetId}-dataset-dac`}>
{dataset.dac?.dacName}
</OverflowTooltip>,
value: dataset.dac?.dacName,
id: `${dataset.datasetId}-dac`,
style: makeRowStyle(cellWidths.dac),
label: `DAC for dataset ${dataset.datasetId}: ${dataset.dac?.dacName}`
})
cellStyle: makeHeaderStyle(cellWidths.dataUse),
cellDataFn: (dataset: DatasetTerm) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole function reuses the Data Use logic used on the DAC Datasets table (in the file DACDatasetTableCellData.jsx) to maintain consistency in how each table's Data Use column behaves/looks. It's not as clean as the other cellDataFn's in this file so I'm open to feedback/suggestions on what to do here if this isn't the best approach

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update - Adjusted to using helper function instead

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's okay. I would rather it be different here than duplicate the logic in multiple places.

return dataUseCellData({
dataset,
label: `Data Use for dataset ${dataset.datasetId}: ${dataset.dataUse}`,
divClass: ['data-use-cell'],
spanClass: [],
cellWidth: cellWidths.dataUse,
tooltipPlace: 'top'});
}
},
{
label: 'Export to Terra',
Expand Down
Loading