From 13a1804714cf464acdd439f00e4f1b8c122b18ba Mon Sep 17 00:00:00 2001 From: Jan-Gerke Salomon Date: Fri, 14 Aug 2020 13:30:40 +0200 Subject: [PATCH] refactor: make prop names consistent --- packages/widgets/src/Transfer/Transfer.js | 30 +++++++++---------- .../__e2e__/loading_lists.stories.e2e.js | 7 +---- .../notify_at_end_of_list.stories.e2e.js | 16 +++++----- .../features/notify_at_end_of_list/index.js | 8 ++--- 4 files changed, 26 insertions(+), 35 deletions(-) diff --git a/packages/widgets/src/Transfer/Transfer.js b/packages/widgets/src/Transfer/Transfer.js index 88aaaae220..c706e9cfd0 100644 --- a/packages/widgets/src/Transfer/Transfer.js +++ b/packages/widgets/src/Transfer/Transfer.js @@ -90,7 +90,7 @@ export const Transfer = ({ leftFooter, leftHeader, loadingPicked, - loadingSource, + loading, maxSelections, optionsWidth, removeAllText, @@ -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 @@ -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, @@ -158,7 +158,7 @@ export const Transfer = ({ } = useFilter({ filterable: filterablePicked, initialSearchTerm: initialSearchTermPicked, - onFilterChange: onFilterPickedChange, + onFilterChange: onFilterChangePicked, externalSearchTerm: searchTermPicked, filterCallback: filterCallbackPicked, }) @@ -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 && ( @@ -338,8 +338,8 @@ export const Transfer = ({ dataTest={`${dataTest}-filter`} filter={actualFilterPicked} onChange={ - onFilterPickedChange - ? onFilterPickedChange + onFilterChangePicked + ? onFilterChangePicked : ({ value }) => setInternalFilterPicked(value) } @@ -358,7 +358,7 @@ export const Transfer = ({ renderOption={renderOption} selectionHandler={deselectSingleOption} toggleHighlightedOption={toggleHighlightedPickedOption} - onEndReached={onPickedEndReached} + onEndReached={onEndReachedPicked} /> {(rightFooter || enableOrderChange) && ( @@ -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, @@ -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, } diff --git a/packages/widgets/src/Transfer/__e2e__/loading_lists.stories.e2e.js b/packages/widgets/src/Transfer/__e2e__/loading_lists.stories.e2e.js index eb61014403..8acccb4999 100644 --- a/packages/widgets/src/Transfer/__e2e__/loading_lists.stories.e2e.js +++ b/packages/widgets/src/Transfer/__e2e__/loading_lists.stories.e2e.js @@ -6,12 +6,7 @@ import { options } from './common/options' export default { title: 'Transfer Loading Lists' } export const LoadingSource = () => ( - null} - options={options} - /> + null} options={options} /> ) export const LoadingPicked = () => ( diff --git a/packages/widgets/src/Transfer/__e2e__/notify_at_end_of_list.stories.e2e.js b/packages/widgets/src/Transfer/__e2e__/notify_at_end_of_list.stories.e2e.js index b451b14f75..aa0f48ca8c 100644 --- a/packages/widgets/src/Transfer/__e2e__/notify_at_end_of_list.stories.e2e.js +++ b/packages/widgets/src/Transfer/__e2e__/notify_at_end_of_list.stories.e2e.js @@ -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 }) => ( ) @@ -32,7 +32,7 @@ export const FullPickedList = ({ selected, onChange }) => ( options={options} selected={selected} onChange={onChange} - onPickedEndReached={window.onPickedEndReached} + onEndReachedPicked={window.onEndReachedPicked} /> ) @@ -49,7 +49,7 @@ export const PartialSourceList = ({ selected, onChange }) => ( options={options.slice(0, 4)} selected={selected} onChange={onChange} - onSourceEndReached={window.onSourceEndReached} + onEndReached={window.onEndReached} /> ) @@ -58,7 +58,7 @@ export const PartialPickedList = ({ selected, onChange }) => ( options={options} selected={selected} onChange={onChange} - onPickedEndReached={window.onPickedEndReached} + onEndReachedPicked={window.onEndReachedPicked} /> ) diff --git a/packages/widgets/src/Transfer/features/notify_at_end_of_list/index.js b/packages/widgets/src/Transfer/features/notify_at_end_of_list/index.js index 371af7ead5..1e7715f249 100644 --- a/packages/widgets/src/Transfer/features/notify_at_end_of_list/index.js +++ b/packages/widgets/src/Transfer/features/notify_at_end_of_list/index.js @@ -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 }) @@ -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 })