-
Notifications
You must be signed in to change notification settings - Fork 4
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-788] Footer: Apply for Access to selected Studies and Datasets #2723
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a2e3725
add new footer component and add to the table
raejohanek 1784093
Merge branch 'develop' into rj/dt-788-footer
raejohanek 559a198
linting
raejohanek fc9188c
PR feedback: simplify div logic
raejohanek 9f7b606
add unit test for new footer component
raejohanek 97afe13
simplify test data
raejohanek 71cb122
remove circular dependency
raejohanek a21842a
add test for footer on dataset search table
raejohanek 85de688
add new lines at end of files
raejohanek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
cypress/component/DataSearch/dataset_search_footer.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* eslint-disable no-undef */ | ||
import {mount} from 'cypress/react'; | ||
import {React} from 'react'; | ||
import {DatasetSearchFooter} from '../../../src/components/data_search/DatasetSearchFooter'; | ||
|
||
const datasets = [ | ||
{ | ||
datasetId: 123456, | ||
study: { | ||
studyId: 1, | ||
} | ||
}, | ||
{ | ||
datasetId: 234567, | ||
study: { | ||
studyId: 1, | ||
} | ||
}, | ||
{ | ||
datasetId: 345678, | ||
study: { | ||
studyId: 2, | ||
} | ||
}, | ||
]; | ||
|
||
const oneDatasetProps = { | ||
selectedDatasets: [123456], | ||
datasets: datasets, | ||
onClick: () => {}, | ||
}; | ||
|
||
const oneStudyProps = { | ||
selectedDatasets: [123456, 234567], | ||
datasets: datasets, | ||
onClick: () => {}, | ||
}; | ||
|
||
const twoStudiesProps = { | ||
selectedDatasets: [123456, 234567, 345678], | ||
datasets: datasets, | ||
onClick: () => {}, | ||
}; | ||
|
||
describe('Dataset Search Footer renders correct text and button', () => { | ||
|
||
it('Shows button and single dataset and study text', () => { | ||
mount(<DatasetSearchFooter {...oneDatasetProps} />); | ||
cy.contains('1 dataset selected from 1 study'); | ||
cy.contains('Apply for Access'); | ||
}); | ||
|
||
|
||
it('Shows button and two datasets from one study text', () => { | ||
mount(<DatasetSearchFooter {...oneStudyProps} />); | ||
cy.contains('2 datasets selected from 1 study'); | ||
cy.contains('Apply for Access'); | ||
}); | ||
|
||
it('Shows button and three datasets from two studies text', () => { | ||
mount(<DatasetSearchFooter {...twoStudiesProps} />); | ||
cy.contains('3 datasets selected from 2 studies'); | ||
cy.contains('Apply for Access'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* eslint-disable no-undef */ | ||
import {React} from 'react'; | ||
import {mount} from 'cypress/react'; | ||
import DatasetSearchTable from '../../../src/components/data_search/DatasetSearchTable'; | ||
import {TerraDataRepo} from '../../../src/libs/ajax/TerraDataRepo'; | ||
|
||
const datasets = [ | ||
{ | ||
datasetId: 123456, | ||
datasetIdentifier: `DUOS-123456`, | ||
datasetName: 'Some Dataset 1', | ||
study: { | ||
studyId: 1, | ||
dataCustodianEmail: ['Some Data Custodian Email 1'], | ||
} | ||
} | ||
]; | ||
|
||
const props = { | ||
datasets: datasets, | ||
history: {} | ||
}; | ||
|
||
describe('Dataset Search Table tests', () => { | ||
|
||
describe('Data library with three datasets', () => { | ||
beforeEach(() => { | ||
cy.stub(TerraDataRepo, 'listSnapshotsByDatasetIds').returns({}); | ||
mount(<DatasetSearchTable {...props} />); | ||
}); | ||
|
||
it('When no datasets are selected the footer does not appear', () => { | ||
cy.contains('1 dataset selected from 1 study').should('not.exist'); | ||
}); | ||
|
||
|
||
it('When a dataset is selected the footer appears', () => { | ||
cy.get('#header-checkbox').click(); | ||
cy.contains('1 dataset selected from 1 study'); | ||
}); | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import {Styles} from '../../libs/theme'; | ||
|
||
export const styles = { | ||
baseStyle: { | ||
fontFamily: 'Montserrat', | ||
fontSize: '1.6rem', | ||
fontWeight: 400, | ||
display: 'flex', | ||
padding: '1rem 2%', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
whiteSpace: 'pre-wrap', | ||
backgroundColor: 'white', | ||
border: '1px solid #DEDEDE', | ||
borderRadius: '4px', | ||
margin: '0.5% 0' | ||
}, | ||
columnStyle: Object.assign({}, Styles.TABLE.HEADER_ROW, { | ||
justifyContent: 'space-between', | ||
color: '#7B7B7B', | ||
fontFamily: 'Montserrat', | ||
fontSize: '1.2rem', | ||
fontWeight: 'bold', | ||
letterSpacing: '0.2px', | ||
textTransform: 'uppercase', | ||
backgroundColor: 'B8CDD3', | ||
border: 'none' | ||
}), | ||
cellWidths: { | ||
duosId: '10%', | ||
phsId: '10%', | ||
datasetName: '15%', | ||
studyName: '15%', | ||
dataSubmitter: '15%', | ||
dataCustodian: '15%', | ||
dataUse: '10%', | ||
status: '10%' | ||
}, | ||
color: { | ||
dataUseGroup: '#000000', | ||
votes: '#000000', | ||
numberOfDatasets: '#000000', | ||
datasets: '#000000', | ||
}, | ||
fontSize: { | ||
dataUseGroup: '1.4rem', | ||
votes: '1.4rem', | ||
numberOfDatasets: '1.4rem', | ||
datasets: '1.4rem', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import React from 'react'; | ||
import style from '../../pages/DACDatasets.module.css'; | ||
import {styles} from './DACDatasetsTable'; | ||
import {styles} from './DACDatasetConstants'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removing circular dependency discovered when testing |
||
import DACDatasetApprovalStatus from './DACDatasetApprovalStatus'; | ||
import ReactTooltip from 'react-tooltip'; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import * as _ from 'lodash'; | ||
import {Button} from '@mui/material'; | ||
import * as React from 'react'; | ||
import {Dataset} from 'src/types/model'; | ||
|
||
interface DatasetSearchFooterProps { | ||
selectedDatasets: number[]; | ||
datasets: Dataset[]; | ||
onClick: () => void; | ||
} | ||
export const DatasetSearchFooter = (props: DatasetSearchFooterProps) => { | ||
const { selectedDatasets, datasets, onClick } = props; | ||
const selectedStudies = _.uniq( | ||
_.filter(datasets, dataset => selectedDatasets.includes(dataset.datasetId)) | ||
.map(dataset => dataset.study.studyId)); | ||
const datasetText = selectedDatasets.length > 1 ? 'datasets' : 'dataset'; | ||
const studyText = selectedStudies.length > 1 ? 'studies' : 'study'; | ||
|
||
return <div style={{ | ||
position: 'fixed', | ||
bottom: 0, | ||
zIndex: 999, | ||
width: '100vw', | ||
height: 60, | ||
display: 'flex', | ||
justifyContent: 'flex-end', | ||
backgroundColor: 'white', | ||
border: '1px solid #DEDEDE', | ||
alignItems: 'center' | ||
}}> | ||
<div style={{paddingRight: 15}}>{selectedDatasets.length} {datasetText} selected from {selectedStudies.length} {studyText}</div> | ||
<Button | ||
variant='contained' | ||
onClick={onClick} | ||
sx={{fontSize: 14, height: 35, marginRight: 5}} | ||
> | ||
Apply for Access | ||
</Button> | ||
</div>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,7 +79,7 @@ export const makeStudyTableHeaders = (datasets: DatasetTerm[], selected: number[ | |
const selectableDatasetIds = datasets.filter(isSelectable).map(dataset => dataset.datasetId); | ||
return [ | ||
{ | ||
label: <Checkbox checked={datasets.length === selected.length} | ||
label: <Checkbox id='header-checkbox' checked={datasets.length === selected.length} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added the id here so the element is easily retrievable in testing |
||
indeterminate={selected.length > 0 && selected.length < selectableDatasetIds.length} | ||
onClick={() => onSelect(selectableDatasetIds.length === selected.length ? [] : selectableDatasetIds)}/>, | ||
sortable: false, | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another approach to this is to use modular css. We have several examples in the codebase for this. If the style objects are being manipulated by components, then I think that approach wouldn't work.