Skip to content

Commit

Permalink
Bail when the registerBlocks hook is triggered by a deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
mmtr committed Jul 27, 2019
1 parent 62b46d2 commit 6a89012
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions extensions/blocks/videopress/deprecated/v1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@ export default {
reusable: false,
},
save,
isDeprecation: true,
};
20 changes: 13 additions & 7 deletions extensions/blocks/videopress/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ import getJetpackExtensionAvailability from '../../shared/get-jetpack-extension-
import deprecatedV1 from './deprecated/v1';

const addVideoPressSupport = ( settings, name ) => {
if ( 'core/video' !== name ) {
// Bail if this is not the video block or if the hook has been triggered by a deprecation.
if ( 'core/video' !== name || settings.isDeprecation ) {
return settings;
}

const { attributes, deprecated, edit, save, supports, transforms } = settings;

const { available, unavailableReason } = getJetpackExtensionAvailability( 'videopress' );

// We customize the video block even if VideoPress it not available so we can support videos that were uploaded to
Expand Down Expand Up @@ -69,7 +72,7 @@ const addVideoPressSupport = ( settings, name ) => {
},

transforms: {
...settings.transforms,
...transforms,
from: [
{
type: 'files',
Expand Down Expand Up @@ -99,19 +102,22 @@ const addVideoPressSupport = ( settings, name ) => {
},

supports: {
...settings.supports,
...supports,
reusable: false,
},

edit: withVideoPressEdit( settings.edit ),
edit: withVideoPressEdit( edit ),

save: withVideoPressSave( settings.save ),
save: withVideoPressSave( save ),

deprecated: [
...( deprecated || [] ),
{
attributes: settings.attributes,
save: settings.save,
attributes,
isEligible: attrs => ! attrs.guid,
save,
supports,
isDeprecation: true,
},
deprecatedV1,
],
Expand Down

0 comments on commit 6a89012

Please sign in to comment.