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

Data: Refactor query HOC usage with withSelect #5215

Merged
merged 1 commit into from
Feb 23, 2018
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
6 changes: 3 additions & 3 deletions edit-post/components/sidebar/featured-image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { __ } from '@wordpress/i18n';
import { PanelBody, withAPIData } from '@wordpress/components';
import { PostFeaturedImage, PostFeaturedImageCheck } from '@wordpress/editor';
import { compose } from '@wordpress/element';
import { query } from '@wordpress/data';
import { withSelect } from '@wordpress/data';

/**
* Internal dependencies
Expand Down Expand Up @@ -42,7 +42,7 @@ function FeaturedImage( { isOpened, postType, onTogglePanel } ) {
);
}

const applyQuery = query( ( select ) => ( {
const applyWithSelect = withSelect( ( select ) => ( {
postTypeSlug: select( 'core/editor' ).getEditedPostAttribute( 'type' ),
} ) );

Expand All @@ -69,7 +69,7 @@ const applyWithAPIData = withAPIData( ( props ) => {
} );

export default compose(
applyQuery,
applyWithSelect,
applyConnect,
applyWithAPIData,
)( FeaturedImage );
4 changes: 2 additions & 2 deletions edit-post/components/sidebar/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { connect } from 'react-redux';
import { compose } from '@wordpress/element';
import { __, _n, sprintf } from '@wordpress/i18n';
import { IconButton } from '@wordpress/components';
import { query } from '@wordpress/data';
import { withSelect } from '@wordpress/data';

/**
* Internal Dependencies
Expand Down Expand Up @@ -47,7 +47,7 @@ const SidebarHeader = ( { panel, onSetPanel, onCloseSidebar, count } ) => {
};

export default compose(
query( ( select ) => ( {
withSelect( ( select ) => ( {
count: select( 'core/editor' ).getSelectedBlockCount(),
} ) ),
Copy link
Member Author

@gziolo gziolo Feb 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

connect should go next as soon as we expose all selectors and actions :)

connect(
Expand Down
6 changes: 3 additions & 3 deletions edit-post/components/sidebar/page-attributes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { __ } from '@wordpress/i18n';
import { PanelBody, PanelRow, withAPIData } from '@wordpress/components';
import { compose } from '@wordpress/element';
import { PageAttributesCheck, PageAttributesOrder, PageAttributesParent, PageTemplate } from '@wordpress/editor';
import { query } from '@wordpress/data';
import { withSelect } from '@wordpress/data';

/**
* Internal dependencies
Expand Down Expand Up @@ -45,7 +45,7 @@ export function PageAttributes( { isOpened, onTogglePanel, postType } ) {
);
}

const applyQuery = query( ( select ) => ( {
const applyWithSelect = withSelect( ( select ) => ( {
postTypeSlug: select( 'core/editor' ).getEditedPostAttribute( 'type' ),
} ) );

Expand All @@ -72,7 +72,7 @@ const applyWithAPIData = withAPIData( ( props ) => {
} );

export default compose(
applyQuery,
applyWithSelect,
applyConnect,
applyWithAPIData,
)( PageAttributes );
4 changes: 2 additions & 2 deletions edit-post/hooks/more-menu/copy-content-menu-item/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { ClipboardButton, withState } from '@wordpress/components';
import { compose } from '@wordpress/element';
import { query } from '@wordpress/data';
import { withSelect } from '@wordpress/data';
import { __ } from '@wordpress/i18n';

function CopyContentMenuItem( { editedPostContent, hasCopied, setState } ) {
Expand All @@ -22,7 +22,7 @@ function CopyContentMenuItem( { editedPostContent, hasCopied, setState } ) {
}

export default compose(
query( ( select ) => ( {
withSelect( ( select ) => ( {
editedPostContent: select( 'core/editor' ).getEditedPostAttribute( 'content' ),
} ) ),
withState( { hasCopied: false } )
Expand Down
4 changes: 2 additions & 2 deletions editor/components/multi-select-scroll-into-view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import scrollIntoView from 'dom-scroll-into-view';
* WordPress dependencies
*/
import { Component } from '@wordpress/element';
import { query } from '@wordpress/data';
import { withSelect } from '@wordpress/data';
import { getScrollContainer } from '@wordpress/utils';

class MultiSelectScrollIntoView extends Component {
Expand Down Expand Up @@ -52,7 +52,7 @@ class MultiSelectScrollIntoView extends Component {
}
}

export default query( ( select ) => {
export default withSelect( ( select ) => {
return {
extentUID: select( 'core/editor' ).getLastMultiSelectedBlockUid(),
};
Expand Down
4 changes: 2 additions & 2 deletions editor/components/table-of-contents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { __ } from '@wordpress/i18n';
import { Dropdown, IconButton } from '@wordpress/components';
import { query } from '@wordpress/data';
import { withSelect } from '@wordpress/data';

/**
* Internal dependencies
Expand Down Expand Up @@ -31,7 +31,7 @@ function TableOfContents( { hasBlocks } ) {
);
}

export default query( ( select ) => {
export default withSelect( ( select ) => {
return {
hasBlocks: !! select( 'core/editor' ).getBlockCount(),
};
Expand Down
4 changes: 2 additions & 2 deletions editor/components/table-of-contents/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { countBy } from 'lodash';
*/
import { Fragment } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { query } from '@wordpress/data';
import { withSelect } from '@wordpress/data';

/**
* Internal dependencies
Expand Down Expand Up @@ -58,7 +58,7 @@ function TableOfContentsPanel( { blocks } ) {
);
}

export default query( ( select ) => {
export default withSelect( ( select ) => {
return {
blocks: select( 'core/editor' ).getBlocks(),
};
Expand Down