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: Drop deprecations slated for 3.2 removal #7747

Merged
merged 2 commits into from
Jul 6, 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
24 changes: 1 addition & 23 deletions docs/data/data-core-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -871,24 +871,6 @@ Returns the user notices array.

List of notices.

### getFrecentInserterItems

Returns a list of items which the user is likely to want to insert. These
are ordered by 'frecency', which is a heuristic that combines block usage
frequency and recency.

https://en.wikipedia.org/wiki/Frecency

*Parameters*

* state: Global application state.
* allowedBlockTypes: Allowed block types, or true/false to enable/disable all types.
* maximum: Number of items to return.

*Returns*

Items that appear in the 'Recent' tab.

### isSavingSharedBlock

Returns whether or not the shared block with the given ID is being saved.
Expand Down Expand Up @@ -1029,10 +1011,6 @@ Returns the Block List settings of a block if any.

Block settings of the block if set.

### getSupportedBlocks

eslint-disable-next-line no-unused-vars

### getEditorSettings

Returns the editor settings.
Expand Down Expand Up @@ -1417,4 +1395,4 @@ Returns an action object used in signalling that the editor settings have been u

*Parameters*

* settings: Updated settings
* settings: Updated settings
1 change: 1 addition & 0 deletions docs/reference/deprecated.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Gutenberg's deprecation policy is intended to support backwards-compatibility fo
- `wp.data.withRehydratation` has been renamed to `wp.data.withRehydration`.
- The `wp.editor.ImagePlaceholder` component is removed. Please use `wp.editor.MediaPlaceholder` instead.
- `wp.utils.deprecated` function removed. Please use `wp.deprecated` instead.
- `wp.utils.blob` removed. Please use `wp.blob` instead.
- `getInserterItems`: the `allowedBlockTypes` argument was removed and the `parentUID` argument was added.
- `getFrecentInserterItems` selector removed. Please use `getInserterItems` instead.
- `getSupportedBlocks` selector removed. Please use `canInsertBlockType` instead.
Expand Down
43 changes: 0 additions & 43 deletions editor/components/image-placeholder/index.js

This file was deleted.

1 change: 0 additions & 1 deletion editor/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export { default as ColorPalette } from './color-palette';
export { default as withColorContext } from './color-palette/with-color-context';
export * from './colors';
export { default as ContrastChecker } from './contrast-checker';
export { default as ImagePlaceholder } from './image-placeholder';
export { default as InnerBlocks } from './inner-blocks';
export { default as InspectorAdvancedControls } from './inspector-advanced-controls';
export { default as InspectorControls } from './inspector-controls';
Expand Down
63 changes: 0 additions & 63 deletions editor/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ import createSelector from 'rememo';
import { serialize, getBlockType, getBlockTypes, hasBlockSupport, hasChildBlocks } from '@wordpress/blocks';
import { __ } from '@wordpress/i18n';
import { moment } from '@wordpress/date';
import deprecated from '@wordpress/deprecated';

