Skip to content

Commit fab452e

Browse files
committed
fix: remove substituteIfDisabledFunction
1 parent 4d421ca commit fab452e

File tree

3 files changed

+15
-49
lines changed

3 files changed

+15
-49
lines changed

src/block/card/variations.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import ImageFaded from './images/faded.svg'
1111
* External dependencies
1212
*/
1313
import { i18n, isPro } from 'stackable'
14-
import { substituteIfDisabled } from '~stackable/util'
1514

1615
/**
1716
* WordPress dependencies
@@ -106,7 +105,7 @@ const variations = applyFilters(
106105
bottom: 0,
107106
left: 0,
108107
},
109-
}, [ substituteIfDisabled( [ 'stackable/button-group|social-buttons', 'stackable/button-group|icon-button' ],
108+
}, [
110109
[ 'stackable/button-group', {
111110
columnSpacing: {
112111
top: 0,
@@ -133,15 +132,6 @@ const variations = applyFilters(
133132
className: 'is-style-plain',
134133
} ],
135134
] ],
136-
[ 'core/social-links',
137-
{
138-
align: 'right',
139-
},
140-
[
141-
[ 'core/social-link', { service: 'facebook' } ],
142-
[ 'core/social-link', { service: 'twitter' } ],
143-
],
144-
] ),
145135
] ],
146136
] ],
147137
],

src/block/team-member/variations.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* Internal dependencies
33
*/
44
import { i18n, isPro } from 'stackable'
5-
import { substituteIfDisabled } from '~stackable/util'
65

76
/**
87
* WordPress dependencies
@@ -54,14 +53,6 @@ import ImageCover from './images/cover.svg'
5453
],
5554
]
5655

57-
const socialLinksInnerBlocks = [
58-
[ 'core/social-link', { service: 'facebook' } ],
59-
[ 'core/social-link', { service: 'twitter' } ],
60-
[ 'core/social-link', { service: 'instagram' } ],
61-
[ 'core/social-link', { service: 'youtube' } ],
62-
[ 'core/social-link', { service: 'linkedin' } ],
63-
]
64-
6556
const variations = applyFilters(
6657
'stackable.team-member.variations',
6758
[
@@ -86,10 +77,7 @@ const variations = applyFilters(
8677
text: __( 'Position', i18n ),
8778
} ],
8879
[ 'stackable/text', { text: _x( 'Description for this block. Use this space for describing your block. Any text will do. Description for this block. You can use this space for describing your block.', 'Content placeholder', i18n ) } ],
89-
substituteIfDisabled( [ 'stackable/button-group|social-buttons', 'stackable/button-group|icon-button' ],
90-
[ 'stackable/button-group', {}, buttonGroupInnerBlocks ],
91-
[ 'core/social-links', { align: 'center' }, socialLinksInnerBlocks ],
92-
),
80+
[ 'stackable/button-group', {}, buttonGroupInnerBlocks ],
9381
],
9482
scope: [ 'block' ],
9583
},
@@ -110,10 +98,7 @@ const variations = applyFilters(
11098
[ 'stackable/subtitle', {
11199
text: __( 'Position', i18n ),
112100
} ],
113-
substituteIfDisabled( [ 'stackable/button-group|social-buttons', 'stackable/button-group|icon-button' ],
114-
[ 'stackable/button-group', {}, buttonGroupInnerBlocks ],
115-
[ 'core/social-links', { align: 'center' }, socialLinksInnerBlocks ],
116-
),
101+
[ 'stackable/button-group', {}, buttonGroupInnerBlocks ],
117102
],
118103
scope: [ 'block' ],
119104
},

src/util/blocks.js

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,18 @@ export const substituteCoreIfDisabled = ( blockName, blockAttributes, children )
578578
if ( 'stackable/button-group|button' in disabled_blocks && disabled_blocks[ 'stackable/button-group|button' ] === BLOCK_STATE.DISABLED ) { // eslint-disable-line camelcase
579579
return [ 'core/buttons', {}, children ]
580580
}
581+
if ( 'stackable/button-group|icon-button' in disabled_blocks && disabled_blocks[ 'stackable/button-group|icon-button' ] === BLOCK_STATE.DISABLED && // eslint-disable-line camelcase
582+
children.length &&
583+
children[ 0 ][ 0 ] === 'stackable/icon-button'
584+
) {
585+
return [ 'core/social-links',
586+
{ align: blockAttributes.contentAlign },
587+
[
588+
[ 'core/social-link', { service: 'facebook' } ],
589+
[ 'core/social-link', { service: 'twitter' } ],
590+
],
591+
]
592+
}
581593
return [ 'stackable/button-group', blockAttributes, children ]
582594
}
583595

@@ -608,27 +620,6 @@ export const substituteCoreIfDisabled = ( blockName, blockAttributes, children )
608620
return [ blockName, blockAttributes ]
609621
}
610622

611-
/**
612-
* Substitutes a block definition with another block definition if any of the block names given are disabled.
613-
*
614-
* @param {Array} blockNames The block names to check if disabled
615-
* @param {Array} originalBlockDefinition The original block definition
616-
* @param {Array} substituteBlockDefinition The block definition to substitute with
617-
*
618-
* @return {Array} The resulting block definition
619-
*/
620-
export const substituteIfDisabled = ( blockNames, originalBlockDefinition, substituteBlockDefinition ) => {
621-
const disabled_blocks = stackableSettings.stackable_block_states || {} // eslint-disable-line camelcase
622-
623-
for ( const blockName of blockNames ) {
624-
if ( blockName in disabled_blocks && disabled_blocks[ blockName ] === BLOCK_STATE.DISABLED ) { // eslint-disable-line camelcase
625-
return substituteBlockDefinition
626-
}
627-
}
628-
629-
return originalBlockDefinition
630-
}
631-
632623
/**
633624
* Remove a given child block from a block tree definition if disabled
634625
*

0 commit comments

Comments
 (0)