Remove select form template feature switch

[MAILPOET-2988]
This commit is contained in:
Rostislav Wolny
2020-09-30 11:13:16 +02:00
committed by Veljko V
parent bd08cfd6a0
commit ec2e2418fd
4 changed files with 38 additions and 75 deletions

View File

@@ -5,7 +5,6 @@ import jQuery from 'jquery';
import PropTypes from 'prop-types';
import Listing from 'listing/listing.jsx';
import withNpsPoll from 'nps_poll.jsx';
import { GlobalContext } from 'context/index.jsx';
const columns = [
{
@@ -153,35 +152,10 @@ const itemActions = [
];
class FormList extends React.Component {
createForm = (templatesEnabled) => {
if (templatesEnabled) {
MailPoet.trackEvent('Forms > Add New', {
'MailPoet Free version': window.mailpoet_version,
});
setTimeout(() => {
window.location = window.mailpoet_form_template_selection_url;
}, 200); // leave some time for the event to track
} else {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'forms',
action: 'create',
}).done((response) => {
MailPoet.trackEvent('Forms > Add New', {
'MailPoet Free version': window.mailpoet_version,
});
setTimeout(() => {
window.location = window.mailpoet_form_edit_url + response.data.id;
}, 200);
}).fail((response) => {
if (response.errors.length > 0) {
MailPoet.Notice.error(
response.errors.map((error) => error.message),
{ scroll: true }
);
}
});
}
goToSelectTemplate = () => {
setTimeout(() => {
window.location = window.mailpoet_form_template_selection_url;
}, 200); // leave some time for the event to track
};
updateStatus = (e) => {
@@ -280,37 +254,33 @@ class FormList extends React.Component {
render() {
return (
<GlobalContext.Consumer>
{(value) => (
<div>
<h1 className="title">
{MailPoet.I18n.t('pageTitle')}
{' '}
<button
className="page-title-action"
onClick={() => this.createForm(value.features.isSupported('templates-selection'))}
data-automation-id="create_new_form"
type="button"
>
{MailPoet.I18n.t('new')}
</button>
</h1>
<div>
<h1 className="title">
{MailPoet.I18n.t('pageTitle')}
{' '}
<button
className="page-title-action"
onClick={() => this.goToSelectTemplate()}
data-automation-id="create_new_form"
type="button"
>
{MailPoet.I18n.t('new')}
</button>
</h1>
<Listing
limit={window.mailpoet_listing_per_page}
location={this.props.location}
params={this.props.match.params}
messages={messages}
search={false}
endpoint="forms"
onRenderItem={this.renderItem}
columns={columns}
bulk_actions={bulkActions}
item_actions={itemActions}
/>
</div>
)}
</GlobalContext.Consumer>
<Listing
limit={window.mailpoet_listing_per_page}
location={this.props.location}
params={this.props.match.params}
messages={messages}
search={false}
endpoint="forms"
onRenderItem={this.renderItem}
columns={columns}
bulk_actions={bulkActions}
item_actions={itemActions}
/>
</div>
);
}
}