Skip to content

Commit

Permalink
Framework: Remove deprecations slated for 3.5 removal (#8687)
Browse files Browse the repository at this point in the history
* Framework: Update use of deprecated UID

* Framework: Update use of deprecated compose

* Framework: Remove deprecations slated for v3.5 removal

* Framework: Update package dependencies after deprecation removals
  • Loading branch information
aduth authored and gziolo committed Aug 8, 2018
1 parent ae2d929 commit e95026c
Show file tree
Hide file tree
Showing 36 changed files with 53 additions and 713 deletions.
2 changes: 0 additions & 2 deletions core-blocks/test/full-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ function normalizeParsedBlocks( blocks ) {

// Change client IDs to a predictable value
block.clientId = '_clientId_' + index;
// TODO: Remove in 3.5 "UID" deprecation.
delete block.uid;

// Walk each attribute and get a more concise representation of any
// React elements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const PluginBlockSettingsMenuGroupSlot = ( { fillProps, selectedBlocks } ) => {
};

PluginBlockSettingsMenuGroup.Slot = withSelect( ( select, { fillProps: { clientIds } } ) => ( {
selectedBlocks: select( 'core/editor' ).getBlocksByUID( clientIds ),
selectedBlocks: select( 'core/editor' ).getBlocksByClientId( clientIds ),
} ) )( PluginBlockSettingsMenuGroupSlot );

export default PluginBlockSettingsMenuGroup;
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { difference } from 'lodash';
* WordPress dependencies
*/
import { IconButton } from '@wordpress/components';
import { compose } from '@wordpress/element';
import { compose } from '@wordpress/compose';

/**
* Internal dependencies
Expand Down
4 changes: 2 additions & 2 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ function gutenberg_register_scripts_and_styles() {
wp_register_script(
'wp-utils',
gutenberg_url( 'build/utils/index.js' ),
array( 'lodash', 'wp-api-fetch', 'wp-deprecated', 'wp-html-entities', 'wp-i18n', 'wp-editor' ),
array( 'lodash', 'wp-api-fetch', 'wp-data', 'wp-deprecated', 'wp-i18n', 'wp-editor' ),
filemtime( gutenberg_dir_path() . 'build/utils/index.js' ),
true
);
Expand Down Expand Up @@ -322,7 +322,7 @@ function gutenberg_register_scripts_and_styles() {
wp_register_script(
'wp-element',
gutenberg_url( 'build/element/index.js' ),
array( 'react', 'react-dom', 'wp-is-shallow-equal', 'lodash', 'wp-deprecated' ),
array( 'react', 'react-dom', 'lodash' ),
filemtime( gutenberg_dir_path() . 'build/element/index.js' ),
true
);
Expand Down
32 changes: 17 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions packages/blocks/src/api/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ export function createBlock( name, blockAttributes = {}, innerBlocks = [] ) {
// attributes, and their inner blocks.
return {
clientId,
// TODO: Remove from block interface in 3.5 "UID" deprecation.
uid: clientId,
name,
isValid: true,
attributes,
Expand All @@ -83,8 +81,6 @@ export function cloneBlock( block, mergeAttributes = {}, newInnerBlocks ) {
return {
...block,
clientId,
// TODO: Remove from block interface in 3.5 "UID" deprecation.
uid: uuid(),
attributes: {
...block.attributes,
...mergeAttributes,
Expand Down
4 changes: 2 additions & 2 deletions packages/blocks/src/api/test/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -1024,9 +1024,9 @@ describe( 'block factory', () => {

const transformedBlocks = switchToBlockType( block, 'core/updated-text-block' );

// Make sure the block UIDs are set as expected: the first
// Make sure the block client IDs are set as expected: the first
// transformed block whose type matches the "destination" type gets
// to keep the existing block's UID.
// to keep the existing block's client ID.
expect( transformedBlocks ).toHaveLength( 2 );
expect( transformedBlocks[ 0 ] ).toHaveProperty( 'clientId' );
expect( transformedBlocks[ 0 ].clientId ).not.toBe( block.clientId );
Expand Down
35 changes: 0 additions & 35 deletions packages/components/src/deprecated.js

This file was deleted.

11 changes: 0 additions & 11 deletions packages/components/src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* Internal dependencies
*/
import deprecated from './deprecated';

// Components
// eslint-disable-next-line camelcase
export { default as APIProvider, unstable__setApiSettings } from './higher-order/with-api-data/provider';
Expand Down Expand Up @@ -73,9 +68,3 @@ export { default as withFocusOutside } from './higher-order/with-focus-outside';
export { default as withFocusReturn } from './higher-order/with-focus-return';
export { default as withNotices } from './higher-order/with-notices';
export { default as withSpokenMessages } from './higher-order/with-spoken-messages';

export const ifCondition = deprecated.ifCondition;
export const withGlobalEvents = deprecated.withGlobalEvents;
export const withInstanceId = deprecated.withInstanceId;
export const withSafeTimeout = deprecated.withSafeTimeout;
export const withState = deprecated.withState;
2 changes: 1 addition & 1 deletion packages/compose/src/with-instance-id/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Wrapping a component with `withInstanceId` provides a unique `instanceId` to ser
/**
* WordPress dependencies
*/
import { withInstanceId } from '@wordpress/components';
import { withInstanceId } from '@wordpress/compose';

function MyCustomElement( { instanceId } ) {
return (
Expand Down
2 changes: 1 addition & 1 deletion packages/compose/src/with-safe-timeout/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ withSafeTimeout
/**
* WordPress dependencies
*/
import { withSafeTimeout } from '@wordpress/components';
import { withSafeTimeout } from '@wordpress/compose';

function MyEffectfulComponent( { setTimeout } ) {
return (
Expand Down
1 change: 0 additions & 1 deletion packages/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"@wordpress/viewport": "file:../viewport",
"@wordpress/wordcount": "file:../wordcount",
"classnames": "^2.2.5",
"dom-react": "^2.2.1",
"dom-scroll-into-view": "^1.2.1",
"element-closest": "^2.0.2",
"lodash": "^4.17.10",
Expand Down
3 changes: 1 addition & 2 deletions packages/editor/src/components/block-edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Component } from '@wordpress/element';
*/
import Edit from './edit';
import { BlockEditContextProvider } from './context';
import withDeprecatedUniqueId from '../with-deprecated-unique-id';

class BlockEdit extends Component {
constructor( props ) {
Expand Down Expand Up @@ -50,4 +49,4 @@ class BlockEdit extends Component {
}
}

export default withDeprecatedUniqueId( BlockEdit );
export default BlockEdit;
70 changes: 7 additions & 63 deletions packages/editor/src/components/block-list/index.js
Original file line number Diff line number Diff line change
@@ -1,74 +1,18 @@
/**
* External dependencies
*/
import {
reduce,
get,
map,
} from 'lodash';

/**
* WordPress dependencies
*/
import { createElement } from '@wordpress/element';
import { withSelect } from '@wordpress/data';
import deprecated from '@wordpress/deprecated';

/**
* Internal dependencies
*/
import BlockListLayout from './layout';

const UngroupedLayoutBlockList = withSelect(
( select, ownProps ) => ( {
blockClientIds: select( 'core/editor' ).getBlockOrder( ownProps.rootClientId ),
} )
)( BlockListLayout );

const GroupedLayoutBlockList = withSelect(
( select, ownProps ) => ( {
blocks: select( 'core/editor' ).getBlocks( ownProps.rootClientId ),
} ),
)( ( {
blocks,
layouts,
...props
} ) => map( layouts, ( layout ) => {
deprecated( 'grouped layout', {
alternative: 'intermediary nested inner blocks',
version: '3.5',
plugin: 'Gutenberg',
hint: 'See core Columns / Column block for reference implementation',
} );

// Filter blocks assigned to layout when rendering grouped layouts.
const layoutBlockClientIds = reduce( blocks, ( result, block ) => {
if ( get( block, [ 'attributes', 'layout' ] ) === layout.name ) {
result.push( block.clientId );
}

return result;
}, [] );

return (
<BlockListLayout
key={ layout.name }
layout={ layout.name }
isGroupedByLayout
blockClientIds={ layoutBlockClientIds }
{ ...props }
/>
);
} ) );

const BlockList = ( props ) => createElement(
// BlockList can be provided with a layouts configuration, either grouped
// (blocks adjacent in markup) or ungrouped. This is inferred by the shape
// of the layouts configuration passed (grouped layout as array).
Array.isArray( props.layouts ) ?
GroupedLayoutBlockList :
UngroupedLayoutBlockList,
props
);
// TODO: This should be refactored to flatten BlockListLayout into this file.
export default withSelect( ( select, ownProps ) => {
const { getBlockOrder } = select( 'core/editor' );

export default BlockList;
return {
blockClientIds: getBlockOrder( ownProps.rootClientId ),
};
} )( BlockListLayout );
2 changes: 0 additions & 2 deletions packages/editor/src/components/block-list/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { compose } from '@wordpress/compose';
import BlockListBlock from './block';
import IgnoreNestedEvents from './ignore-nested-events';
import DefaultBlockAppender from '../default-block-appender';
import withDeprecatedUniqueId from '../with-deprecated-unique-id';

class BlockListLayout extends Component {
constructor( props ) {
Expand Down Expand Up @@ -239,7 +238,6 @@ class BlockListLayout extends Component {
}

export default compose( [
withDeprecatedUniqueId,
withSelect( ( select, ownProps ) => {
const {
isSelectionEnabled,
Expand Down
2 changes: 0 additions & 2 deletions packages/editor/src/components/block-mover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { withInstanceId, compose } from '@wordpress/compose';
*/
import { getBlockMoverDescription } from './mover-description';
import { upArrow, downArrow } from './arrows';
import withDeprecatedUniqueId from '../with-deprecated-unique-id';

export class BlockMover extends Component {
constructor() {
Expand Down Expand Up @@ -107,7 +106,6 @@ export class BlockMover extends Component {
}

export default compose(
withDeprecatedUniqueId,
withSelect( ( select, { clientIds, rootClientId } ) => {
const { getBlock, getBlockIndex, getTemplateLock } = select( 'core/editor' );
const firstClientId = first( castArray( clientIds ) );
Expand Down
15 changes: 5 additions & 10 deletions packages/editor/src/components/block-settings-menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { __ } from '@wordpress/i18n';
import { Component } from '@wordpress/element';
import { IconButton, Dropdown, NavigableMenu } from '@wordpress/components';
import { withDispatch } from '@wordpress/data';
import { compose } from '@wordpress/compose';

/**
* Internal dependencies
Expand All @@ -25,7 +24,6 @@ import BlockHTMLConvertButton from './block-html-convert-button';
import BlockUnknownConvertButton from './block-unknown-convert-button';
import _BlockSettingsMenuFirstItem from './block-settings-menu-first-item';
import _BlockSettingsMenuPluginsExtension from './block-settings-menu-plugins-extension';
import withDeprecatedUniqueId from '../with-deprecated-unique-id';

export class BlockSettingsMenu extends Component {
constructor() {
Expand Down Expand Up @@ -148,11 +146,8 @@ export class BlockSettingsMenu extends Component {
}
}

export default compose( [
withDeprecatedUniqueId,
withDispatch( ( dispatch ) => ( {
onSelect( clientId ) {
dispatch( 'core/editor' ).selectBlock( clientId );
},
} ) ),
] )( BlockSettingsMenu );
export default withDispatch( ( dispatch ) => ( {
onSelect( clientId ) {
dispatch( 'core/editor' ).selectBlock( clientId );
},
} ) )( BlockSettingsMenu );
Loading

0 comments on commit e95026c

Please sign in to comment.