diff --git a/src/blocks/services/block.json b/src/blocks/services/block.json
index ddad13f0c3b..f1520d0a0ae 100644
--- a/src/blocks/services/block.json
+++ b/src/blocks/services/block.json
@@ -13,10 +13,6 @@
"headingLevel": {
"type": "integer",
"default": 3
- },
- "buttons": {
- "type": "boolean",
- "default": false
}
},
"title": "Services",
diff --git a/src/blocks/services/edit.js b/src/blocks/services/edit.js
index d8ae1038f1c..979d4c3e936 100644
--- a/src/blocks/services/edit.js
+++ b/src/blocks/services/edit.js
@@ -66,13 +66,6 @@ const Edit = ( props ) => {
updateInnerAttributes( 'coblocks/service', { headingLevel } );
};
- const toggleCtas = () => {
- const buttons = ! attributes.buttons;
- setAttributes( { buttons } );
-
- updateInnerAttributes( 'coblocks/service', { showCta: buttons } );
- };
-
const setColumns = ( value ) => {
setAttributes( { columns: parseInt( value ) } );
};
@@ -90,10 +83,9 @@ const Edit = ( props ) => {
/* istanbul ignore next */
useEffect( () => {
// Handle add and removal of service block when column is changed.
- const { buttons, headingLevel, alignment } = props;
+ const { headingLevel, alignment } = props;
handlePlaceholderPlacement( 'coblocks/service', {
- showCta: buttons,
headingLevel,
alignment,
} );
@@ -159,7 +151,6 @@ const Edit = ( props ) => {
setAttributes={ setAttributes }
activeStyle={ activeStyle }
layoutOptions={ layoutOptions }
- onToggleCtas={ toggleCtas }
onUpdateStyle={ updateStyle }
onSetColumns={ setColumns }
/>
diff --git a/src/blocks/services/inspector.js b/src/blocks/services/inspector.js
index 14f5f3d2d99..35d38ee387c 100644
--- a/src/blocks/services/inspector.js
+++ b/src/blocks/services/inspector.js
@@ -12,7 +12,7 @@ import GutterControl from '../../components/gutter-control/gutter-control';
* WordPress dependencies.
*/
import { __ } from '@wordpress/i18n';
-import { PanelBody, ToggleControl, RangeControl } from '@wordpress/components';
+import { PanelBody, RangeControl } from '@wordpress/components';
import { InspectorControls } from '@wordpress/block-editor';
import { ENTER, SPACE } from '@wordpress/keycodes';
@@ -22,7 +22,6 @@ const Inspector = ( props ) => {
setAttributes,
activeStyle,
layoutOptions,
- onToggleCtas,
onUpdateStyle,
} = props;
@@ -71,17 +70,6 @@ const Inspector = ( props ) => {
onChange={ ( columns ) => setAttributes( { columns } ) }
/>
{ attributes.columns >= 2 && }
-
);
diff --git a/src/blocks/services/service/block.json b/src/blocks/services/service/block.json
index bbabb30957d..d53b31fd4b0 100644
--- a/src/blocks/services/service/block.json
+++ b/src/blocks/services/service/block.json
@@ -6,10 +6,6 @@
"type": "integer",
"default": 3
},
- "showCta": {
- "type": "boolean",
- "default": false
- },
"imageUrl": {
"type": "string",
"source": "attribute",
diff --git a/src/blocks/services/service/edit.js b/src/blocks/services/service/edit.js
index 068e8a90741..b73e87badac 100644
--- a/src/blocks/services/service/edit.js
+++ b/src/blocks/services/service/edit.js
@@ -14,7 +14,6 @@ import classnames from 'classnames';
*/
import { __ } from '@wordpress/i18n';
import { closeSmall } from '@wordpress/icons';
-import { createBlock } from '@wordpress/blocks';
import { isBlobURL } from '@wordpress/blob';
import { useEffect } from '@wordpress/element';
import {
@@ -58,7 +57,7 @@ const Edit = ( props ) => {
return isSelected || rootClientId === selectedRootClientId;
} );
- const { updateBlockAttributes, insertBlock, removeBlocks } = useDispatch( 'core/block-editor' );
+ const { updateBlockAttributes } = useDispatch( 'core/block-editor' );
const updateInnerAttributes = ( blockName, newAttributes ) => {
innerItems.forEach( ( item ) => {
@@ -71,30 +70,6 @@ const Edit = ( props ) => {
} );
};
- const manageInnerBlock = ( blockName, blockAttributes, show = true ) => {
- const migrateButton = innerItems.filter( ( item ) => item.name === 'core/button' );
-
- // Migrate core/button to core/buttons block
- if ( !! migrateButton.length ) {
- removeBlocks( migrateButton.map( ( item ) => item.clientId ), false );
- const newBlock = createBlock( blockName, blockAttributes, migrateButton );
- insertBlock( newBlock, innerItems.length, clientId, false );
- return;
- }
-
- const targetBlock = innerItems.filter( ( item ) => item.name === blockName );
-
- if ( ! targetBlock.length && show ) {
- const newButton = createBlock( 'core/button', {} );
- const newBlock = createBlock( blockName, blockAttributes, [ newButton ] );
- insertBlock( newBlock, innerItems.length, clientId, false );
- }
-
- if ( targetBlock.length && ! show ) {
- removeBlocks( targetBlock.map( ( item ) => item.clientId ), false );
- }
- };
-
/* istanbul ignore next */
useEffect( () => {
updateInnerAttributes( 'core/heading', { level: attributes.headingLevel } );
@@ -105,15 +80,6 @@ const Edit = ( props ) => {
updateInnerAttributes( 'core/buttons', { contentJustification: attributes.alignment } );
}, [ attributes.alignment ] );
- /* istanbul ignore next */
- useEffect( () => {
- manageInnerBlock( 'core/buttons', { contentJustification: attributes.alignment }, attributes.showCta );
- }, [ attributes.showCta ] );
-
- const toggleCta = () => {
- setAttributes( { showCta: ! showCta } );
- };
-
const replaceImage = ( file ) => {
setAttributes( { imageAlt: file.alt, imageId: file.id, imageUrl: file.url } );
};
@@ -197,7 +163,6 @@ const Edit = ( props ) => {
linkDestination,
linkTarget,
rel,
- showCta,
alignment,
} = attributes;
@@ -255,7 +220,6 @@ const Edit = ( props ) => {
diff --git a/src/blocks/services/service/inspector.js b/src/blocks/services/service/inspector.js
index 6d8bc064b8a..ddc95a13f38 100644
--- a/src/blocks/services/service/inspector.js
+++ b/src/blocks/services/service/inspector.js
@@ -2,30 +2,17 @@
* WordPress dependencies.
*/
import { __ } from '@wordpress/i18n';
-import { PanelBody, ToggleControl, TextareaControl, ExternalLink, FocalPointPicker } from '@wordpress/components';
+import { PanelBody, TextareaControl, ExternalLink, FocalPointPicker } from '@wordpress/components';
import { InspectorControls } from '@wordpress/block-editor';
const Inspector = ( props ) => {
const {
attributes,
setAttributes,
- onToggleCta,
} = props;
return (
-
-
-
{ attributes.imageUrl &&
+"
"
`;
exports[`coblocks/service should render with href 1`] = `
-"
+"
"
`;
diff --git a/src/blocks/services/service/test/save.spec.js b/src/blocks/services/service/test/save.spec.js
index f9609d6804f..8375aa0b0f8 100644
--- a/src/blocks/services/service/test/save.spec.js
+++ b/src/blocks/services/service/test/save.spec.js
@@ -27,14 +27,12 @@ describe( 'coblocks/service', () => {
block.attributes.imageUrl = 'https://website.com/wp-content/uploads/1234/56/image.jpg';
block.attributes.imageAlt = 'alt text';
block.attributes.focalPoint = { x: 100, y: 0 };
- block.attributes.showCta = 1;
const serializedBlock = serialize( block );
expect( serializedBlock ).toBeDefined();
expect( serializedBlock ).toContain( `src="${ block.attributes.imageUrl }"` );
expect( serializedBlock ).toContain( `alt="${ block.attributes.imageAlt }"` );
expect( serializedBlock ).toContain( 'style="object-position:10000% 0%"' );
- expect( serializedBlock ).toContain( '"showCta":1' );
expect( serializedBlock ).toMatchSnapshot();
} );
diff --git a/src/blocks/services/test/__snapshots__/save.spec.js.snap b/src/blocks/services/test/__snapshots__/save.spec.js.snap
index be2e0c38234..abc596434c2 100644
--- a/src/blocks/services/test/__snapshots__/save.spec.js.snap
+++ b/src/blocks/services/test/__snapshots__/save.spec.js.snap
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`coblocks/services should render 1`] = `
-"
+"
"
`;
diff --git a/src/blocks/services/test/save.spec.js b/src/blocks/services/test/save.spec.js
index b26c2a8741f..d6a4eeef81e 100644
--- a/src/blocks/services/test/save.spec.js
+++ b/src/blocks/services/test/save.spec.js
@@ -32,7 +32,6 @@ describe( 'coblocks/services', () => {
block.attributes.gutter = 'huge';
block.attributes.alignment = 'center';
block.attributes.headingLevel = 2;
- block.attributes.buttons = true;
serializedBlock = serialize( block );
expect( serializedBlock ).toBeDefined();
@@ -40,7 +39,6 @@ describe( 'coblocks/services', () => {
expect( serializedBlock ).toContain( 'has-huge-gutter' );
expect( serializedBlock ).toContain( '"alignment":"center"' );
expect( serializedBlock ).toContain( '"headingLevel":2' );
- expect( serializedBlock ).toContain( '"buttons":true' );
expect( serializedBlock ).toMatchSnapshot();
} );
} );
diff --git a/src/blocks/services/test/services.cypress.js b/src/blocks/services/test/services.cypress.js
index 71bde29551a..7c33bfbfd7c 100644
--- a/src/blocks/services/test/services.cypress.js
+++ b/src/blocks/services/test/services.cypress.js
@@ -89,21 +89,31 @@ describe( 'Test CoBlocks Services Block', function() {
} );
/**
- * Test that we can add a services block to the content, enable
- * action buttons and are able to successfully save the block without errors.
+ * Test that we can add a services block to the content with a nested button block
+ * and are able to successfully save the services and button blocks without errors.
*/
- it( 'Test services block saves with action buttons enabled.', function() {
+ it( 'Test services block saves after adding button', function() {
helpers.addBlockToPost( 'coblocks/services', true );
cy.get( 'div.wp-block-button' ).should( 'not.exist' );
- helpers.toggleSettingCheckbox( /display buttons/i );
+ const servicesBlock = cy.get( '[data-type="coblocks/services"]' );
- cy.get( '.wp-block-buttons' ).should( 'have.length', 2 );
+ // Select the first child paragraph block of the parent services block
+ const servicesBlockParagraph = servicesBlock.find( '[data-type="core/paragraph"]' ).first();
+ // Insert a new buttons block into the services block
+ servicesBlockParagraph.click().type( '/buttons' ).type( '{enter}' );
+
+ cy.get( 'div.wp-block-button' ).should( 'exist' );
+
+ // Check ability to save page without errors
helpers.savePage();
helpers.checkForBlockErrors( 'coblocks/services' );
+
+ // Check button persists after saving
+ cy.get( 'div.wp-block-button' ).should( 'exist' );
} );
/**