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>
);
}
}

View File

@ -6,15 +6,9 @@ use MailPoetVendor\Doctrine\DBAL\Exception\TableNotFoundException;
class FeaturesController {
// Define features below in the following form:
// const FEATURE_NAME_OF_FEATURE = 'name-of-feature';
const TEMPLATES_SELECTION = 'templates-selection';
// Define feature defaults in the array below in the following form:
// self::FEATURE_NAME_OF_FEATURE => true,
private $defaults = [
self::TEMPLATES_SELECTION => false,
];
private $defaults = [];
/** @var array */
private $flags;

View File

@ -2,16 +2,9 @@
namespace MailPoet\Test\Acceptance;
use MailPoet\Features\FeaturesController;
use MailPoet\Test\DataFactories\Features;
use MailPoet\Test\DataFactories\Segment;
class CreateFormUsingTemplateCest {
public function _before() {
$features = new Features();
$features->withFeatureEnabled(FeaturesController::TEMPLATES_SELECTION);
}
public function createFormUsingTemplate(\AcceptanceTester $i) {
$segmentFactory = new Segment();
$segmentName = 'Fancy List';
@ -23,7 +16,11 @@ class CreateFormUsingTemplateCest {
$i->click('[data-automation-id="create_new_form"]');
$i->waitForElement('[data-automation-id="template_selection_list"]');
$i->click('[data-automation-id="select_template_template_1_popup"]');
$i->waitForElement('[data-automation-id="select_template_template_1_popup"]');
$i->wantTo('Switch template category and crete a form');
$i->click('[data-title="Fixed bar"]');
$i->waitForElement('[data-automation-id="select_template_template_1_fixed_bar"]');
$i->click('[data-automation-id="select_template_template_1_fixed_bar"]');
$i->waitForElement('[data-automation-id="form_title_input"]', 20);
$i->selectOptionInSelect2($segmentName);

View File

@ -43,6 +43,8 @@ class FormEditorUpdateNewFormCest {
$formName = 'My awesome form';
$updatedFormName = 'My updated awesome form';
$i->click('[data-automation-id="create_new_form"]');
$i->waitForElement('[data-automation-id="template_selection_list"]');
$i->click('[data-automation-id="select_template_template_1_popup"]');
$i->waitForElement('[data-automation-id="form_title_input"]');
$i->fillField('[data-automation-id="form_title_input"]', $formName);
// Try saving form without selected list