Skip to content

Commit decb130

Browse files
committed
fix: add deprecation code to affected blocks, including removing V4
1 parent c158a40 commit decb130

File tree

8 files changed

+57
-90
lines changed

8 files changed

+57
-90
lines changed

src/block/call-to-action/deprecated.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { withVersion } from '~stackable/higher-order'
1111
import {
1212
deprecateBlockBackgroundColorOpacity, deprecateContainerBackgroundColorOpacity,
1313
deprecateBlockShadowColor, deprecateContainerShadowColor, deprecateShadowColor, deprecateBlockHeight,
14+
deprecateInnerBlockRowGapAndContainerHeight,
1415
} from '~stackable/block-components'
1516
import compareVersions from 'compare-versions'
1617

@@ -40,9 +41,10 @@ const deprecated = [
4041
attributes: attributes( '3.15.2' ),
4142
save: withVersion( '3.15.2' )( Save ),
4243
isEligible: attributes => {
43-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
4444
const hasNumberBlockHeight = deprecateBlockHeight.isEligible( attributes )
45-
return isNotV4 || hasNumberBlockHeight
45+
const hasNumberInnerBlockRowGapAndContainerHeight = deprecateInnerBlockRowGapAndContainerHeight.isEligible( '%s' )( attributes )
46+
47+
return hasNumberBlockHeight || hasNumberInnerBlockRowGapAndContainerHeight
4648
},
4749
migrate: ( attributes, innerBlocks ) => {
4850
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
@@ -102,6 +104,7 @@ const deprecated = [
102104
newAttributes = deprecateShadowColor.migrate( 'topSeparator%s' )( newAttributes )
103105
newAttributes = deprecateShadowColor.migrate( 'bottomSeparator%s' )( newAttributes )
104106
newAttributes = deprecateBlockHeight.migrate( newAttributes )
107+
newAttributes = deprecateInnerBlockRowGapAndContainerHeight.migrate( '%s' )( newAttributes )
105108

106109
return [ newAttributes, innerBlocks ]
107110
},
@@ -115,9 +118,8 @@ const deprecated = [
115118
const hasContainerShadow = deprecateContainerShadowColor.isEligible( attributes )
116119
const hasTopSeparatorShadow = deprecateShadowColor.isEligible( 'topSeparator%s' )( attributes )
117120
const hasBottomSeparatorShadow = deprecateShadowColor.isEligible( 'bottomSeparator%s' )( attributes )
118-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
119121

120-
return hasBlockShadow || hasContainerShadow || hasTopSeparatorShadow || hasBottomSeparatorShadow || isNotV4
122+
return hasBlockShadow || hasContainerShadow || hasTopSeparatorShadow || hasBottomSeparatorShadow
121123
},
122124
migrate: ( attributes, innerBlocks ) => {
123125
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
@@ -187,9 +189,8 @@ const deprecated = [
187189
isEligible: attributes => {
188190
const hasContainerOpacity = deprecateContainerBackgroundColorOpacity.isEligible( attributes )
189191
const hasBlockOpacity = deprecateBlockBackgroundColorOpacity.isEligible( attributes )
190-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
191192

192-
return hasContainerOpacity || hasBlockOpacity || isNotV4
193+
return hasContainerOpacity || hasBlockOpacity
193194
},
194195
migrate: ( attributes, innerBlocks ) => {
195196
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
@@ -257,11 +258,6 @@ const deprecated = [
257258
// layout & containers work.
258259
attributes: attributes( '3.7.9' ),
259260
save: withVersion( '3.7.9' )( Save ),
260-
isEligible: attributes => {
261-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
262-
263-
return isNotV4
264-
},
265261
migrate: ( attributes, innerBlocks ) => {
266262
let newAttributes = {
267263
...attributes,

src/block/card/deprecated.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
deprecateBlockBackgroundColorOpacity, deprecateContainerBackgroundColorOpacity,
1414
deprecationImageOverlayOpacity, getAlignmentClasses,
1515
deprecateBlockShadowColor, deprecateContainerShadowColor, deprecateBlockHeight,
16+
deprecateInnerBlockRowGapAndContainerHeight,
1617
} from '~stackable/block-components'
1718

1819
/**
@@ -91,9 +92,10 @@ const deprecated = [
9192
attributes: attributes( '3.15.2' ),
9293
save: withVersion( '3.15.2' )( Save ),
9394
isEligible: attributes => {
94-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
9595
const hasNumberBlockHeight = deprecateBlockHeight.isEligible( attributes )
96-
return isNotV4 || hasNumberBlockHeight
96+
const hasNumberInnerBlockRowGapAndContainerHeight = deprecateInnerBlockRowGapAndContainerHeight.isEligible( '%s' )( attributes )
97+
98+
return hasNumberBlockHeight || hasNumberInnerBlockRowGapAndContainerHeight
9799
},
98100
migrate: ( attributes, innerBlocks ) => {
99101
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
@@ -152,6 +154,7 @@ const deprecated = [
152154
newAttributes = deprecateBlockShadowColor.migrate( newAttributes )
153155
newAttributes = deprecateContainerShadowColor.migrate( newAttributes )
154156
newAttributes = deprecateBlockHeight.migrate( newAttributes )
157+
newAttributes = deprecateInnerBlockRowGapAndContainerHeight.migrate( '%s' )( newAttributes )
155158

156159
return [ newAttributes, innerBlocks ]
157160
},
@@ -163,9 +166,8 @@ const deprecated = [
163166
isEligible: attributes => {
164167
const hasBlockShadow = deprecateBlockShadowColor.isEligible( attributes )
165168
const hasContainerShadow = deprecateContainerShadowColor.isEligible( attributes )
166-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
167169

168-
return hasBlockShadow || hasContainerShadow || isNotV4
170+
return hasBlockShadow || hasContainerShadow
169171
},
170172
migrate: ( attributes, innerBlocks ) => {
171173
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
@@ -234,9 +236,8 @@ const deprecated = [
234236
isEligible: attributes => {
235237
const hasContainerOpacity = deprecateContainerBackgroundColorOpacity.isEligible( attributes )
236238
const hasBlockOpacity = deprecateBlockBackgroundColorOpacity.isEligible( attributes )
237-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
238239

239-
return hasContainerOpacity || hasBlockOpacity || isNotV4 || deprecationImageOverlayOpacity.isEligible( attributes )
240+
return hasContainerOpacity || hasBlockOpacity || deprecationImageOverlayOpacity.isEligible( attributes )
240241
},
241242
migrate: ( attributes, innerBlocks ) => {
242243
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
@@ -303,11 +304,6 @@ const deprecated = [
303304
// layout & containers work.
304305
attributes: attributes( '3.7.9' ),
305306
save: withVersion( '3.7.9' )( Save ),
306-
isEligible: attributes => {
307-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
308-
309-
return isNotV4
310-
},
311307
migrate: ( attributes, innerBlocks ) => {
312308
let newAttributes = {
313309
...attributes,

src/block/column/deprecated.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { semverCompare } from '~stackable/util'
1818
import {
1919
deprecateBlockBackgroundColorOpacity, deprecateContainerBackgroundColorOpacity,
2020
deprecateBlockShadowColor, deprecateContainerShadowColor, deprecateBlockHeight,
21+
deprecateInnerBlockRowGapAndContainerHeight,
2122
} from '~stackable/block-components'
2223

2324
// Version 3.8 added horizontal flex, we changed the stk--block-orientation-* to stk--block-horizontal-flex.
@@ -76,13 +77,14 @@ addFilter( 'stackable.column.save.blockClassNames', 'stackable/3.8.0', ( output,
7677

7778
const deprecated = [
7879
{
79-
// Support the change of type for block height
80+
// Support the change of type for block height, innerBlockRowGap and containerHeight
8081
attributes: attributes( '3.15.2' ),
8182
save: withVersion( '3.15.2' )( Save ),
8283
isEligible: attributes => {
83-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
8484
const hasNumberBlockHeight = deprecateBlockHeight.isEligible( attributes )
85-
return isNotV4 || hasNumberBlockHeight
85+
const hasNumberInnerBlockRowGapAndContainerHeight = deprecateInnerBlockRowGapAndContainerHeight.isEligible( '%s' )( attributes )
86+
87+
return hasNumberBlockHeight || hasNumberInnerBlockRowGapAndContainerHeight
8688
},
8789
migrate: ( attributes, innerBlocks ) => {
8890
const isNotV4 = attributes.version < 4 || typeof attributes.version === 'undefined'
@@ -144,6 +146,7 @@ const deprecated = [
144146
newAttributes = deprecateBlockShadowColor.migrate( newAttributes )
145147
newAttributes = deprecateContainerShadowColor.migrate( newAttributes )
146148
newAttributes = deprecateBlockHeight.migrate( newAttributes )
149+
newAttributes = deprecateInnerBlockRowGapAndContainerHeight.migrate( '%s' )( newAttributes )
147150

148151
return [ newAttributes, innerBlocks ]
149152
},
@@ -155,9 +158,8 @@ const deprecated = [
155158
isEligible: attributes => {
156159
const hasBlockShadow = deprecateBlockShadowColor.isEligible( attributes )
157160
const hasContainerShadow = deprecateContainerShadowColor.isEligible( attributes )
158-
const isNotV4 = attributes.version < 4 || typeof attributes.version === 'undefined'
159161

160-
return hasBlockShadow || hasContainerShadow || isNotV4
162+
return hasBlockShadow || hasContainerShadow
161163
},
162164
migrate: ( attributes, innerBlocks ) => {
163165
const isNotV4 = attributes.version < 4 || typeof attributes.version === 'undefined'
@@ -229,9 +231,8 @@ const deprecated = [
229231
isEligible: attributes => {
230232
const hasContainerOpacity = deprecateContainerBackgroundColorOpacity.isEligible( attributes )
231233
const hasBlockOpacity = deprecateBlockBackgroundColorOpacity.isEligible( attributes )
232-
const isNotV4 = attributes.version < 4 || typeof attributes.version === 'undefined'
233234

234-
return hasContainerOpacity || hasBlockOpacity || isNotV4
235+
return hasContainerOpacity || hasBlockOpacity
235236
},
236237
migrate: ( attributes, innerBlocks ) => {
237238
const isNotV4 = attributes.version < 4 || typeof attributes.version === 'undefined'
@@ -301,11 +302,6 @@ const deprecated = [
301302
// layout & containers work.
302303
attributes: attributes( '3.7.9' ),
303304
save: withVersion( '3.7.9' )( Save ),
304-
isEligible: attributes => {
305-
const isNotV4 = attributes.version < 4 || typeof attributes.version === 'undefined'
306-
307-
return isNotV4
308-
},
309305
migrate: ( attributes, innerBlocks ) => {
310306
let newAttributes = {
311307
...attributes,

src/block/hero/deprecated.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import compareVersions from 'compare-versions'
1212
import {
1313
deprecateBlockBackgroundColorOpacity, deprecateContainerBackgroundColorOpacity,
1414
deprecateBlockShadowColor, deprecateContainerShadowColor, deprecateShadowColor,
15-
deprecateBlockHeight,
15+
deprecateBlockHeight, deprecateInnerBlockRowGapAndContainerHeight,
1616
} from '~stackable/block-components'
1717

1818
/**
@@ -41,9 +41,10 @@ const deprecated = [
4141
attributes: attributes( '3.15.2' ),
4242
save: withVersion( '3.15.2' )( Save ),
4343
isEligible: attributes => {
44-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
4544
const hasNumberBlockHeight = deprecateBlockHeight.isEligible( attributes )
46-
return isNotV4 || hasNumberBlockHeight
45+
const hasNumberInnerBlockRowGapAndContainerHeight = deprecateInnerBlockRowGapAndContainerHeight.isEligible( '%s' )( attributes )
46+
47+
return hasNumberBlockHeight || hasNumberInnerBlockRowGapAndContainerHeight
4748
},
4849
migrate: ( attributes, innerBlocks ) => {
4950
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
@@ -103,6 +104,7 @@ const deprecated = [
103104
newAttributes = deprecateShadowColor.migrate( 'topSeparator%s' )( newAttributes )
104105
newAttributes = deprecateShadowColor.migrate( 'bottomSeparator%s' )( newAttributes )
105106
newAttributes = deprecateBlockHeight.migrate( newAttributes )
107+
newAttributes = deprecateInnerBlockRowGapAndContainerHeight.migrate( '%s' )( newAttributes )
106108

107109
return newAttributes
108110
},
@@ -116,9 +118,8 @@ const deprecated = [
116118
const hasContainerShadow = deprecateContainerShadowColor.isEligible( attributes )
117119
const hasTopSeparatorShadow = deprecateShadowColor.isEligible( 'topSeparator%s' )( attributes )
118120
const hasBottomSeparatorShadow = deprecateShadowColor.isEligible( 'bottomSeparator%s' )( attributes )
119-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
120121

121-
return hasBlockShadow || hasContainerShadow || hasTopSeparatorShadow || hasBottomSeparatorShadow || isNotV4
122+
return hasBlockShadow || hasContainerShadow || hasTopSeparatorShadow || hasBottomSeparatorShadow
122123
},
123124
migrate: ( attributes, innerBlocks ) => {
124125
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
@@ -188,9 +189,8 @@ const deprecated = [
188189
isEligible: attributes => {
189190
const hasContainerOpacity = deprecateContainerBackgroundColorOpacity.isEligible( attributes )
190191
const hasBlockOpacity = deprecateBlockBackgroundColorOpacity.isEligible( attributes )
191-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
192192

193-
return hasContainerOpacity || hasBlockOpacity || isNotV4
193+
return hasContainerOpacity || hasBlockOpacity
194194
},
195195
migrate: ( attributes, innerBlocks ) => {
196196
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
@@ -258,11 +258,6 @@ const deprecated = [
258258
// layout & containers work.
259259
attributes: attributes( '3.7.9' ),
260260
save: withVersion( '3.7.9' )( Save ),
261-
isEligible: attributes => {
262-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
263-
264-
return isNotV4
265-
},
266261
migrate: ( attributes, innerBlocks ) => {
267262
let newAttributes = {
268263
...attributes,

src/block/notification/deprecated.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import compareVersions from 'compare-versions'
1212
import {
1313
deprecateBlockBackgroundColorOpacity, deprecateContainerBackgroundColorOpacity,
1414
deprecateBlockShadowColor, deprecateContainerShadowColor, deprecateBlockHeight,
15+
deprecateInnerBlockRowGapAndContainerHeight,
1516
} from '~stackable/block-components'
1617

1718
/**
@@ -40,9 +41,10 @@ const deprecated = [
4041
attributes: attributes( '3.15.2' ),
4142
save: withVersion( '3.15.2' )( Save ),
4243
isEligible: attributes => {
43-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
4444
const hasNumberBlockHeight = deprecateBlockHeight.isEligible( attributes )
45-
return isNotV4 || hasNumberBlockHeight
45+
const hasNumberInnerBlockRowGapAndContainerHeight = deprecateInnerBlockRowGapAndContainerHeight.isEligible( '%s' )( attributes )
46+
47+
return hasNumberBlockHeight || hasNumberInnerBlockRowGapAndContainerHeight
4648
},
4749
migrate: ( attributes, innerBlocks ) => {
4850
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
@@ -100,6 +102,7 @@ const deprecated = [
100102
newAttributes = deprecateBlockShadowColor.migrate( newAttributes )
101103
newAttributes = deprecateContainerShadowColor.migrate( newAttributes )
102104
newAttributes = deprecateBlockHeight.migrate( newAttributes )
105+
newAttributes = deprecateInnerBlockRowGapAndContainerHeight.migrate( '%s' )( newAttributes )
103106

104107
return newAttributes
105108
},
@@ -111,9 +114,8 @@ const deprecated = [
111114
isEligible: attributes => {
112115
const hasBlockShadow = deprecateBlockShadowColor.isEligible( attributes )
113116
const hasContainerShadow = deprecateContainerShadowColor.isEligible( attributes )
114-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
115117

116-
return hasBlockShadow || hasContainerShadow || isNotV4
118+
return hasBlockShadow || hasContainerShadow
117119
},
118120
migrate: ( attributes, innerBlocks ) => {
119121
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
@@ -181,9 +183,8 @@ const deprecated = [
181183
isEligible: attributes => {
182184
const hasContainerOpacity = deprecateContainerBackgroundColorOpacity.isEligible( attributes )
183185
const hasBlockOpacity = deprecateBlockBackgroundColorOpacity.isEligible( attributes )
184-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
185186

186-
return hasContainerOpacity || hasBlockOpacity || isNotV4
187+
return hasContainerOpacity || hasBlockOpacity
187188
},
188189
migrate: ( attributes, innerBlocks ) => {
189190
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
@@ -249,11 +250,6 @@ const deprecated = [
249250
// layout & containers work.
250251
attributes: attributes( '3.7.9' ),
251252
save: withVersion( '3.7.9' )( Save ),
252-
isEligible: attributes => {
253-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
254-
255-
return isNotV4
256-
},
257253
migrate: ( attributes, innerBlocks ) => {
258254
let newAttributes = {
259255
...attributes,

src/block/pricing-box/deprecated.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import compareVersions from 'compare-versions'
1212
import {
1313
deprecateBlockBackgroundColorOpacity, deprecateContainerBackgroundColorOpacity,
1414
deprecateBlockShadowColor, deprecateContainerShadowColor, deprecateBlockHeight,
15+
deprecateInnerBlockRowGapAndContainerHeight,
1516
} from '~stackable/block-components'
1617
/**
1718
* WordPress dependencies
@@ -39,9 +40,10 @@ const deprecated = [
3940
attributes: attributes( '3.15.2' ),
4041
save: withVersion( '3.15.2' )( Save ),
4142
isEligible: attributes => {
42-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
4343
const hasNumberBlockHeight = deprecateBlockHeight.isEligible( attributes )
44-
return isNotV4 || hasNumberBlockHeight
44+
const hasNumberInnerBlockRowGapAndContainerHeight = deprecateInnerBlockRowGapAndContainerHeight.isEligible( '%s' )( attributes )
45+
46+
return hasNumberBlockHeight || hasNumberInnerBlockRowGapAndContainerHeight
4547
},
4648
migrate: ( attributes, innerBlocks ) => {
4749
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
@@ -99,6 +101,7 @@ const deprecated = [
99101
newAttributes = deprecateBlockShadowColor.migrate( newAttributes )
100102
newAttributes = deprecateContainerShadowColor.migrate( newAttributes )
101103
newAttributes = deprecateBlockHeight.migrate( newAttributes )
104+
newAttributes = deprecateInnerBlockRowGapAndContainerHeight.migrate( '%s' )( newAttributes )
102105

103106
return newAttributes
104107
},
@@ -110,9 +113,8 @@ const deprecated = [
110113
isEligible: attributes => {
111114
const hasBlockShadow = deprecateBlockShadowColor.isEligible( attributes )
112115
const hasContainerShadow = deprecateContainerShadowColor.isEligible( attributes )
113-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
114116

115-
return hasBlockShadow || hasContainerShadow || isNotV4
117+
return hasBlockShadow || hasContainerShadow
116118
},
117119
migrate: ( attributes, innerBlocks ) => {
118120
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
@@ -180,9 +182,8 @@ const deprecated = [
180182
isEligible: attributes => {
181183
const hasContainerOpacity = deprecateContainerBackgroundColorOpacity.isEligible( attributes )
182184
const hasBlockOpacity = deprecateBlockBackgroundColorOpacity.isEligible( attributes )
183-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
184185

185-
return hasContainerOpacity || hasBlockOpacity || isNotV4
186+
return hasContainerOpacity || hasBlockOpacity
186187
},
187188
migrate: ( attributes, innerBlocks ) => {
188189
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
@@ -248,11 +249,6 @@ const deprecated = [
248249
// layout & containers work.
249250
attributes: attributes( '3.7.9' ),
250251
save: withVersion( '3.7.9' )( Save ),
251-
isEligible: attributes => {
252-
const isNotV4 = attributes.version < 2 || typeof attributes.version === 'undefined'
253-
254-
return isNotV4
255-
},
256252
migrate: ( attributes, innerBlocks ) => {
257253
let newAttributes = {
258254
...attributes,

0 commit comments

Comments
 (0)