/***
* Module constants
*/
const MAX_RECENT_BLOCKS = 9;
export const POST_UPDATE_TRANSACTION_ID = 'post-update';
const PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/;
export const INSERTER_UTILITY_HIGH = 3;
Expand Down Expand Up @@ -1460,18 +1458,6 @@ function getInsertUsage( state, id ) {
*/
export const getInserterItems = createSelector(
( state, parentUID = null ) => {
/**
* The second argument used to be {boolean|array} allowedBlockTypes but it is no
* longer necessary.
*/
if ( isBoolean( parentUID ) || isArray( parentUID ) ) {
deprecated( 'allowedBlockTypes', {
version: '3.2',
plugin: 'Gutenberg',
} );
parentUID = null;
}

const calculateUtility = ( category, count, isContextual ) => {
if ( isContextual ) {
return INSERTER_UTILITY_HIGH;
Expand Down Expand Up @@ -1610,32 +1596,6 @@ export const getInserterItems = createSelector(
],
);

/**
* Returns a list of items which the user is likely to want to insert. These
* are ordered by 'frecency', which is a heuristic that combines block usage
* frequency and recency.
*
* https://en.wikipedia.org/wiki/Frecency
*
* @param {Object} state Global application state.
* @param {string[]|boolean} allowedBlockTypes Allowed block types, or true/false to enable/disable all types.
* @param {number} maximum Number of items to return.
*
* @return {Editor.InserterItem[]} Items that appear in the 'Recent' tab.
*/
export function getFrecentInserterItems( state, allowedBlockTypes, maximum = MAX_RECENT_BLOCKS ) {
deprecated( 'getFrecentInserterItems', {
version: '3.2',
alternative: 'getInserterItems',
plugin: 'Gutenberg',
} );

const items = getInserterItems( state, allowedBlockTypes );
const usefulItems = items.filter( ( item ) => item.utility > 0 );
const sortedItems = orderBy( usefulItems, [ 'utility', 'frecency' ], [ 'desc', 'desc' ] );
return sortedItems.slice( 0, maximum );
}

/**
* Returns the shared block with the given ID.
*
Expand Down Expand Up @@ -1843,29 +1803,6 @@ export function getBlockListSettings( state, uid ) {
return state.blockListSettings[ uid ];
}

/**
* Determines the blocks that can be nested inside a given block. Or globally if a block is not specified.
*
* @param {Object} state Global application state.
* @param {?string} uid Block UID.
* @param {string[]|boolean} globallyEnabledBlockTypes Globally enabled block types, or true/false to enable/disable all types.
*
* @return {string[]|boolean} Blocks that can be nested inside the block with the specified uid, or true/false to enable/disable all types.
*/
// Disable reason: We have to accept `globallyEnabledBlockTypes` so as to be backwards compatible
// eslint-disable-next-line no-unused-vars
export function getSupportedBlocks( state, uid, globallyEnabledBlockTypes ) {
deprecated( 'getSupportedBlocks', {
version: '3.2',
alternative: 'canInsertBlockType',
plugin: 'Gutenberg',
} );

return getBlockTypes()
.filter( ( blockType ) => canInsertBlockType( state, blockType.name, uid ) )
.map( ( blockType ) => blockType.name );
}

/*
* Returns the editor settings.
*
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gutenberg",
"version": "3.1.1",
"version": "3.2.0",
Copy link
Member Author

Choose a reason for hiding this comment

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

Sigh.. this wasn't meant to be included 😞 Only to help trigger the failing E2E locally.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I missed it too 😢

"private": true,
"description": "A new WordPress editor experience",
"repository": "git+https://github.com/WordPress/gutenberg.git",
Expand Down
2 changes: 1 addition & 1 deletion packages/data/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import isShallowEqual from '@wordpress/is-shallow-equal';
*/
import registerDataStore from './store';

export { loadAndPersist, withRehydration, withRehydratation } from './persist';
export { loadAndPersist, withRehydration } from './persist';

/**
* Module constants
Expand Down
24 changes: 0 additions & 24 deletions packages/data/src/persist.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* WordPress dependencies
*/
import deprecated from '@wordpress/deprecated';

/**
* External dependencies
*/
Expand Down Expand Up @@ -47,25 +42,6 @@ export function withRehydration( reducer, reducerKey, storageKey ) {
return enhancedReducer;
}

/**
* Export withRehydratation (a misspelling of withRehydration) for backwards
* compatibility.
*
* @param {Function} reducer The reducer to enhance.
* @param {string} reducerKey The reducer key to persist.
* @param {string} storageKey The storage key to use.
*
* @return {Function} Enhanced reducer.
*/
export function withRehydratation( reducer, reducerKey, storageKey ) {
deprecated( 'wp.data.withRehydratation', {
version: '3.2',
alternative: 'wp.data.withRehydration',
plugin: 'Gutenberg',
} );
return withRehydration( reducer, reducerKey, storageKey );
}

/**
* Loads the initial state and persist on changes.
*
Expand Down
32 changes: 2 additions & 30 deletions utils/deprecated.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,12 @@
/**
* WordPress dependencies
*/
import * as blob from '@wordpress/blob';
import * as keycodesSource from '@wordpress/keycodes';
import originalDeprecated from '@wordpress/deprecated';

const wrapFunction = ( source, sourceName, version ) =>
( functionName ) => ( ...args ) => {
originalDeprecated( `wp.utils.${ functionName }`, {
version,
alternative: `wp.${ sourceName }.${ functionName }`,
plugin: 'Gutenberg',
} );
return source[ functionName ]( ...args );
};

// blob
const wrapBlobFunction = wrapFunction( blob, 'blob', '3.2' );
export const createBlobURL = wrapBlobFunction( 'createBlobURL' );
export const getBlobByURL = wrapBlobFunction( 'getBlobByURL' );
export const revokeBlobURL = wrapBlobFunction( 'revokeBlobURL' );

// deprecated
export function deprecated( ...params ) {
originalDeprecated( 'wp.utils.deprecated', {
version: '3.2',
alternative: 'wp.deprecated',
plugin: 'Gutenberg',
} );

return originalDeprecated( ...params );
}
import deprecated from '@wordpress/deprecated';

// keycodes
const wrapKeycodeFunction = ( source, functionName ) => ( ...args ) => {
originalDeprecated( `wp.utils.keycodes.${ functionName }`, {
deprecated( `wp.utils.keycodes.${ functionName }`, {
version: '3.4',
alternative: `wp.keycodes.${ functionName }`,
plugin: 'Gutenberg',
Expand Down