Skip to content

Commit

Permalink
refactor: make prop names consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammer5 committed Aug 14, 2020
1 parent 74ff168 commit 13a1804
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 35 deletions.
30 changes: 15 additions & 15 deletions packages/widgets/src/Transfer/Transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const Transfer = ({
leftFooter,
leftHeader,
loadingPicked,
loadingSource,
loading,
maxSelections,
optionsWidth,
removeAllText,
Expand All @@ -105,9 +105,9 @@ export const Transfer = ({
selectedWidth,
sourceEmptyPlaceholder,
onFilterChange,
onFilterPickedChange,
onSourceEndReached,
onPickedEndReached,
onFilterChangePicked,
onEndReached,
onEndReachedPicked,
}) => {
/* Source options search value:
* Depending on whether the onFilterChange callback has been provided
Expand Down Expand Up @@ -149,7 +149,7 @@ export const Transfer = ({
})

/* Picked options search value:
* Depending on whether the onFilterPickedChange callback has been provided
* Depending on whether the onFilterChangePicked callback has been provided
* either the internal or external search value is used */
const {
filterValue: actualFilterPicked,
Expand All @@ -158,7 +158,7 @@ export const Transfer = ({
} = useFilter({
filterable: filterablePicked,
initialSearchTerm: initialSearchTermPicked,
onFilterChange: onFilterPickedChange,
onFilterChange: onFilterChangePicked,
externalSearchTerm: searchTermPicked,
filterCallback: filterCallbackPicked,
})
Expand Down Expand Up @@ -246,12 +246,12 @@ export const Transfer = ({
emptyComponent={sourceEmptyPlaceholder}
getOptionClickHandlers={getOptionClickHandlers}
highlightedOptions={highlightedSourceOptions}
loading={loadingSource}
loading={loading}
options={sourceOptions}
renderOption={renderOption}
selectionHandler={selectSingleOption}
toggleHighlightedOption={toggleHighlightedSourceOption}
onEndReached={onSourceEndReached}
onEndReached={onEndReached}
/>

{leftFooter && (
Expand Down Expand Up @@ -338,8 +338,8 @@ export const Transfer = ({
dataTest={`${dataTest}-filter`}
filter={actualFilterPicked}
onChange={
onFilterPickedChange
? onFilterPickedChange
onFilterChangePicked
? onFilterChangePicked
: ({ value }) =>
setInternalFilterPicked(value)
}
Expand All @@ -358,7 +358,7 @@ export const Transfer = ({
renderOption={renderOption}
selectionHandler={deselectSingleOption}
toggleHighlightedOption={toggleHighlightedPickedOption}
onEndReached={onPickedEndReached}
onEndReached={onEndReachedPicked}
/>

{(rightFooter || enableOrderChange) && (
Expand Down Expand Up @@ -479,8 +479,8 @@ Transfer.propTypes = {
initialSearchTermPicked: propTypes.string,
leftFooter: propTypes.node,
leftHeader: propTypes.node,
loading: propTypes.bool,
loadingPicked: propTypes.bool,
loadingSource: propTypes.bool,
maxSelections: propTypes.oneOf([1, Infinity]),
optionsWidth: propTypes.string,
removeAllText: propTypes.string,
Expand All @@ -494,8 +494,8 @@ Transfer.propTypes = {
selectedEmptyComponent: propTypes.node,
selectedWidth: propTypes.string,
sourceEmptyPlaceholder: propTypes.node,
onEndReached: propTypes.func,
onEndReachedPicked: propTypes.func,
onFilterChange: propTypes.func,
onFilterPickedChange: propTypes.func,
onPickedEndReached: propTypes.func,
onSourceEndReached: propTypes.func,
onFilterChangePicked: propTypes.func,
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ import { options } from './common/options'
export default { title: 'Transfer Loading Lists' }

export const LoadingSource = () => (
<Transfer
loadingSource
selected={[]}
onChange={() => null}
options={options}
/>
<Transfer loading selected={[]} onChange={() => null} options={options} />
)

export const LoadingPicked = () => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ export default {
decorators: [statefulDecorator()],
}

window.onSourceEndReached = window.Cypress
window.onEndReached = window.Cypress
? window.Cypress.cy.stub()
: () => console.log('onSourceEndReached')
: () => console.log('onEndReached')

window.onPickedEndReached = window.Cypress
window.onEndReachedPicked = window.Cypress
? window.Cypress.cy.stub()
: () => console.log('onPickedEndReached')
: () => console.log('onEndReachedPicked')

export const FullSourceList = ({ selected, onChange }) => (
<Transfer
options={options}
selected={selected}
onChange={onChange}
onSourceEndReached={window.onSourceEndReached}
onEndReached={window.onEndReached}
/>
)

Expand All @@ -32,7 +32,7 @@ export const FullPickedList = ({ selected, onChange }) => (
options={options}
selected={selected}
onChange={onChange}
onPickedEndReached={window.onPickedEndReached}
onEndReachedPicked={window.onEndReachedPicked}
/>
)

Expand All @@ -49,7 +49,7 @@ export const PartialSourceList = ({ selected, onChange }) => (
options={options.slice(0, 4)}
selected={selected}
onChange={onChange}
onSourceEndReached={window.onSourceEndReached}
onEndReached={window.onEndReached}
/>
)

Expand All @@ -58,7 +58,7 @@ export const PartialPickedList = ({ selected, onChange }) => (
options={options}
selected={selected}
onChange={onChange}
onPickedEndReached={window.onPickedEndReached}
onEndReachedPicked={window.onEndReachedPicked}
/>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ Then('the callback for reaching the end should not be called', () => {
() => cy.get('@listType')
).should(([win, listType]) => {
const callback =
listType === 'source'
? win.onSourceEndReached
: win.onPickedEndReached
listType === 'source' ? win.onEndReached : win.onEndReachedPicked

expect(callback).to.not.be.called
})
Expand All @@ -75,9 +73,7 @@ Then('the callback for reaching the end should be called', () => {
() => cy.get('@listType')
).should(([win, listType]) => {
const callback =
listType === 'source'
? win.onSourceEndReached
: win.onPickedEndReached
listType === 'source' ? win.onEndReached : win.onEndReachedPicked

expect(callback).to.be.calledOnce
})
Expand Down

0 comments on commit 13a1804

Please sign in to comment.