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

Framework: Replace flowRight occurences with compose for HOCs #3907

Merged
merged 2 commits into from
Dec 12, 2017
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
5 changes: 2 additions & 3 deletions blocks/library/image/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ import {
isEmpty,
map,
get,
flowRight,
} from 'lodash';

/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { Component } from '@wordpress/element';
import { Component, compose } from '@wordpress/element';
import { mediaUpload, createMediaFromFile, getBlobByURL, revokeBlobURL, viewPort } from '@wordpress/utils';
import {
Placeholder,
Expand Down Expand Up @@ -298,7 +297,7 @@ class ImageBlock extends Component {
}
}

export default flowRight( [
export default compose( [
withContext( 'editor' )( ( settings ) => {
return { settings };
} ),
Expand Down
6 changes: 3 additions & 3 deletions components/autocomplete/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
* External dependencies
*/
import classnames from 'classnames';
import { escapeRegExp, find, filter, map, flowRight } from 'lodash';
import { escapeRegExp, find, filter, map } from 'lodash';

/**
* WordPress dependencies
*/
import { Component, renderToString } from '@wordpress/element';
import { Component, compose, renderToString } from '@wordpress/element';
import { keycodes } from '@wordpress/utils';
import { __, _n, sprintf } from '@wordpress/i18n';

Expand Down Expand Up @@ -497,7 +497,7 @@ export class Autocomplete extends Component {
}
}

export default flowRight( [
export default compose( [
withSpokenMessages,
withInstanceId,
withFocusOutside, // this MUST be the innermost HOC as it calls handleFocusOutside
Expand Down
5 changes: 3 additions & 2 deletions editor/components/block-drop-zone/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
* External Dependencies
*/
import { connect } from 'react-redux';
import { reduce, get, find, flow } from 'lodash';
import { reduce, get, find } from 'lodash';

/**
* WordPress dependencies
*/
import { DropZone, withContext } from '@wordpress/components';
import { getBlockTypes } from '@wordpress/blocks';
import { compose } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -49,7 +50,7 @@ function BlockDropZone( { index, isLocked, ...props } ) {
);
}

export default flow(
export default compose(
connect(
undefined,
{ insertBlocks }
Expand Down
5 changes: 3 additions & 2 deletions editor/components/block-mover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
* External dependencies
*/
import { connect } from 'react-redux';
import { first, last, flow } from 'lodash';
import { first, last } from 'lodash';

/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { IconButton, withContext } from '@wordpress/components';
import { getBlockType } from '@wordpress/blocks';
import { compose } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -64,7 +65,7 @@ export function BlockMover( { onMoveUp, onMoveDown, isFirst, isLast, uids, block
);
}

export default flow(
export default compose(
connect(
( state, ownProps ) => {
const block = getBlock( state, first( ownProps.uids ) );
Expand Down
3 changes: 2 additions & 1 deletion editor/components/block-settings-menu/block-delete-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { flow, noop } from 'lodash';
*/
import { __ } from '@wordpress/i18n';
import { IconButton, withContext } from '@wordpress/components';
import { compose } from '@wordpress/element';

/**
* Internal dependencies
Expand All @@ -34,7 +35,7 @@ export function BlockDeleteButton( { onDelete, onClick = noop, isLocked, small =
);
}

export default flow(
export default compose(
connect(
undefined,
( dispatch, ownProps ) => ( {
Expand Down
5 changes: 3 additions & 2 deletions editor/components/block-switcher/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
* External dependencies
*/
import { connect } from 'react-redux';
import { every, uniq, get, reduce, find, flow } from 'lodash';
import { every, uniq, get, reduce, find } from 'lodash';

/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { Dropdown, Dashicon, IconButton, Toolbar, NavigableMenu, withContext } from '@wordpress/components';
import { getBlockType, getBlockTypes, switchToBlockType, BlockIcon } from '@wordpress/blocks';
import { compose } from '@wordpress/element';
import { keycodes } from '@wordpress/utils';

/**
Expand Down Expand Up @@ -126,7 +127,7 @@ function BlockSwitcher( { blocks, onTransform, isLocked } ) {
);
}

export default flow(
export default compose(
connect(
( state, ownProps ) => {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports[`DefaultBlockAppender no block present should match snapshot 1`] = `
<div
className="editor-default-block-appender"
>
<WrappedComponent />
<Connect(WrappedComponent) />
<input
className="editor-default-block-appender__content"
onClick={[Function]}
Expand Down
6 changes: 3 additions & 3 deletions editor/components/editor-global-keyboard-shortcuts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
* External dependencies
*/
import { connect } from 'react-redux';
import { first, last, flow } from 'lodash';
import { first, last } from 'lodash';

/**
* WordPress dependencies
*/
import { Component } from '@wordpress/element';
import { Component, compose } from '@wordpress/element';
import { KeyboardShortcuts, withContext } from '@wordpress/components';

/**
Expand Down Expand Up @@ -65,7 +65,7 @@ class EditorGlobalKeyboardShortcuts extends Component {
}
}

export default flow(
export default compose(
connect(
( state ) => {
return {
Expand Down
6 changes: 3 additions & 3 deletions editor/components/inserter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
*/
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { flowRight, isEmpty } from 'lodash';
import { isEmpty } from 'lodash';

/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { Dropdown, IconButton, withContext } from '@wordpress/components';
import { createBlock } from '@wordpress/blocks';
import { Component } from '@wordpress/element';
import { Component, compose } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -106,7 +106,7 @@ class Inserter extends Component {
}
}

export default flowRight( [
export default compose( [
connect(
( state ) => {
return {
Expand Down
10 changes: 5 additions & 5 deletions editor/components/inserter/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { connect } from 'react-redux';
* WordPress dependencies
*/
import { __, _n, sprintf } from '@wordpress/i18n';
import { Component } from '@wordpress/element';
import { Component, compose } from '@wordpress/element';
import {
TabPanel,
TabbableContainer,
Expand Down Expand Up @@ -365,9 +365,9 @@ const connectComponent = connect(
{ showInsertionPoint, hideInsertionPoint, fetchReusableBlocks }
);

export default flow(
withInstanceId,
withSpokenMessages,
export default compose(
connectComponent,
withContext( 'editor' )( ( settings ) => pick( settings, 'blockTypes' ) ),
connectComponent
withSpokenMessages,
withInstanceId
)( InserterMenu );
5 changes: 3 additions & 2 deletions editor/components/page-attributes/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
* External dependencies
*/
import { connect } from 'react-redux';
import { get, flowRight } from 'lodash';
import { get } from 'lodash';

/**
* WordPress dependencies
*/
import { withAPIData } from '@wordpress/components';
import { compose } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -44,7 +45,7 @@ const applyWithAPIData = withAPIData( ( props ) => {
};
} );

export default flowRight( [
export default compose( [
applyConnect,
applyWithAPIData,
] )( PageAttributesCheck );
4 changes: 2 additions & 2 deletions editor/components/page-attributes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
* External dependencies
*/
import { connect } from 'react-redux';
import { flowRight } from 'lodash';

/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { withInstanceId } from '@wordpress/components';
import { compose } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -58,7 +58,7 @@ const applyConnect = connect(
}
);

export default flowRight( [
export default compose( [
applyConnect,
withInstanceId,
] )( PageAttributes );
5 changes: 3 additions & 2 deletions editor/components/post-author/check.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/**
* External dependencies
*/
import { flowRight, filter } from 'lodash';
import { filter } from 'lodash';

/**
* WordPress dependencies
*/
import { withAPIData, withInstanceId } from '@wordpress/components';
import { compose } from '@wordpress/element';

export function PostAuthorCheck( { user, users, children } ) {
const authors = filter( users.data, ( { capabilities } ) => capabilities.level_1 );
Expand All @@ -24,7 +25,7 @@ const applyWithAPIData = withAPIData( () => {
};
} );

export default flowRight( [
export default compose( [
applyWithAPIData,
withInstanceId,
] )( PostAuthorCheck );
6 changes: 3 additions & 3 deletions editor/components/post-author/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
* External dependencies
*/
import { connect } from 'react-redux';
import { filter, flowRight } from 'lodash';
import { filter } from 'lodash';

/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { withAPIData, withInstanceId } from '@wordpress/components';
import { Component } from '@wordpress/element';
import { Component, compose } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -89,7 +89,7 @@ const applyWithAPIData = withAPIData( () => {
};
} );

export default flowRight( [
export default compose( [
applyConnect,
applyWithAPIData,
withInstanceId,
Expand Down
5 changes: 3 additions & 2 deletions editor/components/post-featured-image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
* External dependencies
*/
import { connect } from 'react-redux';
import { flowRight, get } from 'lodash';
import { get } from 'lodash';

/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { Button, Spinner, ResponsiveWrapper, withAPIData } from '@wordpress/components';
import { MediaUploadButton } from '@wordpress/blocks';
import { compose } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -92,7 +93,7 @@ const applyWithAPIData = withAPIData( ( { featuredImageId, postTypeName } ) => {
};
} );

export default flowRight(
export default compose(
applyConnect,
applyWithAPIData,
)( PostFeaturedImage );
5 changes: 3 additions & 2 deletions editor/components/post-format/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
* External dependencies
*/
import { connect } from 'react-redux';
import { get, flowRight } from 'lodash';
import { get } from 'lodash';

/**
* WordPress dependencies
*/
import { withAPIData } from '@wordpress/components';
import { compose } from '@wordpress/element';

/**
* Internal dependencies
Expand All @@ -22,7 +23,7 @@ function PostFormatCheck( { postType, children } ) {
return children;
}

export default flowRight( [
export default compose( [
connect(
( state ) => {
return {
Expand Down
5 changes: 3 additions & 2 deletions editor/components/post-format/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
* External dependencies
*/
import { connect } from 'react-redux';
import { find, flowRight } from 'lodash';
import { find } from 'lodash';

/**
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';
import { withInstanceId } from '@wordpress/components';
import { compose } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -68,7 +69,7 @@ function PostFormat( { onUpdatePostFormat, postFormat = 'standard', suggestedFor
/* eslint-enable jsx-a11y/no-onchange */
}

export default flowRight( [
export default compose( [
connect(
( state ) => {
return {
Expand Down
Loading