Render list of templates
[MAILPOET-2987]
This commit is contained in:
@@ -9,7 +9,10 @@ const App = () => (
|
|||||||
<GlobalContext.Provider value={useGlobalContextValue(window)}>
|
<GlobalContext.Provider value={useGlobalContextValue(window)}>
|
||||||
<>
|
<>
|
||||||
<Notices />
|
<Notices />
|
||||||
<Selection />
|
<Selection
|
||||||
|
templates={(window as any).mailpoet_templates}
|
||||||
|
formEditorUrl={(window as any).mailpoet_form_edit_url}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
</GlobalContext.Provider>
|
</GlobalContext.Provider>
|
||||||
);
|
);
|
||||||
|
@@ -2,8 +2,34 @@ import React from 'react';
|
|||||||
import Heading from 'common/typography/heading/heading';
|
import Heading from 'common/typography/heading/heading';
|
||||||
import MailPoet from 'mailpoet';
|
import MailPoet from 'mailpoet';
|
||||||
|
|
||||||
export default () => (
|
type Template = {
|
||||||
|
id: string
|
||||||
|
name: string
|
||||||
|
};
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
templates: Array<Template>
|
||||||
|
formEditorUrl: string
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ({ formEditorUrl, templates }: Props) => (
|
||||||
<div className="template-selection">
|
<div className="template-selection">
|
||||||
<Heading level={1}>{MailPoet.I18n.t('heading')}</Heading>
|
<Heading level={1}>{MailPoet.I18n.t('heading')}</Heading>
|
||||||
|
<ol>
|
||||||
|
<li>
|
||||||
|
<a href={formEditorUrl}>
|
||||||
|
{MailPoet.I18n.t('blankTemplate')}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{templates.map((template) => (
|
||||||
|
<li
|
||||||
|
key={template.id}
|
||||||
|
>
|
||||||
|
<a href={`${formEditorUrl}${template.id}`}>
|
||||||
|
{template.name}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@@ -20,6 +20,8 @@
|
|||||||
<script>
|
<script>
|
||||||
<% autoescape 'js' %>
|
<% autoescape 'js' %>
|
||||||
var mailpoet_templates = <%= json_encode(templates) %>;
|
var mailpoet_templates = <%= json_encode(templates) %>;
|
||||||
|
var mailpoet_form_edit_url =
|
||||||
|
"<%= admin_url('admin.php?page=mailpoet-form-editor&action=create&template-id=') %>";
|
||||||
<% endautoescape %>
|
<% endautoescape %>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -29,6 +31,7 @@
|
|||||||
<% block translations %>
|
<% block translations %>
|
||||||
<%= localize({
|
<%= localize({
|
||||||
'heading': __('Select form template'),
|
'heading': __('Select form template'),
|
||||||
|
'blankTemplate': _x('Blank template', 'the first item in the templates selection list'),
|
||||||
}) %>
|
}) %>
|
||||||
<% endblock %>
|
<% endblock %>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user