Skip to content

Commit

Permalink
Add deprecated aliases for public reusable block functions
Browse files Browse the repository at this point in the history
  • Loading branch information
noisysocks committed Jul 27, 2018
1 parent 3fe2a4b commit 7e44002
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 0 deletions.
61 changes: 61 additions & 0 deletions editor/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
getDefaultBlockName,
createBlock,
} from '@wordpress/blocks';
import deprecated from '@wordpress/deprecated';

/**
* Returns an action object used in signalling that editor has initialized with
Expand Down Expand Up @@ -766,3 +767,63 @@ export function unregisterToken( name ) {
name,
};
}

export function fetchSharedBlocks( id ) {
deprecated( 'fetchSharedBlocks', {
alternative: 'fetchReusableBlocks',
version: '3.6',
plugin: 'Gutenberg',
} );

return fetchReusableBlocks( id );
}

export function receiveSharedBlocks( results ) {
deprecated( 'receiveSharedBlocks', {
alternative: 'receiveReusableBlocks',
version: '3.6',
plugin: 'Gutenberg',
} );

return receiveReusableBlocks( results );
}

export function saveSharedBlock( id ) {
deprecated( 'saveSharedBlock', {
alternative: 'saveReusableBlock',
version: '3.6',
plugin: 'Gutenberg',
} );

return saveReusableBlock( id );
}

export function deleteSharedBlock( id ) {
deprecated( 'deleteSharedBlock', {
alternative: 'deleteReusableBlock',
version: '3.6',
plugin: 'Gutenberg',
} );

return deleteReusableBlock( id );
}

export function updateSharedBlockTitle( id, title ) {
deprecated( 'updateSharedBlockTitle', {
alternative: 'updateReusableBlockTitle',
version: '3.6',
plugin: 'Gutenberg',
} );

return updateReusableBlockTitle( id, title );
}

export function convertBlockToSaved( clientId ) {
deprecated( 'convertBlockToSaved', {
alternative: 'convertBlockToReusable',
version: '3.6',
plugin: 'Gutenberg',
} );

return convertBlockToReusable( clientId );
}
40 changes: 40 additions & 0 deletions editor/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1996,3 +1996,43 @@ export function getProvisionalBlockUID( state ) {

return getProvisionalBlockClientId( state );
}

export function getSharedBlock( state, ref ) {
deprecated( 'getSharedBlock', {
alternative: 'getReusableBlock',
version: '3.6',
plugin: 'Gutenberg',
} );

return getReusableBlock( state, ref );
}

export function isSavingSharedBlock( state, ref ) {
deprecated( 'isSavingSharedBlock', {
alternative: 'isSavingReusableBlock',
version: '3.6',
plugin: 'Gutenberg',
} );

return isSavingReusableBlock( state, ref );
}

export function isFetchingSharedBlock( state, ref ) {
deprecated( 'isFetchingSharedBlock', {
alternative: 'isFetchingReusableBlock',
version: '3.6',
plugin: 'Gutenberg',
} );

return isFetchingReusableBlock( state, ref );
}

export function getSharedBlocks( state ) {
deprecated( 'getSharedBlocks', {
alternative: 'getReusableBlocks',
version: '3.6',
plugin: 'Gutenberg',
} );

return getReusableBlocks( state );
}
1 change: 1 addition & 0 deletions packages/blocks/src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export {
getBlockSupport,
hasBlockSupport,
isReusableBlock,
isSharedBlock,
getChildBlockNames,
hasChildBlocks,
unstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase
Expand Down
11 changes: 11 additions & 0 deletions packages/blocks/src/api/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { get, isFunction, some } from 'lodash';
*/
import { applyFilters, addFilter } from '@wordpress/hooks';
import { select, dispatch } from '@wordpress/data';
import deprecated from '@wordpress/deprecated';

/**
* Internal dependencies
Expand Down Expand Up @@ -309,6 +310,16 @@ export function isReusableBlock( blockOrType ) {
return blockOrType.name === 'core/block';
}

export function isSharedBlock( blockOrType ) {
deprecated( 'isSharedBlock', {
alternative: 'isReusableBlock',
version: '3.6',
plugin: 'Gutenberg',
} );

return isReusableBlock( blockOrType );
}

/**
* Returns an array with the child blocks of a given block.
*
Expand Down

0 comments on commit 7e44002

Please sign in to comment.