From 7e44002f587d36f87682d476e6ef96761f9c065b Mon Sep 17 00:00:00 2001 From: Robert Anderson Date: Thu, 26 Jul 2018 16:49:24 +1000 Subject: [PATCH] Add deprecated aliases for public reusable block functions --- editor/store/actions.js | 61 +++++++++++++++++++++++++ editor/store/selectors.js | 40 ++++++++++++++++ packages/blocks/src/api/index.js | 1 + packages/blocks/src/api/registration.js | 11 +++++ 4 files changed, 113 insertions(+) diff --git a/editor/store/actions.js b/editor/store/actions.js index 6023ad8156b5dd..79390b9f5dca49 100644 --- a/editor/store/actions.js +++ b/editor/store/actions.js @@ -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 @@ -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 ); +} diff --git a/editor/store/selectors.js b/editor/store/selectors.js index 781cd3ea009d30..09f5f57fd6f8b3 100644 --- a/editor/store/selectors.js +++ b/editor/store/selectors.js @@ -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 ); +} diff --git a/packages/blocks/src/api/index.js b/packages/blocks/src/api/index.js index bb7a4eb54796f2..4b77d4a00b7883 100644 --- a/packages/blocks/src/api/index.js +++ b/packages/blocks/src/api/index.js @@ -38,6 +38,7 @@ export { getBlockSupport, hasBlockSupport, isReusableBlock, + isSharedBlock, getChildBlockNames, hasChildBlocks, unstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase diff --git a/packages/blocks/src/api/registration.js b/packages/blocks/src/api/registration.js index f9e1cebe6f03c2..62d4a7c29e1271 100644 --- a/packages/blocks/src/api/registration.js +++ b/packages/blocks/src/api/registration.js @@ -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 @@ -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. *