Skip to content

Commit 7044dab

Browse files
committed
updates
- modal for adding designs with disabled blocks - fix icon list substitution - fix style options spacing - hide design library modal header tabs - fix php error if download fails
1 parent bc53b53 commit 7044dab

File tree

7 files changed

+41
-35
lines changed

7 files changed

+41
-35
lines changed

src/block/design-library/edit.js

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,22 @@ const createBlockWithAttributes = async ( blockName, attributes, innerBlocks, su
162162
attributes = block[ 0 ].attributes
163163
innerBlocks = block[ 0 ].innerBlocks
164164

165+
if ( attributes.hasBackground ) {
166+
attributes.blockMargin = {
167+
top: '',
168+
right: '',
169+
bottom: '0',
170+
left: '',
171+
}
172+
} else {
173+
attributes.blockMargin = {
174+
top: '120',
175+
right: '',
176+
bottom: '120',
177+
left: '',
178+
}
179+
}
180+
165181
return createBlock( blockName, attributes, createBlocksFromInnerBlocksTemplate( innerBlocks ) )
166182
}
167183

@@ -305,7 +321,7 @@ const Edit = props => {
305321
{ isDialogOpen &&
306322
<Modal
307323
className="ugb-design-library__confirm-dialog"
308-
__experimentalHideHeader
324+
title={ __( 'Stackable Design Library', i18n ) }
309325
onRequestClose={ () => setIsDialogOpen( false ) }
310326
>
311327
<VStack spacing={ 8 }>
@@ -317,26 +333,26 @@ const Edit = props => {
317333
<span> { __( 'These blocks can be enabled in the Stackable settings page. Do you want to keep the disabled blocks or substitute them with other Stackable or core blocks?', i18n ) }</span>
318334
</div>
319335
<Flex direction="column" align="flex-end">
320-
<Button
321-
__next40pxDefaultSize
322-
variant="tertiary"
323-
onClick={ () => onClickTertiary() }
324-
>
325-
{ __( 'Visit the settings page and enable the blocks', i18n ) }
326-
</Button>
327336
<Button
328337
__next40pxDefaultSize
329338
variant="primary"
330339
onClick={ () => onClickPrimary() }
331340
>
332-
{ __( 'Add patterns and substitute missing blocks', i18n ) }
341+
{ __( 'Add patterns and substitute blocks', i18n ) }
333342
</Button>
334343
<Button
335344
__next40pxDefaultSize
336345
variant="secondary"
337346
onClick={ () => onClickSecondary() }
338347
>
339-
{ __( 'Add patterns without substituting missing blocks', i18n ) }
348+
{ __( 'Add patterns only (no substitutes)', i18n ) }
349+
</Button>
350+
<Button
351+
__next40pxDefaultSize
352+
variant="tertiary"
353+
onClick={ () => onClickTertiary() }
354+
>
355+
{ __( 'Enable blocks in settings', i18n ) }
340356
</Button>
341357
</Flex>
342358
</VStack>

src/block/icon-list/substitute.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
export const substitute = {
22
from: 'stackable/icon-list',
3-
transform: () => {
3+
transform: ( oldAttributes, innerBlocks ) => {
4+
const newInnerBlocks = innerBlocks.reduce( ( newInnerBlocks, innerBlock ) => {
5+
const attributes = innerBlock[ 1 ]
6+
7+
newInnerBlocks.push( [ 'core/list-item', { content: attributes.text } ] )
8+
return newInnerBlocks
9+
}, [] )
410
return [
511
'core/list',
612
{},
7-
[
8-
[ 'core/list-item', { content: 'First item list' } ],
9-
[ 'core/list-item', { content: 'Second item list' } ],
10-
[ 'core/list-item', { content: 'Third item list' } ],
11-
],
13+
newInnerBlocks,
1214
]
1315
},
1416
}

src/components/design-library-list/design-library-list-item.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ const DesignLibraryListItem = forwardRef( ( props, ref ) => {
230230
<button
231231
className={ mainClasses }
232232
ref={ ref }
233-
data-stk-design-id={ props.testId }
233+
data-stk-design-id={ props.designId }
234234
onClick={ () => {
235235
if ( ! isPro && plan !== 'free' ) {
236236
return

src/components/design-library-list/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ const DesignLibraryList = props => {
6363
backgroundScheme={ props.backgroundScheme }
6464
enableBackground={ props.enableBackground }
6565
selectedNum={ selectedNum }
66-
testId={ design.testId }
67-
testKey={ i }
6866
isBusy={ isBusy }
6967
forceUpdate={ forceUpdate }
7068
onClick={ ( designId, parsedBlocks, hasDisabledBlocks ) => onSelectMulti( designId, parsedBlocks, hasDisabledBlocks ) }

src/components/modal-design-library/modal.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
/**
22
* Internal deprendencies
33
*/
4-
// import SVGViewSingle from './images/view-single.svg'
5-
// import SVGViewMany from './images/view-many.svg'
6-
// import SVGViewFew from './images/view-few.svg'
74
import BlockList from './block-list'
85
import Button from '../button'
9-
import AdvancedToolbarControl from '../advanced-toolbar-control'
6+
// import AdvancedToolbarControl from '../advanced-toolbar-control'
107
import DesignLibraryList from '~stackable/components/design-library-list'
118
import { getDesigns, filterDesigns } from '~stackable/design-library'
129

@@ -54,7 +51,7 @@ export const ModalDesignLibrary = props => {
5451

5552
const [ isMultiSelectBusy, setIsMultiSelectBusy ] = useState( false )
5653

57-
const [ selectedTab, setSelectedTab ] = useLocalStorage( 'stk__design_library__block-list__view_by', 'patterns' )
54+
const [ selectedTab, _setSelectedTab ] = useLocalStorage( 'stk__design_library__block-list__view_by', 'patterns' )
5855
const [ selectedCategory, setSelectedCategory ] = useLocalStorage( 'stk__design_library__block-list__selected', '' )
5956
const [ selectedPlan, setSelectedPlan ] = useLocalStorage( 'stk__design_library__view-plan', PLAN_OPTIONS[ 0 ] )
6057

@@ -104,6 +101,7 @@ export const ModalDesignLibrary = props => {
104101
title={ __( 'Stackable Design Library', i18n ) }
105102
headerActions={ (
106103
<>
104+
{ /* DEV NOTE: hide for now
107105
<AdvancedToolbarControl
108106
className="stk-design-library-tabs"
109107
fullwidth={ false }
@@ -129,7 +127,7 @@ export const ModalDesignLibrary = props => {
129127
onChange={ setSelectedTab }
130128
isToggleOnly={ true }
131129
allowReset={ false }
132-
/>
130+
/> */ }
133131

134132
<div className="stk-design-library__header-settings">
135133
<Button
@@ -196,7 +194,7 @@ export const ModalDesignLibrary = props => {
196194
/>
197195
</div>
198196
<div className="ugb-modal-design-library__style-options">
199-
<h4 style={ { margin: '0' } }>{ __( 'Style Options', i18n ) }</h4>
197+
<h4 style={ { margin: '0 0 1em ' } }>{ __( 'Style Options', i18n ) }</h4>
200198
<ToggleControl
201199
className="ugb-modal-design-library__enable-background"
202200
label="Section Background"

src/design-library/index.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import apiFetch from '@wordpress/api-fetch'
22
import { doAction, applyFilters } from '@wordpress/hooks'
3-
// import TEST_DESIGN from './test.json'
43

54
const LATEST_API_VERSION = 'v4'
65

@@ -54,13 +53,7 @@ export const setDevModeDesignLibrary = async ( devMode = false ) => {
5453
export const getDesigns = async ( {
5554
reset = false,
5655
} ) => {
57-
let library = Object.values( await fetchDesignLibrary( reset ) )
58-
library = library.map( ( item, index ) => {
59-
return {
60-
...item,
61-
testId: `stk-design-${ index + 1 }`,
62-
}
63-
} )
56+
const library = Object.values( await fetchDesignLibrary( reset ) )
6457
return library
6558
}
6659

src/design-library/init.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ public function get_design_library_image( $request ) {
146146
$temp_filepath = download_url( $url );
147147

148148
if ( is_wp_error( $temp_filepath ) ) {
149-
@unlink( $temp_filepath );
150149
return new WP_REST_Response( array(
151150
'success' => false,
152151
'message' => 'Failed to retrieve image from the provided URL.'

0 commit comments

Comments
 (0)