Skip to content

Commit

Permalink
fix: use the accessManagement property for filters
Browse files Browse the repository at this point in the history
  • Loading branch information
fboulnois committed Nov 16, 2023
1 parent 0ac2a75 commit c93b48f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
33 changes: 17 additions & 16 deletions src/components/data_search/DatasetFilterList.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { Checkbox } from '@mui/material';
export const DatasetFilterList = (props) => {
const { datasets, filters, filterHandler } = props;

const accessManagementFilters = ['Controlled', 'Open', 'External'];

const isFiltered = (filter) => filters.indexOf(filter) > -1;

return (
Expand All @@ -24,22 +26,21 @@ export const DatasetFilterList = (props) => {
Access Type
</Typography>
<List sx={{ margin: '-0.5em -0.5em'}}>
<ListItem disablePadding>
<ListItemButton sx={{ padding: '0' }} onClick={(event) => filterHandler(event, datasets, 'open')}>
<ListItemIcon>
<Checkbox checked={isFiltered('open')} />
</ListItemIcon>
<ListItemText primary="Open" sx={{ fontFamily: 'Montserrat', transform: 'scale(1.2)' }} />
</ListItemButton>
</ListItem>
<ListItem disablePadding>
<ListItemButton sx={{ padding: '0' }} onClick={(event) => filterHandler(event, datasets, 'controlled')}>
<ListItemIcon>
<Checkbox checked={isFiltered('controlled')} />
</ListItemIcon>
<ListItemText primary="Controlled" sx={{ fontFamily: 'Montserrat', transform: 'scale(1.2)' }} />
</ListItemButton>
</ListItem>
{
accessManagementFilters.map((filterName) => {
const filter = filterName.toLowerCase();
return (
<ListItem disablePadding key={filter}>
<ListItemButton sx={{ padding: '0' }} onClick={(event) => filterHandler(event, datasets, filter)}>
<ListItemIcon>
<Checkbox checked={isFiltered(filter)} />
</ListItemIcon>
<ListItemText primary={filterName} sx={{ fontFamily: 'Montserrat', transform: 'scale(1.2)' }} />
</ListItemButton>
</ListItem>
);
})
}
</List>
</Box>
);
Expand Down
8 changes: 6 additions & 2 deletions src/components/data_search/DatasetSearchTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ export const DatasetSearchTable = (props) => {
newFiltered = data;
} else {
newFiltered = data.filter((dataset) => {
if (newFilters.includes('open') && dataset.openAccess) {
// TODO: remove extra checks when openAccess property is deprecated
if (newFilters.includes('open') && (dataset.openAccess || dataset.accessManagement === 'open')) {
return true;
}
if (newFilters.includes('controlled') && !dataset.openAccess) {
if (newFilters.includes('controlled') && (!dataset.openAccess || dataset.accessManagement === 'controlled')) {
return true;
}
if (newFilters.includes('external') && dataset.accessManagement === 'external') {
return true;
}
return false;
Expand Down

0 comments on commit c93b48f

Please sign in to comment.