Add settings

[MAILPOET-1798]
This commit is contained in:
Pavel Dohnal
2020-02-04 08:56:17 +01:00
committed by Jack Kitterhing
parent 1dbf4714b1
commit 8b878e98d2
2 changed files with 45 additions and 30 deletions

View File

@@ -5,4 +5,6 @@
.mailpoet-block-create-new-content { .mailpoet-block-create-new-content {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-between;
min-height: 60px;
} }

View File

@@ -3,8 +3,8 @@ import PropTypes from 'prop-types';
import Icon from './icon.jsx'; import Icon from './icon.jsx';
const wp = window.wp; const wp = window.wp;
const { Placeholder } = wp.components; const { Placeholder, PanelBody } = wp.components;
const { BlockIcon } = wp.blockEditor; const { BlockIcon, InspectorControls } = wp.blockEditor;
const ServerSideRender = wp.serverSideRender; const ServerSideRender = wp.serverSideRender;
const allForms = window.mailpoet_forms; const allForms = window.mailpoet_forms;
@@ -20,7 +20,7 @@ function Edit({ attributes, setAttributes }) {
}); });
}} }}
className="mailpoet-block-create-forms-list" className="mailpoet-block-create-forms-list"
defaultValue={attributes.selectedForm} value={attributes.selectedForm}
> >
<option value="" disabled selected>Select a MailPoet form</option> <option value="" disabled selected>Select a MailPoet form</option>
{allForms.map((form) => ( {allForms.map((form) => (
@@ -41,15 +41,8 @@ function Edit({ attributes, setAttributes }) {
); );
} }
function selectFormSettings() {
return ( return (
<div className="mailpoet-block-div">
{
attributes.selectedForm === null && (
<Placeholder
className="mailpoet-block-create-new"
icon={<BlockIcon icon={Icon} showColors />}
label="MailPoet Subscription Form"
>
<div className="mailpoet-block-create-new-content"> <div className="mailpoet-block-create-new-content">
<a <a
href="admin.php?page=mailpoet-forms" href="admin.php?page=mailpoet-forms"
@@ -60,6 +53,25 @@ function Edit({ attributes, setAttributes }) {
</a> </a>
{displayFormsSelect()} {displayFormsSelect()}
</div> </div>
);
}
return (
<>
<InspectorControls>
<PanelBody title="MailPoet Subscription Form" initialOpen>
{selectFormSettings()}
</PanelBody>
</InspectorControls>
<div className="mailpoet-block-div">
{
attributes.selectedForm === null && (
<Placeholder
className="mailpoet-block-create-new"
icon={<BlockIcon icon={Icon} showColors />}
label="MailPoet Subscription Form"
>
{selectFormSettings()}
</Placeholder> </Placeholder>
) )
} }
@@ -69,6 +81,7 @@ function Edit({ attributes, setAttributes }) {
) )
} }
</div> </div>
</>
); );
} }