Rename block attribute

[MAILPOET-1798]
This commit is contained in:
Pavel Dohnal
2020-02-06 13:41:13 +01:00
committed by Jack Kitterhing
parent 831a865c9e
commit 62c5a8cc84
3 changed files with 19 additions and 42 deletions

View File

@@ -17,11 +17,11 @@ function Edit({ attributes, setAttributes }) {
<select
onChange={(event) => {
setAttributes({
selectedForm: parseInt(event.target.value, 10),
formId: parseInt(event.target.value, 10),
});
}}
className="mailpoet-block-create-forms-list"
value={attributes.selectedForm}
value={attributes.formId}
>
<option value="" disabled selected>{window.locale.selectForm}</option>
{allForms.map((form) => (
@@ -36,8 +36,8 @@ function Edit({ attributes, setAttributes }) {
function renderForm() {
return (
<ServerSideRender
block="mailpoet/form-block-render"
attributes={{ form: attributes.selectedForm }}
block="mailpoet/subscription-form-block-render"
attributes={{ form: attributes.formId }}
/>
);
}
@@ -66,7 +66,7 @@ function Edit({ attributes, setAttributes }) {
</InspectorControls>
<div className="mailpoet-block-div">
{
attributes.selectedForm === null && (
attributes.formId === null && (
<Placeholder
className="mailpoet-block-create-new"
icon={<BlockIcon icon={Icon} showColors />}
@@ -77,7 +77,7 @@ function Edit({ attributes, setAttributes }) {
)
}
{
attributes.selectedForm !== null && (
attributes.formId !== null && (
renderForm()
)
}
@@ -88,7 +88,7 @@ function Edit({ attributes, setAttributes }) {
Edit.propTypes = {
attributes: PropTypes.shape({
selectedForm: PropTypes.number,
formId: PropTypes.number,
}).isRequired,
setAttributes: PropTypes.func.isRequired,
};

View File

@@ -10,7 +10,7 @@ registerBlockType('mailpoet/form-block', {
category: 'widgets',
example: {},
attributes: {
selectedForm: {
formId: {
type: 'number',
default: null,
},